testcontainer/wait
Types
A readiness strategy. Built via constructors (log/1, port/1, http/2,
health_check/0, command/1, all_of/1, any_of/1) and tweaked via
with_timeout/2 and with_poll_interval/2.
pub opaque type WaitStrategy
Values
pub fn all_of(strategies: List(WaitStrategy)) -> WaitStrategy
Composes strategies - succeeds when ALL inner strategies succeed.
pub fn any_of(strategies: List(WaitStrategy)) -> WaitStrategy
Composes strategies - succeeds as soon as ANY inner strategy succeeds.
pub fn command(cmd: List(String)) -> WaitStrategy
Runs a command inside the container and waits until it exits 0.
pub fn describe(strategy: WaitStrategy) -> String
Human-readable description used in WaitTimedOut / WaitFailed errors.
pub fn health_check() -> WaitStrategy
Waits for Docker to report the container’s HEALTHCHECK as healthy.
The image must define a HEALTHCHECK for this to terminate.
pub fn http(port: Int, path: String) -> WaitStrategy
Waits until an HTTP GET to the given path on the given container port returns status 200.
pub fn http_with_status(
port: Int,
path: String,
status: Int,
) -> WaitStrategy
Like http/2 but waits for a custom expected status code.
pub fn log(message: String) -> WaitStrategy
Waits until the container’s combined stdout/stderr stream contains the given message at least once.
pub fn log_times(message: String, times: Int) -> WaitStrategy
Like log/1 but waits until the message appears at least times times.
pub fn none() -> WaitStrategy
“No wait” - succeeds immediately. This is the default when a
ContainerSpec is built with container.new/1 and no wait_for/2
is set.
pub fn poll_interval_ms(strategy: WaitStrategy) -> Int
Returns the configured poll interval in milliseconds.
pub fn port(port: Int) -> WaitStrategy
Waits until the given (TCP) container port accepts connections from the host.
pub fn timeout_ms(strategy: WaitStrategy) -> Int
Returns the configured timeout in milliseconds.
pub fn with_poll_interval(
strategy: WaitStrategy,
ms: Int,
) -> WaitStrategy
Sets the polling interval (default 1 s). Values <= 0 are clamped to 1 to avoid a hot-spin loop.
pub fn with_timeout(
strategy: WaitStrategy,
ms: Int,
) -> WaitStrategy
Sets the per-strategy timeout (default 60 s). Negative values are clamped to 0 (the strategy times out immediately).