docker: github.com/docker/docker/testutil/daemon Index | Files

package daemon

import "github.com/docker/docker/testutil/daemon"

Package daemon launches dockerd for testing purposes.

Index

Package Files

config.go container.go daemon.go daemon_unix.go doc.go node.go ops.go plugin.go secret.go service.go swarm.go

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

func SignalDaemonDump Uses

func SignalDaemonDump(pid int)

SignalDaemonDump sends a signal to the daemon to write a dump file

type ConfigConstructor Uses

type ConfigConstructor func(*swarm.Config)

ConfigConstructor defines a swarm config constructor

type Daemon Uses

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
    OOMScoreAdjust  int
    // cached information
    CachedInfo types.Info
    // contains filtered or unexported fields
}

Daemon represents a Docker daemon for the testing framework

func New Uses

func New(t testing.TB, ops ...Option) *Daemon

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 Uses

func NewDaemon(workingDir string, ops ...Option) (*Daemon, error)

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 Uses

func (d *Daemon) ActiveContainers(t testing.TB) []string

ActiveContainers returns the list of ids of the currently running containers

func (*Daemon) CgroupNamespace Uses

func (d *Daemon) CgroupNamespace(t testing.TB) string

CgroupNamespace returns the cgroup namespace the daemon is running in

func (*Daemon) Cleanup Uses

func (d *Daemon) Cleanup(t testing.TB)

Cleanup cleans the daemon files : exec root (network namespaces, ...), swarmkit files

func (*Daemon) ContainersNamespace Uses

func (d *Daemon) ContainersNamespace() string

ContainersNamespace returns the containerd namespace used for containers.

func (*Daemon) CreateConfig Uses

func (d *Daemon) CreateConfig(t testing.TB, configSpec swarm.ConfigSpec) string

CreateConfig creates a config given the specified spec

func (*Daemon) CreateSecret Uses

func (d *Daemon) CreateSecret(t testing.TB, secretSpec swarm.SecretSpec) string

CreateSecret creates a secret given the specified spec

func (*Daemon) CreateService Uses

func (d *Daemon) CreateService(t testing.TB, f ...ServiceConstructor) string

CreateService creates a swarm service given the specified service constructor

func (*Daemon) DeleteConfig Uses

func (d *Daemon) DeleteConfig(t testing.TB, id string)

DeleteConfig removes the swarm config identified by the specified id

func (*Daemon) DeleteSecret Uses

func (d *Daemon) DeleteSecret(t testing.TB, id string)

DeleteSecret removes the swarm secret identified by the specified id

func (*Daemon) DumpStackAndQuit Uses

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 Uses

func (d *Daemon) FindContainerIP(t testing.TB, id string) string

FindContainerIP returns the ip of the specified container

func (*Daemon) GetConfig Uses

func (d *Daemon) GetConfig(t testing.TB, id string) *swarm.Config

GetConfig returns a swarm config identified by the specified id

func (*Daemon) GetNode Uses

func (d *Daemon) GetNode(t testing.TB, id string, errCheck ...func(error) bool) *swarm.Node

GetNode returns a swarm node identified by the specified id

func (*Daemon) GetSecret Uses

func (d *Daemon) GetSecret(t testing.TB, id string) *swarm.Secret

GetSecret returns a swarm secret identified by the specified id

func (*Daemon) GetService Uses

func (d *Daemon) GetService(t testing.TB, id string) *swarm.Service

GetService returns the swarm service corresponding to the specified id

func (*Daemon) GetServiceTasks Uses

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) GetSwarm Uses

func (d *Daemon) GetSwarm(t testing.TB) swarm.Swarm

GetSwarm returns the current swarm object

func (*Daemon) GetTask Uses

func (d *Daemon) GetTask(t testing.TB, id string) swarm.Task

GetTask returns the swarm task identified by the specified id

func (*Daemon) ID Uses

func (d *Daemon) ID() string

ID returns the generated id of the daemon

func (*Daemon) Info Uses

func (d *Daemon) Info(t testing.TB) types.Info

Info returns the info struct for this daemon

func (*Daemon) Interrupt Uses

func (d *Daemon) Interrupt() error

Interrupt stops the daemon by sending it an Interrupt signal

func (*Daemon) JoinTokens Uses

func (d *Daemon) JoinTokens(t testing.TB) swarm.JoinTokens

JoinTokens returns the current swarm join tokens

func (*Daemon) Kill Uses

func (d *Daemon) Kill() error

Kill will send a SIGKILL to the daemon

func (*Daemon) ListConfigs Uses

func (d *Daemon) ListConfigs(t testing.TB) []swarm.Config

ListConfigs returns the list of the current swarm configs

func (*Daemon) ListNodes Uses

func (d *Daemon) ListNodes(t testing.TB) []swarm.Node

ListNodes returns the list of the current swarm nodes

