dockertest-rs
Control docker containers from a Rust integration test suite. Full fledge management support with automatic cleanup.
This crate provides the following features for your docker testing needs:
- Ensure docker containers are invoked and running according to
WaitForstrategy. - Customize your own or use one of the batteries included.
- Interact with the
RunningContainerin the test body through itsipaddress. - Setup inter-container communication with
inject_container_nameinto environment variables. - Teardown each started container after test is terminated - both successfully and on test failure.
- Concurrent capabilities. All tests are isolated into separate networks per test, with uniquely generated container names.
See the crate documentation for extensive explanations.
Example
This is a trivial example showing of the general structure of a naive test.
use ;
use ;
Testing
Testing this library requires the following:
- docker daemon available on localhost.
- Set
DOCKERTEST_BUILD_TEST_IMAGES=1in your environment, will trigger the test images to be built.
Tests are designed to be run in parallel, and should not conflict with existing system images.
Local images are build with repository prefix dockertest-rs/.
Running dockertest inside docker
To run dockertest inside docker you will have to set the following environment variable:
DOCKERTEST_CONTAINER_ID_INJECT_TO_NETWORK=your_container_id/name
DOCKERTEST_CONTAINER_ID_INJECT_TO_NETWORK has to be set to the ID or name of the container dockertest is running in.