util

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2016 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExecDriverDir = "/var/lib/docker/execdriver"
)

Variables

View Source
var Cluster string
View Source
var ECS *ecs.ECS

Functions

func DeleteCluster added in v1.9.0

func DeleteCluster(t *testing.T, clusterName string)

func GetInstanceIAMRole added in v1.11.1

func GetInstanceIAMRole() (*iam.Role, error)

GetInstanceIAMRole gets the iam roles attached to the instance profile

func GetInstanceMetadata added in v1.11.1

func GetInstanceMetadata(path string) (string, error)

GetInstanceProfileName gets the instance profile name

func GetTaskDefinition

func GetTaskDefinition(name string) (string, error)

GetTaskDefinition is a helper that provies the family:revision for the named task definition where the name matches the folder in which the task definition is present. In order to avoid re-registering a task definition when it has already been regestered in the past, this registers a task definition of the pattern 'family-md5sum' with md5sum being the input task definition json's md5. This special family name is checked for existence before a new one is registered and it is assumed that if it exists, the task definition currently represented by the file was registered as such already.

func GetTaskDefinitionWithOverrides added in v1.11.1

func GetTaskDefinitionWithOverrides(name string, overrides map[string]string) (string, error)

func RequireDockerVersion added in v1.7.0

func RequireDockerVersion(t *testing.T, selector string)

func RoundTimeUp added in v1.9.0

func RoundTimeUp(realTime time.Time, duration time.Duration) time.Time

RoundTimeUp rounds the time to the next second/minute/hours depending on the duration

func SearchStrInDir added in v1.11.1

func SearchStrInDir(dir, filePrefix, content string) error

SearchStrInDir searches the files in direcotry for specific content

func VerifyMetrics added in v1.9.0

func VerifyMetrics(cwclient *cloudwatch.CloudWatch, params *cloudwatch.GetMetricStatisticsInput, idleCluster bool) error

VerifyMetrics whether the response is as expected the expected value can be 0 or positive

Types

type AgentOptions added in v1.5.0

type AgentOptions struct {
	ExtraEnvironment map[string]string
	ContainerLinks   []string
	PortBindings     map[docker.Port]map[string]string
}

type TestAgent

type TestAgent struct {
	Image                string
	DockerID             string
	IntrospectionURL     string
	Version              string
	ContainerInstanceArn string
	Cluster              string
	TestDir              string
	Logdir               string
	Options              *AgentOptions

	DockerClient *docker.Client
	// contains filtered or unexported fields
}

func RunAgent

func RunAgent(t *testing.T, options *AgentOptions) *TestAgent

RunAgent launches the agent and returns an object which may be used to reference it. It will wait until the agent is correctly registered before returning. 'version' may be a docker image (e.g. amazon/amazon-ecs-agent:v1.0.0) with tag that may be used to run the agent. It defaults to 'amazon/amazon-ecs-agent:make', the version created locally by running 'make'

func (*TestAgent) Cleanup

func (agent *TestAgent) Cleanup()

func (*TestAgent) GetContainerNetworkMode added in v1.12.0

func (agent *TestAgent) GetContainerNetworkMode(containerId string) ([]string, error)

GetContainerNetworkMode gets the container network mode, given container id

func (*TestAgent) RequireVersion added in v1.5.0

func (agent *TestAgent) RequireVersion(version string)

func (*TestAgent) ResolveTaskDockerID

func (agent *TestAgent) ResolveTaskDockerID(task *TestTask, containerName string) (string, error)

ResolveTaskDockerID determines the Docker ID for a container within a given task that has been run by the Agent.

func (*TestAgent) StartAgent

func (agent *TestAgent) StartAgent() error

func (*TestAgent) StartMultipleTasks

func (agent *TestAgent) StartMultipleTasks(t *testing.T, taskDefinition string, num int) ([]*TestTask, error)

func (*TestAgent) StartTask

func (agent *TestAgent) StartTask(t *testing.T, task string) (*TestTask, error)

func (*TestAgent) StartTaskWithOverrides

func (agent *TestAgent) StartTaskWithOverrides(t *testing.T, task string, overrides []*ecs.ContainerOverride) (*TestTask, error)

func (*TestAgent) StartTaskWithTaskDefinitionOverrides added in v1.11.1

func (agent *TestAgent) StartTaskWithTaskDefinitionOverrides(t *testing.T, task string, overrides map[string]string) (*TestTask, error)

func (*TestAgent) StopAgent

func (agent *TestAgent) StopAgent() error

func (*TestAgent) WaitRunningViaIntrospection added in v1.8.2

func (agent *TestAgent) WaitRunningViaIntrospection(task *TestTask) (bool, error)

func (*TestAgent) WaitStoppedViaIntrospection added in v1.8.2

func (agent *TestAgent) WaitStoppedViaIntrospection(task *TestTask) (bool, error)

type TestTask

type TestTask struct {
	*ecs.Task
}

func (*TestTask) ContainerExitcode

func (task *TestTask) ContainerExitcode(name string) (int, bool)

func (*TestTask) ExpectErrorType

func (task *TestTask) ExpectErrorType(containerName, errType string, timeout time.Duration) error

func (*TestTask) Redescribe

func (task *TestTask) Redescribe()

func (*TestTask) Stop

func (task *TestTask) Stop() error

func (*TestTask) WaitRunning

func (task *TestTask) WaitRunning(timeout time.Duration) error

func (*TestTask) WaitStopped

func (task *TestTask) WaitStopped(timeout time.Duration) error

type Version added in v1.5.0

type Version string

func (Version) Matches added in v1.5.0

func (lhs Version) Matches(selector string) (bool, error)

Matches returns whether or not a version matches a given selector. The selector can be any of the following:

* x.y.z -- Matches a version exactly the same as the selector version * >=x.y.z -- Matches a version greater than or equal to the selector version * >x.y.z -- Matches a version greater than the selector version * <=x.y.z -- Matches a version less than or equal to the selector version * <x.y.z -- Matches a version less than the selector version * x.y.z,a.b.c -- Matches if the version matches either of the two selector versions

Jump to

Keyboard shortcuts

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