Documentation ¶
Index ¶
- Variables
- func BuildImageCmdWithHost(dockerBinary, name, dockerfile, host string, useCache bool, ...) *exec.Cmd
- func SignalDaemonDump(pid int)
- func WaitInspectWithArgs(dockerBinary, name, expr, expected string, timeout time.Duration, ...) error
- type Config
- type Daemon
- func (d *Daemon) ActiveContainers() (ids []string)
- func (d *Daemon) BuildImageWithOut(name, dockerfile string, useCache bool, buildFlags ...string) (string, int, error)
- func (d *Daemon) CheckActiveContainerCount(c *check.C) (interface{}, check.CommentInterface)
- func (d *Daemon) CleanupExecRoot(c *check.C)
- func (d *Daemon) Cmd(args ...string) (string, error)
- func (d *Daemon) Command(args ...string) *exec.Cmd
- func (d *Daemon) DumpStackAndQuit()
- func (d *Daemon) FindContainerIP(id string) (string, error)
- func (d *Daemon) GetBaseDeviceSize(c *check.C) int64
- func (d *Daemon) GetIDByName(name string) (string, error)
- func (d *Daemon) ID() string
- func (d *Daemon) InspectField(name, filter string) (string, error)
- func (d *Daemon) Interrupt() error
- func (d *Daemon) Kill() error
- func (d *Daemon) LoadBusybox() error
- func (d *Daemon) LogFileName() string
- func (d *Daemon) Pid() int
- func (d *Daemon) PrependHostArg(args []string) []string
- func (d *Daemon) ReadLogFile() ([]byte, error)
- func (d *Daemon) ReloadConfig() error
- func (d *Daemon) Restart(t testingT, args ...string)
- func (d *Daemon) RestartWithError(arg ...string) error
- func (d *Daemon) RootDir() string
- func (d *Daemon) Signal(signal os.Signal) error
- func (d *Daemon) Sock() string
- func (d *Daemon) SockRequest(method, endpoint string, data interface{}) (int, []byte, error)
- func (d *Daemon) SockRequestRaw(method, endpoint string, data io.Reader, ct string) (*http.Response, io.ReadCloser, error)
- func (d *Daemon) Start(t testingT, args ...string)
- func (d *Daemon) StartWithBusybox(t testingT, arg ...string)
- func (d *Daemon) StartWithError(args ...string) error
- func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error
- func (d *Daemon) Stop(t testingT)
- func (d *Daemon) StopWithError() error
- func (d *Daemon) StorageDriver() string
- func (d *Daemon) WaitRun(contID string) error
- type NodeConstructor
- type ServiceConstructor
- type SpecConstructor
- type Swarm
- func (d *Swarm) CheckControlAvailable(c *check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckLeader(c *check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckLocalNodeState(c *check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckNodeReadyCount(c *check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckRunningTaskImages(c *check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckServiceRunningTasks(service string) func(*check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckServiceTasks(service string) func(*check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CheckServiceUpdateState(service string) func(*check.C) (interface{}, check.CommentInterface)
- func (d *Swarm) CmdRetryOutOfSequence(args ...string) (string, error)
- func (d *Swarm) CreateSecret(c *check.C, secretSpec swarm.SecretSpec) string
- func (d *Swarm) CreateService(c *check.C, f ...ServiceConstructor) string
- func (d *Swarm) DeleteSecret(c *check.C, id string)
- func (d *Swarm) GetNode(c *check.C, id string) *swarm.Node
- func (d *Swarm) GetSecret(c *check.C, id string) *swarm.Secret
- func (d *Swarm) GetService(c *check.C, id string) *swarm.Service
- func (d *Swarm) GetServiceTasks(c *check.C, service string) []swarm.Task
- func (d *Swarm) GetSwarm(c *check.C) swarm.Swarm
- func (d *Swarm) GetTask(c *check.C, id string) swarm.Task
- func (d *Swarm) Init(req swarm.InitRequest) error
- func (d *Swarm) Join(req swarm.JoinRequest) error
- func (d *Swarm) JoinTokens(c *check.C) swarm.JoinTokens
- func (d *Swarm) Leave(force bool) error
- func (d *Swarm) ListNodes(c *check.C) []swarm.Node
- func (d *Swarm) ListSecrets(c *check.C) []swarm.Secret
- func (d *Swarm) ListServices(c *check.C) []swarm.Service
- func (d *Swarm) RemoveNode(c *check.C, id string, force bool)
- func (d *Swarm) RemoveService(c *check.C, id string)
- func (d *Swarm) RotateTokens(c *check.C)
- func (d *Swarm) SwarmInfo() (swarm.Info, error)
- func (d *Swarm) Unlock(req swarm.UnlockRequest) error
- func (d *Swarm) UpdateNode(c *check.C, id string, f ...NodeConstructor)
- func (d *Swarm) UpdateService(c *check.C, service *swarm.Service, f ...ServiceConstructor)
- func (d *Swarm) UpdateSwarm(c *check.C, f ...SpecConstructor)
Constants ¶
This section is empty.
Variables ¶
var SockRoot = filepath.Join(os.TempDir(), "docker-integration")
SockRoot holds the path of the default docker integration daemon socket
Functions ¶
func BuildImageCmdWithHost ¶
func BuildImageCmdWithHost(dockerBinary, name, dockerfile, host string, useCache bool, buildFlags ...string) *exec.Cmd
BuildImageCmdWithHost create a build command with the specified arguments. FIXME(vdemeester) move this away
func SignalDaemonDump ¶
func SignalDaemonDump(pid int)
SignalDaemonDump sends a signal to the daemon to write a dump file
func WaitInspectWithArgs ¶
func WaitInspectWithArgs(dockerBinary, name, expr, expected string, timeout time.Duration, arg ...string) error
WaitInspectWithArgs waits for the specified expression to be equals to the specified expected string in the given time. FIXME(vdemeester) Attach this to the Daemon struct
Types ¶
type Config ¶
type Config struct {
Experimental bool
}
Config holds docker daemon integration configuration
type Daemon ¶
type Daemon struct { GlobalFlags []string Root string Folder string Wait chan error UseDefaultHost bool UseDefaultTLSHost bool // contains filtered or unexported fields }
Daemon represents a Docker daemon for the testing framework.
func New ¶
New returns a Daemon instance to be used for testing. This will create a directory such as d123456789 in the folder specified by $DEST. The daemon will not automatically start.
func (*Daemon) ActiveContainers ¶
ActiveContainers returns the list of ids of the currently running containers
func (*Daemon) BuildImageWithOut ¶
func (d *Daemon) BuildImageWithOut(name, dockerfile string, useCache bool, buildFlags ...string) (string, int, error)
BuildImageWithOut builds an image with the specified dockerfile and options and returns the output
func (*Daemon) CheckActiveContainerCount ¶
func (d *Daemon) CheckActiveContainerCount(c *check.C) (interface{}, check.CommentInterface)
CheckActiveContainerCount returns the number of active containers FIXME(vdemeester) should re-use ActivateContainers in some way
func (*Daemon) CleanupExecRoot ¶
CleanupExecRoot cleans the daemon exec root (network namespaces, ...)
func (*Daemon) Cmd ¶
Cmd will execute a docker CLI command against this Daemon. Example: d.Cmd("version") will run docker -H unix://path/to/unix.sock version
func (*Daemon) DumpStackAndQuit ¶
func (d *Daemon) DumpStackAndQuit()
DumpStackAndQuit sends SIGQUIT to the daemon, which triggers it to dump its stack to its log file and exit This is used primarily for gathering debug information on test timeout
func (*Daemon) FindContainerIP ¶
FindContainerIP returns the ip of the specified container
func (*Daemon) GetBaseDeviceSize ¶
GetBaseDeviceSize returns the base device size of the daemon
func (*Daemon) GetIDByName ¶
GetIDByName returns the ID of an object (container, volume, …) given its name
func (*Daemon) InspectField ¶
InspectField returns the field filter by 'filter'
func (*Daemon) LoadBusybox ¶
LoadBusybox will load the stored busybox into a newly started daemon
func (*Daemon) LogFileName ¶
LogFileName returns the path the daemon's log file
func (*Daemon) PrependHostArg ¶
PrependHostArg prepend the specified arguments by the daemon host flags
func (*Daemon) ReadLogFile ¶
ReadLogFile returns the content of the daemon log file
func (*Daemon) ReloadConfig ¶
ReloadConfig asks the daemon to reload its configuration
func (*Daemon) Restart ¶
Restart will restart the daemon by first stopping it and the starting it. If an error occurs while starting the daemon, the test will fail.
func (*Daemon) RestartWithError ¶
RestartWithError will restart the daemon by first stopping it and then starting it.
func (*Daemon) SockRequest ¶
SockRequest executes a socket request on a daemon and returns statuscode and output.
func (*Daemon) SockRequestRaw ¶
func (d *Daemon) SockRequestRaw(method, endpoint string, data io.Reader, ct string) (*http.Response, io.ReadCloser, error)
SockRequestRaw executes a socket request on a daemon and returns an http response and a reader for the output data.
func (*Daemon) StartWithBusybox ¶
StartWithBusybox will first start the daemon with Daemon.Start() then save the busybox image from the main daemon and load it into this Daemon instance.
func (*Daemon) StartWithError ¶
StartWithError starts the daemon and return once it is ready to receive requests. It returns an error in case it couldn't start.
func (*Daemon) StartWithLogFile ¶
StartWithLogFile will start the daemon and attach its streams to a given file.
func (*Daemon) Stop ¶
func (d *Daemon) Stop(t testingT)
Stop will send a SIGINT every second and wait for the daemon to stop. If it times out, a SIGKILL is sent. Stop will not delete the daemon directory. If a purged daemon is needed, instantiate a new one with NewDaemon. If an error occurs while starting the daemon, the test will fail.
func (*Daemon) StopWithError ¶
StopWithError will send a SIGINT every second and wait for the daemon to stop. If it timeouts, a SIGKILL is sent. Stop will not delete the daemon directory. If a purged daemon is needed, instantiate a new one with NewDaemon.
func (*Daemon) StorageDriver ¶
StorageDriver returns the configured storage driver of the daemon
type NodeConstructor ¶
NodeConstructor defines a swarm node constructor
type ServiceConstructor ¶
ServiceConstructor defines a swarm service constructor function
type SpecConstructor ¶
SpecConstructor defines a swarm spec constructor
type Swarm ¶
Swarm is a test daemon with helpers for participating in a swarm.
func (*Swarm) CheckControlAvailable ¶
func (d *Swarm) CheckControlAvailable(c *check.C) (interface{}, check.CommentInterface)
CheckControlAvailable returns the current swarm control available
func (*Swarm) CheckLeader ¶
func (d *Swarm) CheckLeader(c *check.C) (interface{}, check.CommentInterface)
CheckLeader returns whether there is a leader on the swarm or not
func (*Swarm) CheckLocalNodeState ¶
func (d *Swarm) CheckLocalNodeState(c *check.C) (interface{}, check.CommentInterface)
CheckLocalNodeState returns the current swarm node state
func (*Swarm) CheckNodeReadyCount ¶
func (d *Swarm) CheckNodeReadyCount(c *check.C) (interface{}, check.CommentInterface)
CheckNodeReadyCount returns the number of ready node on the swarm
func (*Swarm) CheckRunningTaskImages ¶
func (d *Swarm) CheckRunningTaskImages(c *check.C) (interface{}, check.CommentInterface)
CheckRunningTaskImages returns the number of different images attached to a running task
func (*Swarm) CheckServiceRunningTasks ¶
func (d *Swarm) CheckServiceRunningTasks(service string) func(*check.C) (interface{}, check.CommentInterface)
CheckServiceRunningTasks returns the number of running tasks for the specified service
func (*Swarm) CheckServiceTasks ¶
func (d *Swarm) CheckServiceTasks(service string) func(*check.C) (interface{}, check.CommentInterface)
CheckServiceTasks returns the number of tasks for the specified service
func (*Swarm) CheckServiceTasksInState ¶
func (d *Swarm) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*check.C) (interface{}, check.CommentInterface)
CheckServiceTasksInState returns the number of tasks with a matching state, and optional message substring.
func (*Swarm) CheckServiceUpdateState ¶
func (d *Swarm) CheckServiceUpdateState(service string) func(*check.C) (interface{}, check.CommentInterface)
CheckServiceUpdateState returns the current update state for the specified service
func (*Swarm) CmdRetryOutOfSequence ¶
CmdRetryOutOfSequence tries the specified command against the current daemon for 10 times
func (*Swarm) CreateSecret ¶
CreateSecret creates a secret given the specified spec
func (*Swarm) CreateService ¶
func (d *Swarm) CreateService(c *check.C, f ...ServiceConstructor) string
CreateService creates a swarm service given the specified service constructor
func (*Swarm) DeleteSecret ¶
DeleteSecret removes the swarm secret identified by the specified id
func (*Swarm) GetService ¶
GetService returns the swarm service corresponding to the specified id
func (*Swarm) GetServiceTasks ¶
GetServiceTasks returns the swarm tasks for the specified service
func (*Swarm) Init ¶
func (d *Swarm) Init(req swarm.InitRequest) error
Init initializes a new swarm cluster.
func (*Swarm) Join ¶
func (d *Swarm) Join(req swarm.JoinRequest) error
Join joins a daemon to an existing cluster.
func (*Swarm) JoinTokens ¶
func (d *Swarm) JoinTokens(c *check.C) swarm.JoinTokens
JoinTokens returns the current swarm join tokens
func (*Swarm) ListSecrets ¶
ListSecrets returns the list of the current swarm secrets
func (*Swarm) ListServices ¶
ListServices return the list of the current swarm services
func (*Swarm) RemoveNode ¶
RemoveNode removes the specified node
func (*Swarm) RemoveService ¶
RemoveService removes the specified service
func (*Swarm) RotateTokens ¶
RotateTokens update the swarm to rotate tokens
func (*Swarm) Unlock ¶
func (d *Swarm) Unlock(req swarm.UnlockRequest) error
Unlock tries to unlock a locked swarm
func (*Swarm) UpdateNode ¶
func (d *Swarm) UpdateNode(c *check.C, id string, f ...NodeConstructor)
UpdateNode updates a swarm node with the specified node constructor
func (*Swarm) UpdateService ¶
UpdateService updates a swarm service with the specified service constructor
func (*Swarm) UpdateSwarm ¶
func (d *Swarm) UpdateSwarm(c *check.C, f ...SpecConstructor)
UpdateSwarm updates the current swarm object with the specified spec constructors