Orchestration Management
Let’s learn about how to configure and test PostgreSQL.
When we run our integration tests, the PostgreSQL database engine must already be running in the background. It must also already be configured, for example, with a new database ready to be used. Additionally, when all the tests have been executed, the database should be removed, and the database engine needs to stop running.
This job is most suited for Docker, which can run complex systems in isolation with minimal configuration. Here, we have a choice: either choose to orchestrate the creation and destruction of the database with an external script or implement everything in the test suite. Since the first solution is what many frameworks tend to use, in this chapter, we’ll show an implementation of that solution.
We’ve planned to create a management script that spins up and tears down the required containers and runs the tests. The management script can also be used to run the application itself or to create development setups, but in this case, we’ll simplify it only to manage the tests.
Update the requirements
The first thing we need to do when we use Docker Compose is to add the requirement to the requirements/test.txt
file, as we can see in the code below:
Get hands-on with 1400+ tech skills courses.