Documentation
¶
Overview ¶
Package hosttest holds helpers for tests that drive gcpemu from the host through the docker CLI and the clients' environment, for gcpemu's own tests only: the Containerized Instance tests and the Pre-release host checks. Eventually and Kube also serve the tests in services/gke, to say what a cluster's pods were doing when a wait times out.
Index ¶
- func Docker(t testing.TB, args ...string) string
- func EnvValue(t testing.TB, gcpemuEnv func() string, key string) string
- func Eventually(t testing.TB, timeout time.Duration, what string, cond func() bool, ...)
- func LANIP(t testing.TB) string
- func ParseEnv(out string) map[string]string
- func RunEmulator(t testing.TB, name, image, gatewayPort string, args []string, start ...string) string
- func SocketArgs(t testing.TB) []string
- type Kube
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvValue ¶
EnvValue waits for gcpemuEnv, the output of `gcpemu env`, to set key, and returns its value.
func Eventually ¶
func Eventually(t testing.TB, timeout time.Duration, what string, cond func() bool, diag func() string)
Eventually polls cond until it holds or timeout passes; diag explains a failure.
func LANIP ¶ added in v0.12.0
LANIP returns an IPv4 address of an up, multicast-capable interface other than loopback on which this process can send multicast, or skips the test: mDNS needs one. macOS's Local Network privacy refuses a process the user hasn't allowed, as on GitHub's macOS runners.
func ParseEnv ¶
ParseEnv returns the variables in `gcpemu env` output for a POSIX shell (export K='v') or PowerShell ($env:K = 'v').
func RunEmulator ¶
func RunEmulator(t testing.TB, name, image, gatewayPort string, args []string, start ...string) string
RunEmulator runs the image as an Ephemeral Instance in container name, with its API gateway published at 127.0.0.1:gatewayPort (a port docker picks when it is ""), extra docker run args and start args. It waits until the container is healthy and returns the host address of the API gateway. At cleanup it prints the logs of a failed test's container, keeps them all in GCPEMU_TEST_LOG_DIR when that is set, stops it, so the Instance removes its containers and networks, and removes it.
func SocketArgs ¶
SocketArgs returns the docker run args that mount the runtime's socket at /var/run/docker.sock, with the group that owns it where the runtime runs, which on a VM runtime is inside the VM: on Docker Desktop root (0), whatever the host's socket says, or whether the host has one. They turn off SELinux labelling, without which Podman machine's SELinux denies the container the socket. It skips the test when containers cannot mount the socket.
Types ¶
type Kube ¶ added in v0.15.0
Kube reads a cluster's Kubernetes API for failure diagnostics. It never fails a test: Diagnose reports a failed read, and Logs omits what it could not read.
func (Kube) Diagnose ¶ added in v0.15.0
Diagnose returns what explains pods matching selector not being ready: their status, the nodes, the namespace's recent events and the logs. Logs alone say nothing of a pod that never ran (#966).
func (Kube) DiagnosePod ¶ added in v0.15.0
DiagnosePod is Diagnose for one pod by name, for a pod without labels to select.