daemon

package
v0.1.3-0...-f63d1a6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: Apache-2.0 Imports: 28 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. 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

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 $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 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) Command

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

Command will create a docker CLI command against this Daeomn.

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

func (d *Daemon) GetBaseDeviceSize(c *check.C) int64

GetBaseDeviceSize returns the base device size of the daemon

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) 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() error

LoadBusybox will load the stored busybox into a newly started daemon

func (*Daemon) LogFileName

func (d *Daemon) LogFileName() string

LogFileName returns the path the daemon's log file

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.

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

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

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

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

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

DeleteSecret removes the swarm secret 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 return 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) 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 return 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) 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

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