Documentation ¶
Overview ¶
Package daemon launches dockerd for testing purposes.
Index ¶
- Constants
- Variables
- func SignalDaemonDump(pid int)
- type ConfigConstructor
- type Daemon
- func (d *Daemon) ActiveContainers(t testing.TB) []string
- func (d *Daemon) CgroupNamespace(t testing.TB) string
- func (d *Daemon) Cleanup(t testing.TB)
- func (d *Daemon) ContainersNamespace() string
- func (d *Daemon) CreateConfig(t testing.TB, configSpec swarm.ConfigSpec) string
- func (d *Daemon) CreateSecret(t testing.TB, secretSpec swarm.SecretSpec) string
- func (d *Daemon) CreateService(t testing.TB, f ...ServiceConstructor) string
- func (d *Daemon) DeleteConfig(t testing.TB, id string)
- func (d *Daemon) DeleteSecret(t testing.TB, id string)
- func (d *Daemon) DumpStackAndQuit()
- func (d *Daemon) FindContainerIP(t testing.TB, id string) string
- func (d *Daemon) GetConfig(t testing.TB, id string) *swarm.Config
- func (d *Daemon) GetNode(t testing.TB, id string, errCheck ...func(error) bool) *swarm.Node
- func (d *Daemon) GetSecret(t testing.TB, id string) *swarm.Secret
- func (d *Daemon) GetService(t testing.TB, id string) *swarm.Service
- func (d *Daemon) GetServiceTasks(t testing.TB, service string, additionalFilters ...filters.KeyValuePair) []swarm.Task
- func (d *Daemon) GetSwarm(t testing.TB) swarm.Swarm
- func (d *Daemon) GetTask(t testing.TB, id string) swarm.Task
- func (d *Daemon) ID() string
- func (d *Daemon) Info(t testing.TB) types.Info
- func (d *Daemon) Interrupt() error
- func (d *Daemon) JoinTokens(t testing.TB) swarm.JoinTokens
- func (d *Daemon) Kill() error
- func (d *Daemon) ListConfigs(t testing.TB) []swarm.Config
- func (d *Daemon) ListNodes(t testing.TB) []swarm.Node
- func (d *Daemon) ListSecrets(t testing.TB) []swarm.Secret
- func (d *Daemon) ListServices(t testing.TB) []swarm.Service
- func (d *Daemon) LoadBusybox(t testing.TB)
- func (d *Daemon) LogFileName() string
- func (d *Daemon) NewClient(extraOpts ...client.Opt) (*client.Client, error)
- func (d *Daemon) NewClientT(t testing.TB, extraOpts ...client.Opt) *client.Client
- func (d *Daemon) NodeID() string
- func (d *Daemon) Pid() int
- func (d *Daemon) PluginIsNotPresent(t testing.TB, name string) func(poll.LogT) poll.Result
- func (d *Daemon) PluginIsNotRunning(t testing.TB, name string) func(poll.LogT) poll.Result
- func (d *Daemon) PluginIsRunning(t testing.TB, name string) func(poll.LogT) poll.Result
- func (d *Daemon) PluginReferenceIs(t testing.TB, name, expectedRef string) func(poll.LogT) poll.Result
- func (d *Daemon) ReadLogFile() ([]byte, error)
- func (d *Daemon) ReloadConfig() error
- func (d *Daemon) RemoveNode(t testing.TB, id string, force bool)
- func (d *Daemon) RemoveService(t testing.TB, id string)
- func (d *Daemon) Restart(t testing.TB, args ...string)
- func (d *Daemon) RestartNode(t testing.TB)
- func (d *Daemon) RestartWithError(arg ...string) error
- func (d *Daemon) RootDir() string
- func (d *Daemon) RotateTokens(t testing.TB)
- func (d *Daemon) Signal(signal os.Signal) error
- func (d *Daemon) Sock() string
- func (d *Daemon) Start(t testing.TB, args ...string)
- func (d *Daemon) StartAndSwarmInit(t testing.TB)
- func (d *Daemon) StartAndSwarmJoin(t testing.TB, leader *Daemon, manager bool)
- func (d *Daemon) StartNode(t testing.TB)
- func (d *Daemon) StartNodeWithBusybox(t testing.TB)
- func (d *Daemon) StartWithBusybox(t testing.TB, arg ...string)
- func (d *Daemon) StartWithError(args ...string) error
- func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error
- func (d *Daemon) Stop(t testing.TB)
- func (d *Daemon) StopWithError() (err error)
- func (d *Daemon) StorageDriver() string
- func (d *Daemon) SwarmInfo(t testing.TB) swarm.Info
- func (d *Daemon) SwarmInit(t testing.TB, req swarm.InitRequest)
- func (d *Daemon) SwarmJoin(t testing.TB, req swarm.JoinRequest)
- func (d *Daemon) SwarmLeave(t testing.TB, force bool) error
- func (d *Daemon) SwarmListenAddr() string
- func (d *Daemon) SwarmUnlock(t testing.TB, req swarm.UnlockRequest) error
- func (d *Daemon) UpdateConfig(t testing.TB, id string, f ...ConfigConstructor)
- func (d *Daemon) UpdateNode(t testing.TB, id string, f ...NodeConstructor)
- func (d *Daemon) UpdateSecret(t testing.TB, id string, f ...SecretConstructor)
- func (d *Daemon) UpdateService(t testing.TB, service *swarm.Service, f ...ServiceConstructor)
- func (d *Daemon) UpdateSwarm(t testing.TB, f ...SpecConstructor)
- type LogT
- type NodeConstructor
- type Option
- func WithContainerdSocket(socket string) Option
- func WithDefaultCgroupNamespaceMode(mode string) Option
- func WithDockerdBinary(dockerdBinary string) Option
- func WithEnvironment(e environment.Execution) Option
- func WithExperimental() Option
- func WithInit() Option
- func WithStorageDriver(driver string) Option
- func WithSwarmDataPathPort(datapathPort uint32) Option
- func WithSwarmDefaultAddrPool(defaultAddrPool []string) Option
- func WithSwarmDefaultAddrPoolSubnetSize(subnetSize uint32) Option
- func WithSwarmListenAddr(listenAddr string) Option
- func WithSwarmPort(port int) Option
- func WithTestLogger(t LogT) Option
- type SecretConstructor
- type ServiceConstructor
- type SpecConstructor
Constants ¶
const (
// DefaultSwarmPort is the default port use for swarm in the tests
DefaultSwarmPort = 2477
)
Variables ¶
var SockRoot = filepath.Join(os.TempDir(), "docker-integration")
SockRoot holds the path of the default docker integration daemon socket
Functions ¶
func SignalDaemonDump ¶
func SignalDaemonDump(pid int)
SignalDaemonDump sends a signal to the daemon to write a dump file
Types ¶
type ConfigConstructor ¶
ConfigConstructor defines a swarm config constructor
type Daemon ¶
type Daemon struct { Root string Folder string Wait chan error UseDefaultHost bool UseDefaultTLSHost bool SwarmPort int // FIXME(vdemeester) should probably not be exported DefaultAddrPool []string SubnetSize uint32 DataPathPort uint32 // cached information CachedInfo types.Info // 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 $DOCKER_INTEGRATION_DAEMON_DEST or $DEST. The daemon will not automatically start.
func NewDaemon ¶
NewDaemon returns a Daemon instance to be used for testing. The daemon will not automatically start. The daemon will modify and create files under workingDir.
func (*Daemon) ActiveContainers ¶
ActiveContainers returns the list of ids of the currently running containers
func (*Daemon) CgroupNamespace ¶
CgroupNamespace returns the cgroup namespace the daemon is running in
func (*Daemon) Cleanup ¶
Cleanup cleans the daemon files : exec root (network namespaces, ...), swarmkit files
func (*Daemon) ContainersNamespace ¶
ContainersNamespace returns the containerd namespace used for containers.
func (*Daemon) CreateConfig ¶
CreateConfig creates a config given the specified spec
func (*Daemon) CreateSecret ¶
CreateSecret creates a secret given the specified spec
func (*Daemon) CreateService ¶
func (d *Daemon) CreateService(t testing.TB, f ...ServiceConstructor) string
CreateService creates a swarm service given the specified service constructor
func (*Daemon) DeleteConfig ¶
DeleteConfig removes the swarm config identified by the specified id
func (*Daemon) DeleteSecret ¶
DeleteSecret removes the swarm secret identified by the specified id
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) GetService ¶
GetService returns the swarm service corresponding to the specified id
func (*Daemon) GetServiceTasks ¶
func (d *Daemon) GetServiceTasks(t testing.TB, service string, additionalFilters ...filters.KeyValuePair) []swarm.Task
GetServiceTasks returns the swarm tasks for the specified service
func (*Daemon) JoinTokens ¶
func (d *Daemon) JoinTokens(t testing.TB) swarm.JoinTokens
JoinTokens returns the current swarm join tokens
func (*Daemon) ListConfigs ¶
ListConfigs returns the list of the current swarm configs
func (*Daemon) ListSecrets ¶
ListSecrets returns the list of the current swarm secrets
func (*Daemon) ListServices ¶
ListServices returns the list of the current swarm services
func (*Daemon) LoadBusybox ¶
LoadBusybox image into the daemon
func (*Daemon) LogFileName ¶
LogFileName returns the path the daemon's log file
func (*Daemon) NewClientT ¶
NewClientT creates new client based on daemon's socket path
func (*Daemon) PluginIsNotPresent ¶
PluginIsNotPresent provides a poller to check if the specified plugin is not present
func (*Daemon) PluginIsNotRunning ¶
PluginIsNotRunning provides a poller to check if the specified plugin is not running
func (*Daemon) PluginIsRunning ¶
PluginIsRunning provides a poller to check if the specified plugin is running
func (*Daemon) PluginReferenceIs ¶
func (d *Daemon) PluginReferenceIs(t testing.TB, name, expectedRef string) func(poll.LogT) poll.Result
PluginReferenceIs provides a poller to check if the specified plugin has the specified reference
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) RemoveNode ¶
RemoveNode removes the specified node
func (*Daemon) RemoveService ¶
RemoveService removes the specified service
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) RestartNode ¶
RestartNode restarts a daemon to be used as a swarm node
func (*Daemon) RestartWithError ¶
RestartWithError will restart the daemon by first stopping it and then starting it.
func (*Daemon) RotateTokens ¶
RotateTokens update the swarm to rotate tokens
func (*Daemon) StartAndSwarmInit ¶
StartAndSwarmInit starts the daemon (with busybox) and init the swarm
func (*Daemon) StartAndSwarmJoin ¶
StartAndSwarmJoin starts the daemon (with busybox) and join the specified swarm as worker or manager
func (*Daemon) StartNodeWithBusybox ¶
StartNodeWithBusybox starts daemon to be used as a swarm node, and loads the busybox image
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 ¶
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
func (*Daemon) SwarmInit ¶
func (d *Daemon) SwarmInit(t testing.TB, req swarm.InitRequest)
SwarmInit initializes a new swarm cluster.
func (*Daemon) SwarmJoin ¶
func (d *Daemon) SwarmJoin(t testing.TB, req swarm.JoinRequest)
SwarmJoin joins a daemon to an existing cluster.
func (*Daemon) SwarmLeave ¶
SwarmLeave forces daemon to leave current cluster.
The passed in testing.TB is only used to validate that the client was successfully created Some tests rely on error checking the result of the actual unlock, so allow the error to be returned.
func (*Daemon) SwarmListenAddr ¶
SwarmListenAddr returns the listen-addr used for the daemon
func (*Daemon) SwarmUnlock ¶
SwarmUnlock tries to unlock a locked swarm
The passed in testing.TB is only used to validate that the client was successfully created Some tests rely on error checking the result of the actual unlock, so allow the error to be returned.
func (*Daemon) UpdateConfig ¶
func (d *Daemon) UpdateConfig(t testing.TB, id string, f ...ConfigConstructor)
UpdateConfig updates the swarm config identified by the specified id Currently, only label update is supported.
func (*Daemon) UpdateNode ¶
func (d *Daemon) UpdateNode(t testing.TB, id string, f ...NodeConstructor)
UpdateNode updates a swarm node with the specified node constructor
func (*Daemon) UpdateSecret ¶
func (d *Daemon) UpdateSecret(t testing.TB, id string, f ...SecretConstructor)
UpdateSecret updates the swarm secret identified by the specified id Currently, only label update is supported.
func (*Daemon) UpdateService ¶
UpdateService updates a swarm service with the specified service constructor
func (*Daemon) UpdateSwarm ¶
func (d *Daemon) UpdateSwarm(t testing.TB, f ...SpecConstructor)
UpdateSwarm updates the current swarm object with the specified spec constructors
type LogT ¶
type LogT interface {
Logf(string, ...interface{})
}
LogT is the subset of the testing.TB interface used by the daemon.
type NodeConstructor ¶
NodeConstructor defines a swarm node constructor
type Option ¶
type Option func(*Daemon)
Option is used to configure a daemon.
func WithContainerdSocket ¶
WithContainerdSocket sets the --containerd option on the daemon. Use an empty string to remove the option.
If unset the --containerd option will be used with a default value.
func WithDefaultCgroupNamespaceMode ¶
WithDefaultCgroupNamespaceMode sets the default cgroup namespace mode for the daemon
func WithDockerdBinary ¶
WithDockerdBinary sets the dockerd binary to the specified one
func WithEnvironment ¶
func WithEnvironment(e environment.Execution) Option
WithEnvironment sets options from testutil/environment.Execution struct
func WithExperimental ¶
func WithExperimental() Option
WithExperimental sets the daemon in experimental mode
func WithStorageDriver ¶
WithStorageDriver sets store driver option
func WithSwarmDataPathPort ¶
WithSwarmDataPathPort sets the swarm datapath port to use for swarm mode
func WithSwarmDefaultAddrPool ¶
WithSwarmDefaultAddrPool sets the swarm default address pool to use for swarm mode
func WithSwarmDefaultAddrPoolSubnetSize ¶
WithSwarmDefaultAddrPoolSubnetSize sets the subnet length mask of swarm default address pool to use for swarm mode
func WithSwarmListenAddr ¶
WithSwarmListenAddr sets the swarm listen addr to use for swarm mode
func WithSwarmPort ¶
WithSwarmPort sets the swarm port to use for swarm mode
func WithTestLogger ¶
WithTestLogger causes the daemon to log certain actions to the provided test.
type SecretConstructor ¶
SecretConstructor defines a swarm secret constructor
type ServiceConstructor ¶
ServiceConstructor defines a swarm service constructor function
type SpecConstructor ¶
SpecConstructor defines a swarm spec constructor