func (*Daemon) ListSecrets Uses

func (d *Daemon) ListSecrets(t testing.TB) []swarm.Secret

ListSecrets returns the list of the current swarm secrets

func (*Daemon) ListServices Uses

func (d *Daemon) ListServices(t testing.TB) []swarm.Service

ListServices returns the list of the current swarm services

func (*Daemon) LoadBusybox Uses

func (d *Daemon) LoadBusybox(t testing.TB)

LoadBusybox image into the daemon

func (*Daemon) LogFileName Uses

func (d *Daemon) LogFileName() string

LogFileName returns the path the daemon's log file

func (*Daemon) NewClient Uses

func (d *Daemon) NewClient(extraOpts ...client.Opt) (*client.Client, error)

NewClient creates new client based on daemon's socket path

func (*Daemon) NewClientT Uses

func (d *Daemon) NewClientT(t testing.TB, extraOpts ...client.Opt) *client.Client

NewClientT creates new client based on daemon's socket path

func (*Daemon) NodeID Uses

func (d *Daemon) NodeID() string

NodeID returns the swarm mode node ID

func (*Daemon) Pid Uses

func (d *Daemon) Pid() int

Pid returns the pid of the daemon

func (*Daemon) PluginIsNotPresent Uses

func (d *Daemon) PluginIsNotPresent(t testing.TB, name string) func(poll.LogT) poll.Result

PluginIsNotPresent provides a poller to check if the specified plugin is not present

func (*Daemon) PluginIsNotRunning Uses

func (d *Daemon) PluginIsNotRunning(t testing.TB, name string) func(poll.LogT) poll.Result

PluginIsNotRunning provides a poller to check if the specified plugin is not running

func (*Daemon) PluginIsRunning Uses

func (d *Daemon) PluginIsRunning(t testing.TB, name string) func(poll.LogT) poll.Result

PluginIsRunning provides a poller to check if the specified plugin is running

func (*Daemon) PluginReferenceIs Uses

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 Uses

func (d *Daemon) ReadLogFile() ([]byte, error)

ReadLogFile returns the content of the daemon log file

func (*Daemon) ReloadConfig Uses

func (d *Daemon) ReloadConfig() error

ReloadConfig asks the daemon to reload its configuration

func (*Daemon) RemoveNode Uses

func (d *Daemon) RemoveNode(t testing.TB, id string, force bool)

RemoveNode removes the specified node

func (*Daemon) RemoveService Uses

func (d *Daemon) RemoveService(t testing.TB, id string)

RemoveService removes the specified service

func (*Daemon) Restart Uses

func (d *Daemon) Restart(t testing.TB, args ...string)

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 Uses

func (d *Daemon) RestartNode(t testing.TB)

RestartNode restarts a daemon to be used as a swarm node

func (*Daemon) RestartWithError Uses

func (d *Daemon) RestartWithError(arg ...string) error

RestartWithError will restart the daemon by first stopping it and then starting it.

func (*Daemon) RootDir Uses

func (d *Daemon) RootDir() string

RootDir returns the root directory of the daemon.

func (*Daemon) RotateTokens Uses

func (d *Daemon) RotateTokens(t testing.TB)

RotateTokens update the swarm to rotate tokens

func (*Daemon) Signal Uses

func (d *Daemon) Signal(signal os.Signal) error

Signal sends the specified signal to the daemon if running

func (*Daemon) Sock Uses

func (d *Daemon) Sock() string

Sock returns the socket path of the daemon

func (*Daemon) Start Uses

func (d *Daemon) Start(t testing.TB, args ...string)

Start starts the daemon and return once it is ready to receive requests.

func (*Daemon) StartAndSwarmInit Uses

func (d *Daemon) StartAndSwarmInit(t testing.TB)

StartAndSwarmInit starts the daemon (with busybox) and init the swarm

func (*Daemon) StartAndSwarmJoin Uses

func (d *Daemon) StartAndSwarmJoin(t testing.TB, leader *Daemon, manager bool)

StartAndSwarmJoin starts the daemon (with busybox) and join the specified swarm as worker or manager

func (*Daemon) StartNode Uses

func (d *Daemon) StartNode(t testing.TB)

StartNode (re)starts the daemon

func (*Daemon) StartNodeWithBusybox Uses

func (d *Daemon) StartNodeWithBusybox(t testing.TB)

StartNodeWithBusybox starts daemon to be used as a swarm node, and loads the busybox image

func (*Daemon) StartWithBusybox Uses

func (d *Daemon) StartWithBusybox(t testing.TB, arg ...string)

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 Uses

func (d *Daemon) StartWithError(args ...string) error

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 Uses

func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error

StartWithLogFile will start the daemon and attach its streams to a given file.

func (*Daemon) Stop Uses

func (d *Daemon) Stop(t testing.TB)

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 Uses

