Automating tests of cooperating microservices
Docker Compose is really helpful when it comes to manually managing a group of microservices. In this section, we will take this one step further and integrate Docker Compose into our test script, test-em-all.bash
. The test script will automatically start up the microservice landscape, run all the required tests to verify that the microservice landscape works as expected, and finally, tear it down, leaving no traces behind.
The test script can be found at $BOOK_HOME/Chapter04/test-em-all.bash
.
Before the test script runs the test suite, it will check for the presence of a start
argument in the invocation of the test script. If found, it will restart the containers with the following code:
if [[ $@ == *"start"* ]]
then
echo "Restarting the test environment..."
echo "$ docker-compose down --remove-orphans"
docker-compose down --remove-orphans
echo "$ docker-compose up -d"...