hosttest

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 16 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. 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

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, 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

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

type Kube added in v0.15.0

type Kube struct {
	Endpoint string
	Client   *http.Client
}

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

func (k Kube) Diagnose(ns, selector string) string

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

func (k Kube) DiagnosePod(ns, name string) string

DiagnosePod is Diagnose for one pod by name, for a pod without labels to select.

func (Kube) Logs added in v0.15.0

func (k Kube) Logs(ns, selector string) string

Logs returns the last lines of the pods matching selector.

Jump to

Keyboard shortcuts

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