hosttest

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Docker

func Docker(t testing.TB, args ...string) string

Docker runs the docker CLI and returns its trimmed output.

func EnvValue

func EnvValue(t testing.TB, gcpemuEnv func() string, key string) string

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

func LANIP(t testing.TB) string

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

func ParseEnv(out string) map[string]string

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

func SocketArgs(t testing.TB) []string

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.

Jump to

Keyboard shortcuts

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