func (d *Daemon) StopWithError() (err error)

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 Uses

func (d *Daemon) StorageDriver() string

StorageDriver returns the configured storage driver of the daemon

func (*Daemon) SwarmInfo Uses

func (d *Daemon) SwarmInfo(t testing.TB) swarm.Info

SwarmInfo returns the swarm information of the daemon

func (*Daemon) SwarmInit Uses

func (d *Daemon) SwarmInit(t testing.TB, req swarm.InitRequest)

SwarmInit initializes a new swarm cluster.

func (*Daemon) SwarmJoin Uses

func (d *Daemon) SwarmJoin(t testing.TB, req swarm.JoinRequest)

SwarmJoin joins a daemon to an existing cluster.

func (*Daemon) SwarmLeave Uses

func (d *Daemon) SwarmLeave(t testing.TB, force bool) error

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 Uses

func (d *Daemon) SwarmListenAddr() string

SwarmListenAddr returns the listen-addr used for the daemon

func (*Daemon) SwarmUnlock Uses

func (d *Daemon) SwarmUnlock(t testing.TB, req swarm.UnlockRequest) error

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 Uses

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 Uses

func (d *Daemon) UpdateNode(t testing.TB, id string, f ...NodeConstructor)

UpdateNode updates a swarm node with the specified node constructor

func (*Daemon) UpdateSecret Uses

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 Uses

func (d *Daemon) UpdateService(t testing.TB, service *swarm.Service, f ...ServiceConstructor)

UpdateService updates a swarm service with the specified service constructor

func (*Daemon) UpdateSwarm Uses

func (d *Daemon) UpdateSwarm(t testing.TB, f ...SpecConstructor)

UpdateSwarm updates the current swarm object with the specified spec constructors

type LogT Uses

type LogT interface {
    Logf(string, ...interface{})
}

LogT is the subset of the testing.TB interface used by the daemon.

type NodeConstructor Uses

type NodeConstructor func(*swarm.Node)

NodeConstructor defines a swarm node constructor

type Option Uses

type Option func(*Daemon)

Option is used to configure a daemon.

func WithContainerdSocket Uses

func WithContainerdSocket(socket string) Option

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 Uses

func WithDefaultCgroupNamespaceMode(mode string) Option

WithDefaultCgroupNamespaceMode sets the default cgroup namespace mode for the daemon

func WithDockerdBinary Uses

func WithDockerdBinary(dockerdBinary string) Option

WithDockerdBinary sets the dockerd binary to the specified one

func WithEnvironment Uses

func WithEnvironment(e environment.Execution) Option

WithEnvironment sets options from testutil/environment.Execution struct

func WithExperimental Uses

func WithExperimental() Option

WithExperimental sets the daemon in experimental mode

func WithInit Uses

func WithInit() Option

WithInit sets the daemon init

func WithOOMScoreAdjust Uses

func WithOOMScoreAdjust(score int) Option

WithOOMScoreAdjust sets OOM score for the daemon

func WithRootlessUser Uses

func WithRootlessUser(username string) Option

WithRootlessUser sets the daemon to be rootless

func WithStorageDriver Uses

func WithStorageDriver(driver string) Option

WithStorageDriver sets store driver option

func WithSwarmDataPathPort Uses

func WithSwarmDataPathPort(datapathPort uint32) Option

WithSwarmDataPathPort sets the swarm datapath port to use for swarm mode

func WithSwarmDefaultAddrPool Uses

func WithSwarmDefaultAddrPool(defaultAddrPool []string) Option

WithSwarmDefaultAddrPool sets the swarm default address pool to use for swarm mode

func WithSwarmDefaultAddrPoolSubnetSize Uses

func WithSwarmDefaultAddrPoolSubnetSize(subnetSize uint32) Option

WithSwarmDefaultAddrPoolSubnetSize sets the subnet length mask of swarm default address pool to use for swarm mode

func WithSwarmListenAddr Uses

func WithSwarmListenAddr(listenAddr string) Option

WithSwarmListenAddr sets the swarm listen addr to use for swarm mode

func WithSwarmPort Uses

func WithSwarmPort(port int) Option

WithSwarmPort sets the swarm port to use for swarm mode

func WithTestLogger Uses

func WithTestLogger(t LogT) Option

WithTestLogger causes the daemon to log certain actions to the provided test.

type SecretConstructor Uses

type SecretConstructor func(*swarm.Secret)

SecretConstructor defines a swarm secret constructor

type ServiceConstructor Uses

type ServiceConstructor func(*swarm.Service)

ServiceConstructor defines a swarm service constructor function

type SpecConstructor Uses

type SpecConstructor func(*swarm.Spec)

SpecConstructor defines a swarm spec constructor

Package daemon imports 31 packages (graph) and is imported by 5 packages. Updated 2020-12-24. Refresh now. Tools for package owners.