tests

package
v0.7.22 Latest Latest
Warning

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

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

Documentation

Overview

Package tests contains the exported functions that are meant to be imported as test cases.

It should not export any other thing except for a SubcommandOption struct (e.g., LoginOption) that may be added in the future.

Each file contains one subcommand to test and is named after that subcommand. Note that the file names are not suffixed with _test so that they can appear in Go Doc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(o *option.Option)

Build command building an image.

TODO: --no-cache, syntax check for docker files --no-cache flag is added to tests asserting the output from `RUN` command. [Discussion]: https://github.com/runfinch/common-tests/pull/4#discussion_r971338825

func BuilderPrune

func BuilderPrune(o *option.Option)

BuilderPrune tests the "builder prune" command that prunes the builder cache.

func CleanupLocalRegistry

func CleanupLocalRegistry(o *option.Option)

CleanupLocalRegistry removes the local registry container and image. It's used together with SetupLocalRegistry, and should be invoked after running all the tests.

func ComposeBuild

func ComposeBuild(o *option.Option)

ComposeBuild tests functionality of `compose build` command.

func ComposeDown

func ComposeDown(o *option.Option)

ComposeDown tests functionality of `compose down` command.

func ComposeKill

func ComposeKill(o *option.Option)

ComposeKill tests functionality of `compose` command.

func ComposeLogs

func ComposeLogs(o *option.Option)

ComposeLogs tests functionality of `compose logs` command.

func ComposePs

func ComposePs(o *option.Option)

ComposePs tests functionality of `compose ps` command.

func ComposePull

func ComposePull(o *option.Option)

ComposePull tests functionality of `compose pull` command.

func Cp added in v0.2.0

func Cp(o *option.Option)

Cp tests `finch cp` command to copy files between container and host filesystems.

func Create

func Create(o *option.Option)

Create tests creating a container.

func Events

func Events(o *option.Option)

Events tests "events" command that gets real time events from server, synonyms to "system events" command.

func Exec

func Exec(o *option.Option)

Exec tests executing a command in a running container.

func ImageHistory

func ImageHistory(o *option.Option)

ImageHistory tests "image history" command that shows the history of an image.

func ImageInspect

func ImageInspect(o *option.Option)

ImageInspect tests "image inspect" command that displays detailed information on one or more images.

func ImagePrune

func ImagePrune(o *option.Option)

ImagePrune tests "image prune" command that removes unused images.

func Images

func Images(o *option.Option)

Images tests functionality of `images` command that lists container images.

func Info

func Info(o *option.Option)

Info tests "info" command that displays system-wide information, synonyms to "system info" command.

func Inspect

func Inspect(o *option.Option)

Inspect tests displaying the detailed information of image or container.

func Kill

func Kill(o *option.Option)

Kill tests killing a running container.

func Load

func Load(o *option.Option)

Load tests loading images from tar file or stdin.

func Login

func Login(o *option.Option)

Login tests logging in a container registry.

func Logout

func Logout(o *option.Option)

Logout tests logging out a container registry.

func Logs

func Logs(o *option.Option)

Logs tests fetching logs of a container.

func NetworkCreate

func NetworkCreate(o *option.Option)

NetworkCreate tests the "network create" command that creates a network.

func NetworkInspect

func NetworkInspect(o *option.Option)

NetworkInspect tests the "network inspect" command that displays detailed information on one or more networks.

func NetworkLs

func NetworkLs(o *option.Option)

NetworkLs tests the "network ls" command that list networks.

func NetworkRm

func NetworkRm(o *option.Option)

NetworkRm tests the "network rm" command that removes one or more networks.

func Port

func Port(o *option.Option)

Port tests listing port mappings or a specific mapping for a container.

func Ps added in v0.7.0

func Ps(o *option.Option)

Ps tests functionality of `ps` command.

func Pull

func Pull(o *option.Option)

Pull tests pulling a container image.

func Push

func Push(o *option.Option)

Push tests pushing an image to a registry.

func Restart

func Restart(o *option.Option)

Restart tests "restart" command that will restart one or more running containers.

func Rm

func Rm(o *option.Option)

Rm tests removing a container.

func Rmi

func Rmi(o *option.Option)

Rmi tests removing a container image.

func Run

func Run(o *RunOption)

Run tests running a container image. TODO: test cases for bind propagation options.

func Save

func Save(o *option.Option)

Save tests saving an image to a tar archive.

func SetupLocalRegistry

func SetupLocalRegistry(o *option.Option)

SetupLocalRegistry can be invoked before running the tests to save time when pulling images during tests.

It spins up a local registry, tags all remoteImages, pushes the new tagged images to the local registry, and changes adds corresponding entries to localImages for all of the new tags pushed to local registry.

After all the tests are done, invoke CleanupLocalRegistry to clean up the local registry.

func Start

func Start(o *option.Option)

Start tests starting a container.

func Stats

func Stats(o *option.Option)

Stats tests displaying container resource usage statistics.

func Stop

func Stop(o *option.Option)

Stop tests stopping a container.

func Tag

func Tag(o *option.Option)

Tag tests tagging a container image.

func VolumeCreate

func VolumeCreate(o *option.Option)

VolumeCreate tests "volume create" command that creates a volume.

func VolumeInspect

func VolumeInspect(o *option.Option)

VolumeInspect tests "volume inspect" command that displays detailed information on one or more volumes.

func VolumeLs

func VolumeLs(o *option.Option)

VolumeLs tests "volume ls" command that lists volumes.

func VolumePrune

func VolumePrune(o *option.Option)

VolumePrune tests "volume prune" command that removes all unused volumes.

func VolumeRm

func VolumeRm(o *option.Option)

VolumeRm tests "volume rm" command that removes one or more volumes.

Types

type CGMode added in v0.2.0

type CGMode int

CGMode is the cgroups mode of the host system. We copy the struct from containerd/cgroups [1] instead of using it as a library because it only builds on linux, while we don't really need the functions that make it only build on linux (e.g., determine the cgroup version of the current host).

[1] https://github.com/containerd/cgroups/blob/cc78c6c1e32dc5bde018d92999910fdace3cfa27/utils.go#L38-L50

const (
	// Unavailable cgroup mountpoint.
	Unavailable CGMode = iota
	// Legacy cgroups v1.
	Legacy
	// Hybrid with cgroups v1 and v2 controllers mounted.
	Hybrid
	// Unified with only cgroups v2 mounted.
	Unified
)

type MountJSON

type MountJSON struct {
	MountType   string `json:"Type"`
	Source      string `json:"Source"`
	Destination string `json:"Destination"`
	Mode        string `json:"Mode"`
	Rw          bool   `json:"RW"`
}

MountJSON is used to parse the json from the command images inspect --format "{{json .Mounts}}".

type RunOption added in v0.2.0

type RunOption struct {
	// BaseOpt instructs how to run the test subject.
	BaseOpt *option.Option
	// CGMode is the cgroup mode that the host uses.
	CGMode CGMode
	// DefaultHostGatewayIP is the IP that the test subject will resolve special IP `host-gateway` to.
	DefaultHostGatewayIP string
}

RunOption is the custom option to run tests in run.go.

Jump to

Keyboard shortcuts

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