From fc1f4970eae17305a3bc80c039cfdaac2b5bd79a Mon Sep 17 00:00:00 2001 From: Pete Cornish Date: Thu, 28 Apr 2016 20:02:26 +0100 Subject: [PATCH] Updates documentation to cover new WaitStrategy behaviours. --- docs/usage/generic_containers.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/usage/generic_containers.md b/docs/usage/generic_containers.md index 1985b86419e..75477fb4c68 100644 --- a/docs/usage/generic_containers.md +++ b/docs/usage/generic_containers.md @@ -97,8 +97,34 @@ This simple measure provides a basic check whether a container is ready for use. If the default 60s timeout is not sufficient, it can be altered with the `withStartupTimeout()` method. -If waiting for a listening TCP port is not sufficient to establish whether the container is ready, `GenericContainer` should be subclassed -and an appropriate overriding mechanism set in `waitUntilContainerStarted()`. +If waiting for a listening TCP port is not sufficient to establish whether the container is ready, you can use the +`waitingFor()` method with other `WaitStrategy` implementations as shown below. + +#### Waiting for startup examples + +You can choose to wait for an HTTP(S) endpoint to return a particular status code. + +Waiting for 200 OK: + + @ClassRule + public static GenericContainer elasticsearch = + new GenericContainer("elasticsearch:2.3") + .withExposedPorts(9200) + .waitingFor(Wait.forHttp("/all")); + +Wait for arbitrary status code on an HTTPS endpoint: + + @ClassRule + public static GenericContainer elasticsearch = + new GenericContainer("elasticsearch:2.3") + .withExposedPorts(9200) + .waitingFor(Wait.forHttp("/all") + .forStatusCode(301) + .usingTls()); + +For futher options, check out the `Wait` convenience class, or the various subclasses of `WaitStrategy`. If none of these options +meet your requirements, you can create your own subclass of `AbstractWaitStrategy` with an appropriate wait +mechanism in `waitUntilReady()`. The `GenericContainer.waitingFor()` method accepts any valid `WaitStrategy`. ### Following container output