testutil

package
v0.140.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndpointForPort added in v0.111.0

func EndpointForPort(port int) string

EndpointForPort gets the endpoint for a given port using localhost.

func GetAvailableLocalAddress

func GetAvailableLocalAddress(tb testing.TB) string

GetAvailableLocalAddress finds an available local port on tcp network and returns an endpoint describing it. The port is available for opening when this function returns provided that there is no race by some other code to grab the same port immediately.

func GetAvailableLocalNetworkAddress added in v0.57.2

func GetAvailableLocalNetworkAddress(tb testing.TB, network string) string

GetAvailableLocalNetworkAddress finds an available local port on specified network and returns an endpoint describing it. The port is available for opening when this function returns provided that there is no race by some other code to grab the same port immediately.

func GetAvailablePort

func GetAvailablePort(tb testing.TB) int

func SetFeatureGateForTest added in v0.55.0

func SetFeatureGateForTest(tb testing.TB, gate *featuregate.Gate, enabled bool) func()

Force the state of feature gate for a test usage: defer SetFeatureGateForTest("gateName", true)()

func TempDir added in v0.136.0

func TempDir(tb testing.TB) string

TempDir creates a temporary directory in a safe way. On Linux, it just calls tb.TempDir.

On Windows, it uses os.MkdirTemp to create directory since t.TempDir results in an error during cleanup in scoped-tests, possibly due to an interaction with the -count argument in `go test`. It does not do any cleanup (i.e. the directory is left on the filesystem). Prefer using tb.TempDir directly if possible.

See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42639

Types

This section is empty.

Jump to

Keyboard shortcuts

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