test

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 38

Documentation

Overview

Package test contains functions that implement common functionality between tests. The code (non-test) in this package intentionally does not take any dependendies outside the vim25 tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyContainerRuntimeDefaults added in v0.55.0

func ApplyContainerRuntimeDefaults(spec *types.VirtualMachineConfigSpec) error

ApplyContainerRuntimeDefaults adds runtime-appropriate ExtraConfig defaults to spec. It is a no-op when the current runtime requires no special treatment.

An error is returned when the spec already contains an explicit value for a key that the runtime default would change. An exact value match is treated as a silent no-op: the caller already expressed the same intent. A differing value is an error because silently overriding explicit test intent would mask problems.

func ContainerCurlProbeArgs added in v0.56.0

func ContainerCurlProbeArgs(network, targetURL string) []string

ContainerCurlProbeArgs returns the "docker run" argument list for probing targetURL from a curlimages/curl container, joining network (if non-empty, typically the result of ContainerNetworkFromSpec) so the probe can reach a container-backed VM that is not on the runtime's default bridge (e.g. rootless podman).

func ContainerNetworkFromSpec added in v0.55.0

func ContainerNetworkFromSpec(spec *types.VirtualMachineConfigSpec) string

ContainerNetworkFromSpec returns the RUN.network value from spec's ExtraConfig, or "" when not set. After ApplyContainerRuntimeDefaults, this yields the bridge name that was configured for rootless podman, or "" on runtimes that use the default bridge (e.g. root Docker). Pass the result to any probe container that must reach the VM container by IP.

func HasDocker added in v0.46.0

func HasDocker() bool

func IsRootlessPodman added in v0.55.0

func IsRootlessPodman() bool

IsRootlessPodman returns true when the docker CLI is backed by rootless podman. Rootless podman has restrictions such as the inability to bind-mount system paths like /sys/class/dmi/id.

The detection result is memoized (sync.Once): the underlying runtime does not change within a test binary's lifetime, and each call otherwise spawns up to two subprocesses, which adds up across the many container-backed tests that call this indirectly via ApplyContainerRuntimeDefaults.

func NewAuthenticatedClient

func NewAuthenticatedClient(t *testing.T) *vim25.Client

NewAuthenticatedClient creates a new vim25.Client, authenticates the user specified in the test URL, and returns it.

func URL

func URL() *url.URL

URL parses the GOVMOMI_TEST_URL environment variable if set.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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