environment

package
v24.0.8+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DanglingImageIdGraphDriver = "sha256:0df1207206e5288f4a989a2f13d1f5b3c4e70467702c1d5d21dfc9f002b7bd43" // #nosec G101 -- ignoring: Potential hardcoded credentials (gosec)

DanglingImageIdGraphDriver is the digest for dangling images used in tests when the graph driver is used. The graph driver image store identifies images by the ID of their config.

View Source
const DanglingImageIdSnapshotter = "sha256:16d365089e5c10e1673ee82ab5bba38ade9b763296ad918bd24b42a1156c5456" // #nosec G101 -- ignoring: Potential hardcoded credentials (gosec)

DanglingImageIdSnapshotter is the digest for dangling images used in tests when the containerd image store is used. The container image store identifies images by the ID of their manifest/manifest list..

Variables

This section is empty.

Functions

func EnsureFrozenImagesLinux

func EnsureFrozenImagesLinux(testEnv *Execution) error

EnsureFrozenImagesLinux loads frozen test images into the daemon if they aren't already loaded

func GetTestDanglingImageId

func GetTestDanglingImageId(testEnv *Execution) string

func ProtectAll

func ProtectAll(t testing.TB, testEnv *Execution)

ProtectAll protects the existing environment (containers, images, networks, volumes, and, on Linux, plugins) from being cleaned up at the end of test runs

func ProtectContainers

func ProtectContainers(t testing.TB, testEnv *Execution)

ProtectContainers protects existing containers from being cleaned up at the end of test runs

func ProtectImages

func ProtectImages(t testing.TB, testEnv *Execution)

ProtectImages protects existing images and on linux frozen images from being cleaned up at the end of test runs

func ProtectNetworks

func ProtectNetworks(t testing.TB, testEnv *Execution)

ProtectNetworks protects existing networks from being cleaned up at the end of test runs

func ProtectPlugins

func ProtectPlugins(t testing.TB, testEnv *Execution)

ProtectPlugins protects existing plugins from being cleaned up at the end of test runs

func ProtectVolumes

func ProtectVolumes(t testing.TB, testEnv *Execution)

ProtectVolumes protects existing volumes from being cleaned up at the end of test runs

Types

type Execution

type Execution struct {
	DaemonInfo       types.Info
	DaemonVersion    types.Version
	OSType           string
	PlatformDefaults PlatformDefaults
	// contains filtered or unexported fields
}

Execution contains information about the current test execution and daemon under test

func FromClient

func FromClient(c *client.Client) (*Execution, error)

FromClient creates a new Execution environment from the passed in client

func New

func New() (*Execution, error)

New creates a new Execution struct This is configured using the env client (see client.FromEnv)

func (*Execution) APIClient

func (e *Execution) APIClient() client.APIClient

APIClient returns an APIClient connected to the daemon under test

func (*Execution) Clean

func (e *Execution) Clean(t testing.TB)

Clean the environment, preserving protected objects (images, containers, ...) and removing everything else. It's meant to run after any tests so that they don't depend on each others.

func (*Execution) DaemonAPIVersion

func (e *Execution) DaemonAPIVersion() string

DaemonAPIVersion returns the negotiated daemon api version

func (*Execution) GitHubActions

func (e *Execution) GitHubActions() bool

GitHubActions is true if test is executed on a GitHub Runner.

func (*Execution) HasExistingImage

func (e *Execution) HasExistingImage(t testing.TB, reference string) bool

HasExistingImage checks whether there is an image with the given reference. Note that this is done by filtering and then checking whether there were any results -- so ambiguous references might result in false-positives.

func (*Execution) IsLocalDaemon

func (e *Execution) IsLocalDaemon() bool

IsLocalDaemon is true if the daemon under test is on the same host as the test process.

Deterministically working out the environment in which CI is running to evaluate whether the daemon is local or remote is not possible through a build tag.

For example Windows to Linux CI under Jenkins tests the 64-bit Windows binary build with the daemon build tag, but calls a remote Linux daemon.

We can't just say if Windows then assume the daemon is local as at some point, we will be testing the Windows CLI against a Windows daemon.

Similarly, it will be perfectly valid to also run CLI tests from a Linux CLI (built with the daemon tag) against a Windows daemon.

func (*Execution) IsRemoteDaemon

func (e *Execution) IsRemoteDaemon() bool

IsRemoteDaemon is true if the daemon under test is on different host as the test process.

func (*Execution) IsRootless

func (e *Execution) IsRootless() bool

IsRootless returns whether the rootless mode is enabled

func (*Execution) IsUserNamespace

func (e *Execution) IsUserNamespace() bool

IsUserNamespace returns whether the user namespace remapping is enabled

func (*Execution) IsUserNamespaceInKernel

func (e *Execution) IsUserNamespaceInKernel() bool

IsUserNamespaceInKernel returns whether the kernel supports user namespaces

func (*Execution) NotAmd64

func (e *Execution) NotAmd64() bool

NotAmd64 returns true if the daemon's architecture is not amd64

func (*Execution) Print

func (e *Execution) Print()

Print the execution details to stdout TODO: print everything

func (*Execution) ProtectContainer

func (e *Execution) ProtectContainer(t testing.TB, containers ...string)

ProtectContainer adds the specified container(s) to be protected in case of clean

func (*Execution) ProtectImage

func (e *Execution) ProtectImage(t testing.TB, images ...string)

ProtectImage adds the specified image(s) to be protected in case of clean

func (*Execution) ProtectNetwork

func (e *Execution) ProtectNetwork(t testing.TB, networks ...string)

ProtectNetwork adds the specified network(s) to be protected in case of clean

func (*Execution) ProtectPlugin

func (e *Execution) ProtectPlugin(t testing.TB, plugins ...string)

ProtectPlugin adds the specified plugin(s) to be protected in case of clean

func (*Execution) ProtectVolume

func (e *Execution) ProtectVolume(t testing.TB, volumes ...string)

ProtectVolume adds the specified volume(s) to be protected in case of clean

func (*Execution) RuntimeIsWindowsContainerd

func (e *Execution) RuntimeIsWindowsContainerd() bool

RuntimeIsWindowsContainerd returns whether containerd runtime is used on Windows

func (*Execution) UsingSnapshotter

func (e *Execution) UsingSnapshotter() bool

UsingSnapshotter returns whether containerd snapshotters are used for the tests by checking if the "TEST_INTEGRATION_USE_SNAPSHOTTER" is set to a non-empty value.

type PlatformDefaults

type PlatformDefaults struct {
	BaseImage            string
	VolumesConfigPath    string
	ContainerStoragePath string
}

PlatformDefaults are defaults values for the platform of the daemon under test

Jump to

Keyboard shortcuts

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