testdocker

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package testdocker publishes a container's port on a host port docker picks, for the smoke tests that run real containers.

WHY. Picking a free port first (listen on :0, close, pass the number to `docker run -p 127.0.0.1:<port>:…`) is a race: between the close and docker's bind, anything else on the machine can take the port, and the run fails with "failed to bind host port 127.0.0.1:40003/tcp: address already in use" (control-plane's TestOtlpPublicRateLimitsAgainstEnvoy failed on main that way, control-plane#2085). Docker binding a port of its own choosing cannot collide. TestNoPrePickedDockerHostPorts keeps the old spelling out of forge's tests.

Test-only by intent: nothing outside _test.go files imports it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish

func Publish(containerPort int) []string

Publish is the `docker run` flag pair that publishes containerPort on a loopback port docker picks. PublishedPort reads which one it picked.

func PublishedPort

func PublishedPort(t testing.TB, container string, containerPort int) int

PublishedPort is the loopback port docker published containerPort of container on (see Publish).

Types

This section is empty.

Jump to

Keyboard shortcuts

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