SYNOPSIS

use Testcontainers::Wait;

# Wait for a specific port to be listening
my $wait = Testcontainers::Wait::for_listening_port('80/tcp');

# Wait for the lowest exposed port
my $wait = Testcontainers::Wait::for_exposed_port();

# Wait for an HTTP endpoint to return 200
my $wait = Testcontainers::Wait::for_http('/');

# Wait for an HTTP endpoint with custom options
my $wait = Testcontainers::Wait::for_http('/health',
    port          => '8080/tcp',
    status_code   => 200,
    method        => 'GET',
);

# Wait for a log message
my $wait = Testcontainers::Wait::for_log('ready to accept connections');

# Wait for a log message matching regex
my $wait = Testcontainers::Wait::for_log(qr/listening on port \d+/);

# Wait for Docker health check
my $wait = Testcontainers::Wait::for_health_check();

# Combine multiple strategies (all must pass)
my $wait = Testcontainers::Wait::for_all(
    Testcontainers::Wait::for_listening_port('5432/tcp'),
    Testcontainers::Wait::for_log('ready to accept connections'),
);

DESCRIPTION

Factory module for creating wait strategies. Wait strategies determine when a container is "ready" for use in tests. Inspired by the Go testcontainers wait package.

Wait for the specified port to be listening. The port should include the protocol (e.g., 80/tcp). If no protocol is given, /tcp is assumed.

Wait for the lowest exposed port to be listening.

Wait for an HTTP endpoint to return a successful response.

Options:

  • port - Specific port to check (default: lowest exposed port)

  • status_code - Expected HTTP status code (default: 200)

  • method - HTTP method (default: GET)

  • body - Request body

  • headers - HashRef of HTTP headers

  • tls - Use HTTPS (default: false)

Wait for a string or regex pattern to appear in container logs.

Options:

  • occurrences - Number of times the pattern must occur (default: 1)

Wait for the Docker health check to report "healthy".

Combine multiple wait strategies. All must pass for the container to be considered ready.

6 POD Errors

The following errors were encountered while parsing the POD:

Around line 75:

Unknown directive: =func

Around line 86:

Unknown directive: =func

Around line 100:

Unknown directive: =func

Around line 133:

Unknown directive: =func

Around line 151:

Unknown directive: =func

Around line 163:

Unknown directive: =func