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.
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 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
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 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, 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 ¶
This section is empty.