Documentation
¶
Index ¶
- Constants
- Variables
- func AddContainerToNetwork(pool *dockertest.Pool, network *dockertest.Network, testContainer string) error
- func CleanImagesInCI(pool *dockertest.Pool) error
- func CleanUnreferencedNetworks(pool *dockertest.Pool) error
- func DockerAddIntegrationLabels(opts *dockertest.RunOptions, testType string)
- func DockerAllowLocalIPv6(config *docker.HostConfig)
- func DockerAllowNetworkAdministration(config *docker.HostConfig)
- func DockerMemoryLimit(config *docker.HostConfig)
- func DockerRestartPolicy(config *docker.HostConfig)
- func ExecuteCommand(resource *dockertest.Resource, cmd []string, env []string, ...) (string, string, error)
- func ExtractRunIDFromContainerName(containerName string) string
- func GenerateRunID() string
- func GetFirstOrCreateNetwork(pool *dockertest.Pool, name string) (*dockertest.Network, error)
- func GetIntegrationRunID() string
- func IsRunningInContainer() bool
- func RandomFreeHostPort() (int, error)
- func RunDockerBuildForDiagnostics(contextDir, dockerfile string) string
- func SaveLog(pool *dockertest.Pool, resource *dockertest.Resource, basePath string) (string, string, error)
- func WriteLog(pool *dockertest.Pool, resource *dockertest.Resource, stdout io.Writer, ...) error
- type ExecuteCommandConfig
- type ExecuteCommandOption
Constants ¶
const ( // TimestampFormatRunID is used for generating unique run identifiers // Format: "20060102-150405" provides compact date-time for file/directory names. TimestampFormatRunID = "20060102-150405" )
Variables ¶
var ( ErrDockertestCommandFailed = errors.New("dockertest command failed") ErrDockertestCommandTimeout = errors.New("dockertest command timed out") )
var ErrContainerNotFound = errors.New("container not found")
Functions ¶
func AddContainerToNetwork ¶
func AddContainerToNetwork( pool *dockertest.Pool, network *dockertest.Network, testContainer string, ) error
func CleanImagesInCI ¶ added in v0.26.0
func CleanImagesInCI(pool *dockertest.Pool) error
CleanImagesInCI removes images if running in CI.
func CleanUnreferencedNetworks ¶ added in v0.26.0
func CleanUnreferencedNetworks(pool *dockertest.Pool) error
CleanUnreferencedNetworks removes networks that are not referenced by any containers.
func DockerAddIntegrationLabels ¶ added in v0.27.0
func DockerAddIntegrationLabels(opts *dockertest.RunOptions, testType string)
DockerAddIntegrationLabels adds integration test labels to Docker RunOptions. This allows the hi tool to identify containers belonging to specific test runs. This function should be called before passing RunOptions to dockertest functions.
func DockerAllowLocalIPv6 ¶
func DockerAllowLocalIPv6(config *docker.HostConfig)
DockerAllowLocalIPv6 allows IPv6 traffic within the container.
func DockerAllowNetworkAdministration ¶
func DockerAllowNetworkAdministration(config *docker.HostConfig)
DockerAllowNetworkAdministration gives the container network administration capabilities.
func DockerMemoryLimit ¶ added in v0.27.0
func DockerMemoryLimit(config *docker.HostConfig)
DockerMemoryLimit sets memory limit and disables OOM kill for containers.
func DockerRestartPolicy ¶
func DockerRestartPolicy(config *docker.HostConfig)
DockerRestartPolicy sets the restart policy for containers.
func ExecuteCommand ¶
func ExecuteCommand( resource *dockertest.Resource, cmd []string, env []string, options ...ExecuteCommandOption, ) (string, string, error)
func ExtractRunIDFromContainerName ¶ added in v0.27.0
ExtractRunIDFromContainerName extracts the run ID from container name. Expects format: "prefix-YYYYMMDD-HHMMSS-HASH".
func GenerateRunID ¶ added in v0.27.0
func GenerateRunID() string
GenerateRunID creates a unique run identifier with timestamp and random hash. Format: YYYYMMDD-HHMMSS-HASH (e.g., 20250619-143052-a1b2c3).
func GetFirstOrCreateNetwork ¶
func GetFirstOrCreateNetwork(pool *dockertest.Pool, name string) (*dockertest.Network, error)
func GetIntegrationRunID ¶ added in v0.27.0
func GetIntegrationRunID() string
GetIntegrationRunID returns the run ID for the current integration test session. This is set by the hi tool and passed through environment variables.
func IsRunningInContainer ¶
func IsRunningInContainer() bool
IsRunningInContainer checks if the current process is running inside a Docker container. This is used by tests to determine if they should run integration tests.
func RandomFreeHostPort ¶ added in v0.18.0
RandomFreeHostPort asks the kernel for a free open port that is ready to use. (from https://github.com/phayes/freeport)
func RunDockerBuildForDiagnostics ¶ added in v0.27.0
RunDockerBuildForDiagnostics runs docker build manually to get detailed error output. This is used when a docker build fails to provide more detailed diagnostic information than what dockertest typically provides.
func SaveLog ¶ added in v0.20.0
func SaveLog( pool *dockertest.Pool, resource *dockertest.Resource, basePath string, ) (string, string, error)
Types ¶
type ExecuteCommandConfig ¶
type ExecuteCommandConfig struct {
// contains filtered or unexported fields
}
type ExecuteCommandOption ¶
type ExecuteCommandOption func(*ExecuteCommandConfig) error
func ExecuteCommandTimeout ¶
func ExecuteCommandTimeout(timeout time.Duration) ExecuteCommandOption