testcontainers-cpp 0.2.0
Native C++20 Testcontainers over the Docker Engine API
Loading...
Searching...
No Matches
testcontainers::wait_for Namespace Reference

Readiness conditions: the alternative types a WaitFor can hold, plus the convenience factories (below) that build them. More...

Classes

struct  None
 No readiness condition — start() returns as soon as the container is started. More...
struct  LogMessage
 Wait until a substring appears in the container's logs a number of times. More...
struct  Duration
 Wait for a fixed duration after start (a coarse fallback strategy). More...
struct  Exit
 Wait until the container stops, optionally with a specific exit code. More...
struct  Healthcheck
 Wait until the container's Docker health status becomes "healthy". More...
struct  Http
 Wait until an HTTP GET to the mapped host port returns expected_status. More...
struct  Port
 Wait until the mapped host port for port accepts a TCP connection. More...
struct  Command
 Wait until a command run inside the container (via exec) exits with code 0. More...

Functions

WaitFor stdout_message (std::string text, int times=1)
 Wait for text to appear times times on stdout.
WaitFor stderr_message (std::string text, int times=1)
 Wait for text to appear times times on stderr.
WaitFor log (std::string text, int times=1)
 Wait for text to appear on either stream.
WaitFor seconds (int s)
 Wait a fixed number of seconds after start.
WaitFor millis (int ms)
 Wait a fixed number of milliseconds after start.
WaitFor exit ()
 Wait until the container stops (with any exit code).
WaitFor exit_code (std::int64_t code)
 Wait until the container stops with the given exit code.
WaitFor healthy ()
 Wait until the container's Docker health becomes "healthy".
WaitFor http (std::string path, ContainerPort port, int status=200)
 Wait until an HTTP GET to path on the mapped host port for port returns status.
WaitFor listening_port (ContainerPort port)
 Wait until the mapped host port for port accepts a TCP connection.
WaitFor successful_command (std::vector< std::string > cmd)
 Wait until cmd (argv form), run inside the container, exits with code 0, e.g.
WaitFor successful_shell_command (std::string script)
 Wait until the shell line script, run inside the container via /bin/sh -c, exits with code 0.

Detailed Description

Readiness conditions: the alternative types a WaitFor can hold, plus the convenience factories (below) that build them.

Convenience factories that build the right WaitFor alternative.

Function Documentation

◆ stdout_message()

WaitFor testcontainers::wait_for::stdout_message ( std::string text,
int times = 1 )
inline

Wait for text to appear times times on stdout.

◆ stderr_message()

WaitFor testcontainers::wait_for::stderr_message ( std::string text,
int times = 1 )
inline

Wait for text to appear times times on stderr.

◆ log()

WaitFor testcontainers::wait_for::log ( std::string text,
int times = 1 )
inline

Wait for text to appear on either stream.

◆ seconds()

WaitFor testcontainers::wait_for::seconds ( int s)
inline

Wait a fixed number of seconds after start.

◆ millis()

WaitFor testcontainers::wait_for::millis ( int ms)
inline

Wait a fixed number of milliseconds after start.

◆ exit()

WaitFor testcontainers::wait_for::exit ( )
inline

Wait until the container stops (with any exit code).

◆ exit_code()

WaitFor testcontainers::wait_for::exit_code ( std::int64_t code)
inline

Wait until the container stops with the given exit code.

◆ healthy()

WaitFor testcontainers::wait_for::healthy ( )
inline

Wait until the container's Docker health becomes "healthy".

◆ http()

WaitFor testcontainers::wait_for::http ( std::string path,
ContainerPort port,
int status = 200 )
inline

Wait until an HTTP GET to path on the mapped host port for port returns status.

◆ listening_port()

WaitFor testcontainers::wait_for::listening_port ( ContainerPort port)
inline

Wait until the mapped host port for port accepts a TCP connection.

◆ successful_command()

WaitFor testcontainers::wait_for::successful_command ( std::vector< std::string > cmd)
inline

Wait until cmd (argv form), run inside the container, exits with code 0, e.g.

successful_command({"pg_isready", "-U", "test"}).

◆ successful_shell_command()

WaitFor testcontainers::wait_for::successful_shell_command ( std::string script)
inline

Wait until the shell line script, run inside the container via /bin/sh -c, exits with code 0.

Requires an image with /bin/sh; for a Windows container use successful_command with the image's shell instead (e.g. {"cmd", "/c", ...}).