Replies: 1 comment
-
Hi, I'm here to ask this exact question. In our development workflow, we're used to start a docker compose, a local instance of the service (we're using Quarkus) and just run a suite against this as a "black box", so we can use the same suite locally (against the running process) and in CI (against the built artifact). We'd like to switch to testcontainers to be able to handle the lifecycle of the containers inside the test suite (to test when an external dependency is unavailable, for example), without losing the option of just running the same suite with the running docker compose file. This is mostly useful because:
Ideally, we would like a way to:
Our issues so far have been:
If you have any suggestion on how to get closer to our target, and which requirements it makes sense to "sacrifice" for a more idiomatic approach, we'd be very grateful. Thanks and have a nice day! |
Beta Was this translation helpful? Give feedback.
-
In some testing situations, it is okay to spin up docker-compose containers once, keep them running and reuse them for both local development and testing. For instance, if your test setup is configured to clear your data at the start (and end) of each run and / or preload it with specific data.
For Spring Boot itself, we can just add the
spring-boot-docker-compose
module and configure the its lifecycle tostart_only
.When containers in a docker-compose file have been ran previously, a project prefix is assigned to each container, usually the name of the current folder.
When the docker-compose testcontainers module starts the containers, it uses a random project ID. This obviously does not match the project ID when you previously manually (or through Spring Boot) started the containers. This causes a runtime error because it tries to start new containers, but the ports are already allocated.
It would be nice if the docker-compose module allowed containers to be reused between development and testing and have some lifecycle options such as 'start only' which would work well for iterative local development.
Beta Was this translation helpful? Give feedback.
All reactions