Documentation
¶
Overview ¶
Package framework provides helpers to run e2e test scenarios against containers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Alpine = Image{ Ref: "docker.io/library/alpine:3.22", Entrypoint: sleepEntrypoint, WaitCmd: []string{"apk", "--version"}, }
Alpine is a plain Alpine container.
var ArchLinux = Image{ Ref: "docker.io/library/archlinux:base", Entrypoint: sleepEntrypoint, WaitCmd: []string{"pacman", "--version"}, }
ArchLinux is a plain Arch container.
var Busybox = Image{ Ref: "docker.io/library/busybox:latest", Entrypoint: sleepEntrypoint, WaitCmd: []string{"true"}, }
Busybox is a plain busybox container with busybox's adduser/groupadd applets.
var OpenWrt2410 = Image{ Ref: "docker.io/openwrt/rootfs:x86_64-24.10.8", Entrypoint: []string{"/sbin/init"}, CapAdd: []string{"SYS_ADMIN"}, SecurityOpt: []string{"seccomp=unconfined", "apparmor=unconfined"}, WaitCmd: []string{"ubus", "call", "system", "board"}, }
OpenWrt2410 is an OpenWrt 24.10 machine with procd as PID 1 and opkg.
var OpenWrt2512 = Image{ Ref: "docker.io/openwrt/rootfs:x86_64-25.12.4", Entrypoint: []string{"/sbin/init"}, CapAdd: []string{"SYS_ADMIN"}, SecurityOpt: []string{"seccomp=unconfined", "apparmor=unconfined"}, WaitCmd: []string{"ubus", "call", "system", "board"}, }
OpenWrt2512 is an OpenWrt 25.12 machine with procd as PID 1 and apk.
var OpenWrtImages = map[string]Image{ "24.10": OpenWrt2410, "25.12": OpenWrt2512, }
OpenWrtImages are the OpenWrt releases every openwrt* test runs on.
var SystemdDebian = Image{ Ref: "quay.io/k0sproject/bootloose-debian12:v0.9.6", Entrypoint: []string{ "/bin/sh", "-c", "[ -w /sys/fs/cgroup ] || mount -o remount,rw /sys/fs/cgroup && exec /sbin/init", }, CapAdd: []string{"SYS_ADMIN"}, SecurityOpt: []string{"apparmor=unconfined"}, Tmpfs: map[string]string{ "/run": "", "/run/lock": "", "/tmp": "", }, WaitCmd: []string{"systemctl", "is-system-running", "--wait"}, }
SystemdDebian is a Debian 12 machine with systemd as PID 1.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a running container machine with a deployed scenario binary.
func PrivateContainer ¶
PrivateContainer deploys the scenario into a dedicated container that is terminated when the test exits.
func SharedContainer ¶
SharedContainer deploys the scenario into a container shared by all tests requesting the same image. Shared containers are reaped by ryuk after the test process exits.
Shared containers should be preferred for testing, since the startup still takes time, CPU and RAM and in general tests should be able to be written in a way to not impact each other. For cases where a test will impact other tests use PrivateContainer.
type Image ¶
type Image struct {
// Ref is the image to start the container with.
Ref string
// Entrypoint is the entrypoint to start the container with.
Entrypoint []string
// CapAdd lists added Linux capabilities.
CapAdd []string
// SecurityOpt lists container security options.
SecurityOpt []string
// Tmpfs maps mount points to mount options.
Tmpfs map[string]string
// Files maps container paths to file content copied in before start.
// Wrap strings in [strings.NewReader].
Files map[string]io.Reader
// WaitCmd probes readiness inside the container.
// Exit codes 0 and 1 count as ready so a degraded systemd boot, common in containers, does not fail the wait.
WaitCmd []string
}
Image describes how to run a target OS as a container machine.
type Scenario ¶
type Scenario struct {
// Name is the scenario directory ./<Name>/ and the binary name.
Name string
// Compiler is the compiler binary.
// Empty means "go".
Compiler string
// Args are the compiler arguments before the output and package arguments.
// Empty means ["build"].
Args []string
// Env is extra build environment appended after the defaults.
Env []string
// Dir is the directory containing the main package to build as the
// scenario binary.
// Defaults to `./<Scenario.Name>`
Dir string
}
Scenario builds and deploys a test binary into a container.