Add in documentation for wait-for (#32)
This commit is contained in:
parent
add417b77d
commit
651b4faf7f
1 changed files with 59 additions and 26 deletions
33
README.md
33
README.md
|
|
@ -70,6 +70,7 @@ Creates a testcontainers instance from a given Docker label and returns them
|
||||||
| `:command` | Vector with strings | The start command of the container|
|
| `:command` | Vector with strings | The start command of the container|
|
||||||
| `:network` | Map | A map containing the configuration of a Docker Network (see: `create-network`)|
|
| `:network` | Map | A map containing the configuration of a Docker Network (see: `create-network`)|
|
||||||
| `:network-aliases` | Map | A list of alias names for the container on the network |
|
| `:network-aliases` | Map | A list of alias names for the container on the network |
|
||||||
|
| `:wait-for` | Map | A map containing the wait strategy to use and the condition to check for|
|
||||||
|
|
||||||
#### Result:
|
#### Result:
|
||||||
|
|
||||||
|
|
@ -80,6 +81,7 @@ Creates a testcontainers instance from a given Docker label and returns them
|
||||||
| `:env-vars` | Map | Value of the same input parameter|
|
| `:env-vars` | Map | Value of the same input parameter|
|
||||||
| `:host` | String | The host for the Docker Container|
|
| `:host` | String | The host for the Docker Container|
|
||||||
| `:network` | Map | The network configuration of the Container, if provided|
|
| `:network` | Map | The network configuration of the Container, if provided|
|
||||||
|
| `:wait-for` | Map | The wait-for configuration of the Container, if provided!
|
||||||
|
|
||||||
#### Example:
|
#### Example:
|
||||||
|
|
||||||
|
|
@ -94,6 +96,20 @@ Creates a testcontainers instance from a given Docker label and returns them
|
||||||
"while true; do echo \"$MAGIC_NUMBER\" | nc -l -p 80; done"]})
|
"while true; do echo \"$MAGIC_NUMBER\" | nc -l -p 80; done"]})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Example using wait-for and healthcheck:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
(create {:image-name "alpine:3.2"
|
||||||
|
:exposed-ports [80]
|
||||||
|
:env-vars {"MAGIC_NUMBER" "42"}
|
||||||
|
:network (create-network)
|
||||||
|
:network-aliases ["api-server"]
|
||||||
|
:wait-for {:strategy :health}
|
||||||
|
:command ["/bin/sh"
|
||||||
|
"-c"
|
||||||
|
"while true; do echo \"$MAGIC_NUMBER\" | nc -l -p 80; done"]})
|
||||||
|
```
|
||||||
|
|
||||||
### init
|
### init
|
||||||
Initializes a given Testcontainer, which was e.g. provided by a library
|
Initializes a given Testcontainer, which was e.g. provided by a library
|
||||||
|
|
||||||
|
|
@ -107,6 +123,7 @@ Initializes a given Testcontainer, which was e.g. provided by a library
|
||||||
| `:command` | Vector with strings | The start command of the container|
|
| `:command` | Vector with strings | The start command of the container|
|
||||||
| `:network` | Map | A map containing the configuration of a Docker Network (see: `create-network`)|
|
| `:network` | Map | A map containing the configuration of a Docker Network (see: `create-network`)|
|
||||||
| `:network-aliases` | Map | A list of alias names for the container on the network |
|
| `:network-aliases` | Map | A list of alias names for the container on the network |
|
||||||
|
| `:wait-for` | Map | A map containing the wait strategy to use and the condition to check for|
|
||||||
#### Result:
|
#### Result:
|
||||||
|
|
||||||
| Key | Type | Description |
|
| Key | Type | Description |
|
||||||
|
|
@ -116,6 +133,7 @@ Initializes a given Testcontainer, which was e.g. provided by a library
|
||||||
| `:env-vars` | Map | Value of the same input parameter|
|
| `:env-vars` | Map | Value of the same input parameter|
|
||||||
| `:host` | String | The host for the Docker Container|
|
| `:host` | String | The host for the Docker Container|
|
||||||
| `:network` | Map | The network configuration of the Container, if provided|
|
| `:network` | Map | The network configuration of the Container, if provided|
|
||||||
|
| `:wait-for` | Map | The wait-for configuration of the Container, if provided!
|
||||||
|
|
||||||
#### Example:
|
#### Example:
|
||||||
|
|
||||||
|
|
@ -129,6 +147,19 @@ Initializes a given Testcontainer, which was e.g. provided by a library
|
||||||
"while true; do echo \"$MAGIC_NUMBER\" | nc -l -p 80; done"]})
|
"while true; do echo \"$MAGIC_NUMBER\" | nc -l -p 80; done"]})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Example using wait-for and a log message:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
;; PostgreSQL container needs a separate library! This is not included.
|
||||||
|
(init {:container (org.testcontainers.containers.PostgreSQLContainer)
|
||||||
|
:exposed-ports [80]
|
||||||
|
:env-vars {"MAGIC_NUMBER" "42"}
|
||||||
|
:wait-for {:strategy :log :message "accept connections"}
|
||||||
|
:command ["/bin/sh"
|
||||||
|
"-c"
|
||||||
|
"while true; do echo \"$MAGIC_NUMBER\" | nc -l -p 80; done"]})
|
||||||
|
```
|
||||||
|
|
||||||
### create-from-docker-file
|
### create-from-docker-file
|
||||||
Creates a testcontainer from a Dockerfile
|
Creates a testcontainer from a Dockerfile
|
||||||
|
|
||||||
|
|
@ -142,6 +173,7 @@ Creates a testcontainer from a Dockerfile
|
||||||
| `:command` | Vector with strings | The start command of the container|
|
| `:command` | Vector with strings | The start command of the container|
|
||||||
| `:network` | Map | A map containing the configuration of a Docker Network (see: `create-network`)|
|
| `:network` | Map | A map containing the configuration of a Docker Network (see: `create-network`)|
|
||||||
| `:network-aliases` | Map | A list of alias names for the container on the network |
|
| `:network-aliases` | Map | A list of alias names for the container on the network |
|
||||||
|
| `:wait-for` | Map | A map containing the wait strategy to use and the condition to check for|
|
||||||
#### Result:
|
#### Result:
|
||||||
|
|
||||||
| Key | Type | Description |
|
| Key | Type | Description |
|
||||||
|
|
@ -151,6 +183,7 @@ Creates a testcontainer from a Dockerfile
|
||||||
| `:env-vars` | Map | Value of the same input parameter|
|
| `:env-vars` | Map | Value of the same input parameter|
|
||||||
| `:host` | String | The host for the Docker Container|
|
| `:host` | String | The host for the Docker Container|
|
||||||
| `:network` | Map | The network configuration of the Container, if provided|
|
| `:network` | Map | The network configuration of the Container, if provided|
|
||||||
|
| `:wait-for` | Map | The wait-for configuration of the Container, if provided!
|
||||||
|
|
||||||
#### Example:
|
#### Example:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue