daemon

package
v17.12.1-ce-rc2+incomp... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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. Deprecated 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. Deprecated: use cli.WaitCmd instead

Types

type Config

type Config struct {
	Experimental bool
}

Config holds docker daemon integration configuration

type ConfigConstructor

type ConfigConstructor func(*swarm.Config)

ConfigConstructor defines a swarm config constructor

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

func New(t testingT, dockerBinary string, dockerdBinary string, config Config) *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 (*Daemon) ActiveContainers

func (d *Daemon) ActiveContainers() (ids []string)

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

func (d *Daemon) CleanupExecRoot(c *check.C)

CleanupExecRoot cleans the daemon exec root (network namespaces, ...)

func (*Daemon) Cmd

func (d *Daemon) Cmd(args ...string) (string, error)

Cmd executes a docker CLI command against this daemon. Example: d.Cmd("version") will run docker -H unix://path/to/unix.sock version

func (*Daemon) Command

func (d *Daemon) Command(args ...string) icmd.Cmd

Command creates a docker CLI command against this daemon, to be executed later. Example: d.Command("version") creates a command to 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

func (d *Daemon) FindContainerIP(id string) (string, error)

FindContainerIP returns the ip of the specified container

func (*Daemon) GetIDByName

func (d *Daemon) GetIDByName(name string) (string, error)

GetIDByName returns the ID of an object (container, volume, …) given its name

func (*Daemon) ID

func (d *Daemon) ID() string

ID returns the generated id of the daemon

func (*Daemon) Info

func (d *Daemon) Info(t require.TestingT) types.Info

Info returns the info struct for this daemon

func (*Daemon) InspectField

func (d *Daemon) InspectField(name, filter string) (string, error)

InspectField returns the field filter by 'filter'

func (*Daemon) Interrupt

func (d *Daemon) Interrupt() error

Interrupt stops the daemon by sending it an Interrupt signal

func (*Daemon) Kill

func (d *Daemon) Kill() error

Kill will send a SIGKILL to the daemon

func (*Daemon) LoadBusybox

func (d *Daemon) LoadBusybox(t testingT)

LoadBusybox image into the daemon

func (*Daemon) LogFileName

func (d *Daemon) LogFileName() string

LogFileName returns the path the daemon's log file

func (*Daemon) NewClient

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

NewClient creates new client based on daemon's socket path

func (*Daemon) Pid

func (d *Daemon) Pid() int

Pid returns the pid of the daemon

func (*Daemon) PrependHostArg

func (d *Daemon) PrependHostArg(args []string) []string

PrependHostArg prepend the specified arguments by the daemon host flags

func (*Daemon) ReadLogFile

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

ReadLogFile returns the content of the daemon log file

func (*Daemon) ReloadConfig

func (d *Daemon) ReloadConfig() error

ReloadConfig asks the daemon to reload its configuration

func (*Daemon) Restart

func (d *Daemon) Restart(t testingT, 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) RestartWithError

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

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

func (*Daemon) RootDir

func (d *Daemon) RootDir() string

RootDir returns the root directory of the daemon.

func (*Daemon) Signal

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

Signal sends the specified signal to the daemon if running

func (*Daemon) Sock

func (d *Daemon) Sock() string

Sock returns the socket path of the daemon

func (*Daemon) SockRequest

func (d *Daemon) SockRequest(method, endpoint string, data interface{}) (int, []byte, error)

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. Deprecated: use request package instead

func (*Daemon) Start

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

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

func (*Daemon) StartWithBusybox

func (d *Daemon) StartWithBusybox(t testingT, 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

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

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

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

func (d *Daemon) StopWithError() 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

func (d *Daemon) StorageDriver() string

StorageDriver returns the configured storage driver of the daemon

func (*Daemon) WaitRun

func (d *Daemon) WaitRun(contID string) error

WaitRun waits for a container to be running for 10s

type NodeConstructor

type NodeConstructor func(*swarm.Node)

NodeConstructor defines a swarm node constructor

type SecretConstructor

type SecretConstructor func(*swarm.Secret)

SecretConstructor defines a swarm secret constructor

type ServiceConstructor

type ServiceConstructor func(*swarm.Service)

ServiceConstructor defines a swarm service constructor function

type SpecConstructor

type SpecConstructor func(*swarm.Spec)

SpecConstructor defines a swarm spec constructor

type Swarm

type Swarm struct {
	*Daemon
	swarm.Info
	Port       int
	ListenAddr string
}

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) CheckPluginImage

func (d *Swarm) CheckPluginImage(plugin string) func(c *check.C) (interface{}, check.CommentInterface)

CheckPluginImage returns the runtime state of the plugin

func (*Swarm) CheckPluginRunning

func (d *Swarm) CheckPluginRunning(plugin string) func(c *check.C) (interface{}, check.CommentInterface)

CheckPluginRunning returns the runtime state of the plugin

func (*Swarm) CheckRunningTaskImages

