e2e

package
v2.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DockerExecutableName is the OS dependent Docker CLI binary name
	DockerExecutableName = "docker"

	// DockerComposeExecutableName is the OS dependent Docker CLI binary name
	DockerComposeExecutableName = "docker-" + compose.PluginName

	// DockerScanExecutableName is the OS dependent Docker Scan plugin binary name
	DockerScanExecutableName = "docker-scan"

	// DockerBuildxExecutableName is the Os dependent Buildx plugin binary name
	DockerBuildxExecutableName = "docker-buildx"

	// WindowsExecutableSuffix is the Windows executable suffix
	WindowsExecutableSuffix = ".exe"
)

Functions

func ComposeStandalonePath added in v2.6.1

func ComposeStandalonePath(t testing.TB) string

ComposeStandalonePath returns the path to the locally-built Compose standalone binary from the repo.

This function will fail the test immediately if invoked when not running in standalone test mode.

func CopyFile

func CopyFile(t testing.TB, sourceFile string, destinationFile string)

CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755

func HTTPGetWithRetry

func HTTPGetWithRetry(
	t testing.TB,
	endpoint string,
	expectedStatus int,
	retryDelay time.Duration,
	timeout time.Duration,
) string

HTTPGetWithRetry performs an HTTP GET on an `endpoint`, using retryDelay also as a request timeout. In the case of an error or the response status is not the expected one, it retries the same request, returning the response body as a string (empty if we could not reach it)

func IsHealthy added in v2.14.1

func IsHealthy(service string) func(res *icmd.Result) bool

func Lines

func Lines(output string) []string

Lines split output into lines

func RequireServiceState added in v2.10.0

func RequireServiceState(t testing.TB, cli *CLI, service string, state string)

RequireServiceState ensures that the container is in the expected state (running or exited).

func StdoutContains

func StdoutContains(expected string) func(*icmd.Result) bool

StdoutContains returns a predicate on command result expecting a string in stdout

Types

type CLI added in v2.6.1

type CLI struct {
	// ConfigDir for Docker configuration (set as DOCKER_CONFIG)
	ConfigDir string

	// HomeDir for tools that look for user files (set as HOME)
	HomeDir string
	// contains filtered or unexported fields
}

CLI is used to wrap the CLI for end to end testing

func NewCLI added in v2.6.1

func NewCLI(t testing.TB, opts ...CLIOption) *CLI

NewCLI creates a CLI instance for running E2E tests.

func NewParallelCLI added in v2.6.1

func NewParallelCLI(t *testing.T, opts ...CLIOption) *CLI

NewParallelCLI marks the parent test as parallel and returns a CLI instance suitable for usage across child tests.

func (*CLI) BaseEnvironment added in v2.6.1

func (c *CLI) BaseEnvironment() []string

BaseEnvironment provides the minimal environment variables used across all Docker / Compose commands.

func (*CLI) MetricsSocket added in v2.6.1

func (c *CLI) MetricsSocket() string

MetricsSocket get the path where test metrics will be sent

func (*CLI) NewCmd added in v2.6.1

func (c *CLI) NewCmd(command string, args ...string) icmd.Cmd

NewCmd creates a cmd object configured with the test environment set

func (*CLI) NewCmdWithEnv added in v2.6.1

func (c *CLI) NewCmdWithEnv(envvars []string, command string, args ...string) icmd.Cmd

NewCmdWithEnv creates a cmd object configured with the test environment set with additional env vars

func (*CLI) NewDockerCmd added in v2.6.1

func (c *CLI) NewDockerCmd(t testing.TB, args ...string) icmd.Cmd

NewDockerCmd creates a docker cmd without running it

func (*CLI) NewDockerComposeCmd added in v2.6.1

func (c *CLI) NewDockerComposeCmd(t testing.TB, args ...string) icmd.Cmd

NewDockerComposeCmd creates a command object for Compose, either in plugin or standalone mode (based on build tags).

func (*CLI) RunCmd added in v2.6.1

func (c *CLI) RunCmd(t testing.TB, args ...string) *icmd.Result

RunCmd runs a command, expects no error and returns a result

func (*CLI) RunCmdInDir added in v2.6.1

func (c *CLI) RunCmdInDir(t testing.TB, dir string, args ...string) *icmd.Result

RunCmdInDir runs a command in a given dir, expects no error and returns a result

func (*CLI) RunDockerCmd added in v2.6.1

func (c *CLI) RunDockerCmd(t testing.TB, args ...string) *icmd.Result

RunDockerCmd runs a docker command, expects no error and returns a result

func (*CLI) RunDockerComposeCmd added in v2.6.1

func (c *CLI) RunDockerComposeCmd(t testing.TB, args ...string) *icmd.Result

RunDockerComposeCmd runs a docker compose command, expects no error and returns a result

func (*CLI) RunDockerComposeCmdNoCheck added in v2.6.1

func (c *CLI) RunDockerComposeCmdNoCheck(t testing.TB, args ...string) *icmd.Result

RunDockerComposeCmdNoCheck runs a docker compose command, don't presume of any expectation and returns a result

func (*CLI) RunDockerOrExitError added in v2.6.1

func (c *CLI) RunDockerOrExitError(t testing.TB, args ...string) *icmd.Result

RunDockerOrExitError runs a docker command and returns a result

func (*CLI) WaitForCmdResult added in v2.6.1

func (c *CLI) WaitForCmdResult(
	t testing.TB,
	command icmd.Cmd,
	predicate func(*icmd.Result) bool,
	timeout time.Duration,
	delay time.Duration,
)

WaitForCmdResult try to execute a cmd until resulting output matches given predicate

func (*CLI) WaitForCondition added in v2.6.1

func (c *CLI) WaitForCondition(
	t testing.TB,
	predicate func() (bool, string),
	timeout time.Duration,
	delay time.Duration,
)

WaitForCondition wait for predicate to execute to true

type CLIOption added in v2.6.1

type CLIOption func(c *CLI)

CLIOption to customize behavior for all commands for a CLI instance.

func WithEnv added in v2.6.1

func WithEnv(env ...string) CLIOption

WithEnv sets environment variables that will be passed to commands.

Jump to

Keyboard shortcuts

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