Wait Class
Provides factory methods for the built-in IWaitStrategy implementations.
public static class WaitMethods
| Name | Description |
|---|---|
| ForAll(IWaitStrategy[]) | Runs the strategies concurrently and waits until all of them complete. The first failure stops the others and fails the wait. |
| ForAny(IWaitStrategy[]) | Runs the strategies concurrently and waits until one of them completes, then stops the others. The wait fails only when all of them fail. |
| ForCommand(IEnumerable<string>, Action<PollingWaitStrategyOptions>?) | Waits until a command run inside the container exits with code 0. The command is run again after each failure. |
| ForCommand(string[]) | Waits until a command run inside the container exits with code 0. The command is run again after each failure. |
| ForDelay(TimeSpan) | Waits for a fixed amount of time. |
| ForHealthcheck(Action<PollingWaitStrategyOptions>?) | Waits until the container runtime reports the health check of the container (the HEALTHCHECK instruction of its image) as healthy. The wait fails at once when the container has no health check or becomes unhealthy. |
| ForHttp(int, string, Action<HttpWaitStrategyOptions>?) | Waits until an HTTP request to the host port mapped to containerPort gets an expected response, by default a 2xx status code. |
| ForLogMessage(string, int) | Waits until a log line contains the specified text. |
| ForLogMessage(Regex, int) | Waits until a log line matches the specified pattern. |
| ForPort(int) | Waits until a TCP connection can be established on the host port mapped to containerPort. |
ForAll(IWaitStrategy[])
Wait.csRuns the strategies concurrently and waits until all of them complete. The first failure stops the others and fails the wait.
public static IWaitStrategy ForAll(params IWaitStrategy[] strategies)ForAny(IWaitStrategy[])
Wait.csRuns the strategies concurrently and waits until one of them completes, then stops the others. The wait fails only when all of them fail.
public static IWaitStrategy ForAny(params IWaitStrategy[] strategies)ForCommand overloads
ForCommand(IEnumerable<string>, Action<PollingWaitStrategyOptions>?)
Wait.csWaits until a command run inside the container exits with code 0. The command is run again after each failure.
public static IWaitStrategy ForCommand(IEnumerable<string> command, Action<PollingWaitStrategyOptions>? configure)Parameters
commandIEnumerable<string>- The command and its arguments. The first element is the executable.
configureAction<PollingWaitStrategyOptions>?- Configures the delay between two runs of the command.
Returns
IWaitStrategy A wait strategy.
ForCommand(string[])
Wait.csWaits until a command run inside the container exits with code 0. The command is run again after each failure.
public static IWaitStrategy ForCommand(params string[] command)Parameters
commandstring[]- The command and its arguments. The first element is the executable.
Returns
IWaitStrategy A wait strategy.
ForDelay(TimeSpan)
Wait.csWaits for a fixed amount of time.
public static IWaitStrategy ForDelay(TimeSpan delay)ForHealthcheck(Action<PollingWaitStrategyOptions>?)
Wait.csWaits until the container runtime reports the health check of the container (the HEALTHCHECK instruction of its image) as healthy. The wait fails at once when the container has no health check or becomes unhealthy.
public static IWaitStrategy ForHealthcheck(Action<PollingWaitStrategyOptions>? configure = null)Parameters
configureAction<PollingWaitStrategyOptions>?- Configures the delay between two inspections of the container.
Returns
IWaitStrategy A wait strategy.
ForHttp(int, string, Action<HttpWaitStrategyOptions>?)
Wait.csWaits until an HTTP request to the host port mapped to containerPort gets an expected response, by default a 2xx status code.
public static IWaitStrategy ForHttp(int containerPort, string path = "/", Action<HttpWaitStrategyOptions>? configure = null)Parameters
containerPortint- The container port to send the request to.
pathstring- The path, and optionally the query, of the request.
configureAction<HttpWaitStrategyOptions>?- Configures the request and the response that means the container is ready.
Returns
IWaitStrategy A wait strategy.
ForLogMessage overloads
ForLogMessage(string, int)
Wait.csWaits until a log line contains the specified text.
public static IWaitStrategy ForLogMessage(string substring, int occurrences = 1)ForLogMessage(Regex, int)
Wait.csWaits until a log line matches the specified pattern.
public static IWaitStrategy ForLogMessage(Regex pattern, int occurrences = 1)Parameters
patternRegex- The pattern to match against each log line.
occurrencesint- The number of matching lines to wait for.
Returns
IWaitStrategy A wait strategy.
ForPort(int)
Wait.csWaits until a TCP connection can be established on the host port mapped to containerPort.
public static IWaitStrategy ForPort(int containerPort)