Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions docs/usage/generic_containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you indent this and the following line so that it's clear which object this is being called on?

.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

Expand Down