func (d *Swarm) CheckRunningTaskImages(c *check.C) (interface{}, check.CommentInterface)

CheckRunningTaskImages returns the times each image is running as a task.

func (*Swarm) CheckRunningTaskNetworks

func (d *Swarm) CheckRunningTaskNetworks(c *check.C) (interface{}, check.CommentInterface)

CheckRunningTaskNetworks returns the number of times each network is referenced from a 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) CheckServiceTasksInStateWithError

func (d *Swarm) CheckServiceTasksInStateWithError(service string, state swarm.TaskState, errorMessage string) func(*check.C) (interface{}, check.CommentInterface)

CheckServiceTasksInStateWithError 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

func (d *Swarm) CmdRetryOutOfSequence(args ...string) (string, error)

CmdRetryOutOfSequence tries the specified command against the current daemon for 10 times

func (*Swarm) CreateConfig

func (d *Swarm) CreateConfig(c *check.C, configSpec swarm.ConfigSpec) string

CreateConfig creates a config given the specified spec

func (*Swarm) CreateSecret

func (d *Swarm) CreateSecret(c *check.C, secretSpec swarm.SecretSpec) string

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) CreateServiceWithOptions

func (d *Swarm) CreateServiceWithOptions(c *check.C, opts types.ServiceCreateOptions, f ...ServiceConstructor) string

CreateServiceWithOptions creates a swarm service given the specified service constructors and auth config

func (*Swarm) DeleteConfig

func (d *Swarm) DeleteConfig(c *check.C, id string)

DeleteConfig removes the swarm config identified by the specified id

func (*Swarm) DeleteSecret

func (d *Swarm) DeleteSecret(c *check.C, id string)

DeleteSecret removes the swarm secret identified by the specified id

func (*Swarm) GetConfig

func (d *Swarm) GetConfig(c *check.C, id string) *swarm.Config

GetConfig returns a swarm config identified by the specified id

func (*Swarm) GetNode

func (d *Swarm) GetNode(c *check.C, id string) *swarm.Node

GetNode returns a swarm node identified by the specified id

func (*Swarm) GetSecret

func (d *Swarm) GetSecret(c *check.C, id string) *swarm.Secret

GetSecret returns a swarm secret identified by the specified id

func (*Swarm) GetService

func (d *Swarm) GetService(c *check.C, id string) *swarm.Service

GetService returns the swarm service corresponding to the specified id

func (*Swarm) GetServiceTasks

func (d *Swarm) GetServiceTasks(c *check.C, service string) []swarm.Task

GetServiceTasks returns the swarm tasks for the specified service

func (*Swarm) GetSwarm

func (d *Swarm) GetSwarm(c *check.C) swarm.Swarm

GetSwarm returns the current swarm object

func (*Swarm) GetTask

func (d *Swarm) GetTask(c *check.C, id string) swarm.Task

GetTask returns the swarm task identified by the specified id

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) Leave

func (d *Swarm) Leave(force bool) error

Leave forces daemon to leave current cluster.

func (*Swarm) ListConfigs

func (d *Swarm) ListConfigs(c *check.C) []swarm.Config

ListConfigs returns the list of the current swarm configs

func (*Swarm) ListNodes

func (d *Swarm) ListNodes(c *check.C) []swarm.Node

ListNodes returns the list of the current swarm nodes

func (*Swarm) ListSecrets

func (d *Swarm) ListSecrets(c *check.C) []swarm.Secret

ListSecrets returns the list of the current swarm secrets

func (*Swarm) ListServices

func (d *Swarm) ListServices(c *check.C) []swarm.Service

ListServices returns the list of the current swarm services

func (*Swarm) RemoveNode

func (d *Swarm) RemoveNode(c *check.C, id string, force bool)

RemoveNode removes the specified node

func (*Swarm) RemoveService

func (d *Swarm) RemoveService(c *check.C, id string)

RemoveService removes the specified service

func (*Swarm) RotateTokens

func (d *Swarm) RotateTokens(c *check.C)

RotateTokens update the swarm to rotate tokens

func (*Swarm) SwarmInfo

func (d *Swarm) SwarmInfo() (swarm.Info, error)

SwarmInfo returns the swarm information of the daemon

func (*Swarm) Unlock

func (d *Swarm) Unlock(req swarm.UnlockRequest) error

Unlock tries to unlock a locked swarm

func (*Swarm) UpdateConfig

func (d *Swarm) UpdateConfig(c *check.C, id string, f ...ConfigConstructor)

UpdateConfig updates the swarm config identified by the specified id Currently, only label update is supported.

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) UpdateSecret

func (d *Swarm) UpdateSecret(c *check.C, id string, f ...SecretConstructor)

UpdateSecret updates the swarm secret identified by the specified id Currently, only label update is supported.

func (*Swarm) UpdateService

func (d *Swarm) UpdateService(c *check.C, service *swarm.Service, f ...ServiceConstructor)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL