Prepare Release 0.3.0

This commit is contained in:
Tim Zöller 2020-10-23 23:12:24 +02:00
parent 94975f68f0
commit 193482c1b8
4 changed files with 120 additions and 110 deletions

View file

@ -1,10 +1,19 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## [0.3.0] - Upcoming ## [0.4.0] - Upcoming
## [0.3.0] - 2020-10-23
### Added ### Added
- [#25](https://github.com/javahippie/clj-test-containers/issues/25): Add support for a container wait stategy - [#25](https://github.com/javahippie/clj-test-containers/issues/25): Add support for a container wait stategy
- [#35](https://github.com/javahippie/clj-test-containers/issues/35): Add support for docker version 2.4.0 - upgrading testcontainers-java version - [#35](https://github.com/javahippie/clj-test-containers/issues/35): Add support for docker version 2.4.0 - upgrading testcontainers-java version
- [#27](https://github.com/javahippie/clj-test-containers/issues/27): Add support for accessing container logs
- [#38](https://github.com/javahippie/clj-test-containers/pull/38): Add type hints to silence reflection warnings
- [#33](https://github.com/javahippie/clj-test-containers/pull/33): Add more options to the HTTP wait strategy
- [#28](https://github.com/javahippie/clj-test-containers/pull/28): Link to the java lib
- [#23](https://github.com/javahippie/clj-test-containers/pull/23): Configure clojure.spec, spec out a few functions
- [#24](https://github.com/javahippie/clj-test-containers/pull/24): cljstyle redux, with pre-commit hook
- [#21](https://github.com/javahippie/clj-test-containers/pull/21): Install and configure cljstyle
### Changed ### Changed
- [#29](https://github.com/javahippie/clj-test-containers/issues/29): init-network should be called create-network! - [#29](https://github.com/javahippie/clj-test-containers/issues/29): init-network should be called create-network!

208
README.md
View file

@ -62,26 +62,27 @@ Creates a testcontainers instance from a given Docker label and returns them
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:image-name` | String, mandatory | The name and label of an image, e.g. `postgres:12.2` | | `:image-name` | String, mandatory | The name and label of an image, e.g. `postgres:12.2` |
| `:exposed-ports` | Vector with ints, mandatory | All ports which should be exposed and mapped to a local port | | `:exposed-ports` | Vector with ints, mandatory | All ports which should be exposed and mapped to a local port |
| `:env-vars` | Map | A map with environment variables| | `:env-vars` | Map | A map with environment variables |
| `: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| | `:wait-for` | Map | A map containing the wait strategy to use and the condition to check for |
| `:log-to` | Map | A map containing the log strategy to use, e.g. {:log-strategy string} |
#### Result: #### Result:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) | | `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) |
| `:exposed-ports` | Vector with ints | Value of the same input parameter | | `:exposed-ports` | Vector with ints | Value of the same input parameter |
| `: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! | `:wait-for` | Map | The wait-for configuration of the Container, if provided! |
#### Example: #### Example:
@ -115,25 +116,27 @@ Initializes a given Testcontainer, which was e.g. provided by a library
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:container` | `org.testcontainers.containers.GenericContainer`, mandatory | The name and label of an image, e.g. `postgres:12.2` | | `:container` | `org.testcontainers.containers.GenericContainer`, mandatory | The name and label of an image, e.g. `postgres:12.2` |
| `:exposed-ports` | Vector with ints, mandatory | All ports which should be exposed and mapped to a local port | | `:exposed-ports` | Vector with ints, mandatory | All ports which should be exposed and mapped to a local port |
| `:env-vars` | Map | A map with environment variables| | `:env-vars` | Map | A map with environment variables |
| `: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| | `:wait-for` | Map | A map containing the wait strategy to use and the condition to check for |
| `:log-to` | Map | A map containing the log strategy to use, e.g. {:log-strategy string} |
| | | |
#### Result: #### Result:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) | | `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) |
| `:exposed-ports` | Vector with ints | Value of the same input parameter | | `:exposed-ports` | Vector with ints | Value of the same input parameter |
| `: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! | `:wait-for` | Map | The wait-for configuration of the Container, if provided! |
#### Example: #### Example:
@ -165,25 +168,27 @@ Creates a testcontainer from a Dockerfile
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:docker-file` | String, mandatory | String containing a path to a Dockerfile | | `:docker-file` | String, mandatory | String containing a path to a Dockerfile |
| `:exposed-ports` | Vector with ints, mandatory | All ports which should be exposed and mapped to a local port | | `:exposed-ports` | Vector with ints, mandatory | All ports which should be exposed and mapped to a local port |
| `:env-vars` | Map | A map with environment variables| | `:env-vars` | Map | A map with environment variables |
| `: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| | `:wait-for` | Map | A map containing the wait strategy to use and the condition to check for |
| `:log-to` | Map | A map containing the log strategy to use, e.g. {:log-strategy string} |
| | | |
#### Result: #### Result:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) | | `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) |
| `:exposed-ports` | Vector with ints | Value of the same input parameter | | `:exposed-ports` | Vector with ints | Value of the same input parameter |
| `: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! | `:wait-for` | Map | The wait-for configuration of the Container, if provided! |
#### Example: #### Example:
@ -203,20 +208,21 @@ Starts the Testcontainer, which was defined by `create`
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| First parameter: | | | | First parameter: | | |
| `container-config`| Map, mandatory | Return value of the `create` function | | `container-config` | Map, mandatory | Return value of the `create` function |
| | | |
#### Result: #### Result:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) | | `:container` | `org.testcontainers.containers.Container` | The Testcontainers instance, accessible for everything this library doesn't provide (yet) |
| `:exposed-ports` | Vector with ints | Value of the same input parameter | | `:exposed-ports` | Vector with ints | Value of the same input parameter |
| `: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 |
| `:id` | String | The ID of the started docker container| | `:id` | String | The ID of the started docker container |
| `:mapped-ports` | Map | A map containing the container port as key and the mapped local port as a value| | `:mapped-ports` | Map | A map containing the container port as key and the mapped local port as a value |
#### Example: #### Example:
@ -236,10 +242,10 @@ Stops the Testcontainer, which was defined by `create`
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| First parameter: | | | | First parameter: | | |
| `container-config`| Map, mandatory | Return value of the `create` function | | `container-config` | Map, mandatory | Return value of the `create` function |
#### Result: #### Result:
The `container-config` The `container-config`
@ -292,14 +298,14 @@ Binds a path from your local filesystem into the Docker container as a volume
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| First parameter: | | | | First parameter: | | |
| `container-config`| Map, mandatory | Return value of the `create` function | | `container-config` | Map, mandatory | Return value of the `create` function |
| Second parameter: | | | | Second parameter: |   |   |
| `:host-path` | String , mandatory | Path on your local filesystem | | `:host-path` | String , mandatory | Path on your local filesystem |
| `:container-path` | String, mandatory | Path, to which the resource should be mapped | | `:container-path` | String, mandatory | Path, to which the resource should be mapped |
| `:mode` | Keyword, mandatory | `:read-only` or `:read-write` | | `:mode` | Keyword, mandatory | `:read-only` or `:read-write` |
#### Result: #### Result:
@ -350,21 +356,21 @@ Executes a command in the running container, and returns the result
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| First parameter: | | | | First parameter: | | |
| `container-config`| Map, mandatory | Return value of the `create` function | | `container-config` | Map, mandatory | Return value of the `create` function |
| Second parameter: | | | | Second parameter: |   |   |
| `command` | Vector with Strings, mandatory | A vector containing the command and its parameters | | `command` | Vector with Strings, mandatory | A vector containing the command and its parameters |
#### Result: #### Result:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:exit-code` | int | Exit code of the executed command | | `:exit-code` | int | Exit code of the executed command |
| `:stdout` | String | Content of stdout | | `:stdout` | String | Content of stdout |
| `:stdin` | String | Content of stdin | | `:stdin` | String | Content of stdin |
#### Example: #### Example:
@ -378,20 +384,20 @@ Creates a network. The optional map accepts config values for enabling ipv6 and
#### Config parameters: #### Config parameters:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:ipv6`| boolean | Should the network enable IPv6? | | `:ipv6` | boolean | Should the network enable IPv6? |
| `:driver`| String | The network driver used by Docker, e.g. `bridge` or `host` | `:driver` | String | The network driver used by Docker, e.g. `bridge` or `host` |
#### Result: #### Result:
| Key | Type | Description | | Key | Type | Description |
| ------------- |:------------- | :-----| | ------------- | :------------- | :----- |
| `:network` | `org.testcontainers.containers.Network` | The instance of the network | | `:network` | `org.testcontainers.containers.Network` | The instance of the network |
| `:name` | String | The name of the network | | `:name` | String | The name of the network |
| `:ipv6` | boolean | Does the network enable IPv6? | | `:ipv6` | boolean | Does the network enable IPv6? |
| `:driver` | String | The network driver used | | `:driver` | String | The network driver used |
#### Example: #### Example:
@ -404,9 +410,13 @@ Creates a network. The optional map accepts config values for enabling ipv6 and
(create-network) (create-network)
``` ```
### dump-logs
Call on a started container.
Provided logging was enabled for a container, returns the given log presentation, e.g. as a string
| Key | Type | Description |
| `container-config` | Map, mandatory | The configuration describing the container for which the log should be retrieved |
## License ## License
Copyright © 2020 Tim Zöller
Distributed under the Eclipse Public License either version 1.0 or (at Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version. your option) any later version.

View file

@ -1,4 +1,4 @@
(defproject clj-test-containers "0.3.0-SNAPSHOT" (defproject clj-test-containers "0.3.0"
:description "A lightweight, unofficial wrapper around the Testcontainers Java library" :description "A lightweight, unofficial wrapper around the Testcontainers Java library"
:url "https://github.com/javahippie/clj-test-containers" :url "https://github.com/javahippie/clj-test-containers"

View file

@ -27,15 +27,6 @@
(Thread/sleep 500) (Thread/sleep 500)
(is (includes? (sut/dump-logs initialized-container) "database system is ready to accept connections")))) (is (includes? (sut/dump-logs initialized-container) "database system is ready to accept connections"))))
(comment
(def cnt (sut/create {:image-name "postgres:12.2"
:exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}
:wait-for {:wait-strategy :log :message "accept connections"}
:log-to {:log-strategy :string}}))
(def cnt (sut/start! cnt))
(sut/dump-logs cnt))
(testing "Testing basic testcontainer generic image initialisation with wait for log message" (testing "Testing basic testcontainer generic image initialisation with wait for log message"
(let [container (sut/create {:image-name "postgres:12.2" (let [container (sut/create {:image-name "postgres:12.2"
:exposed-ports [5432] :exposed-ports [5432]