The compose project was always registered with the Testcontainers Ryuk
resource reaper, which removes every resource labelled with the project
when the application exits: containers, networks, volumes and images,
with no way to spare some of them. So volumes were removed even with
quarkus.compose.devservices.remove-volumes=false, and services were
stopped even with stop-services=false.
Only register the project with Ryuk when the configuration asks for
the services and their volumes to be removed anyway, and say so in the
log otherwise. The running services are closed when the curated
application is closed, which does not happen at the end of a test run,
so Ryuk was also what stopped the services after tests: run compose
down from a JVM shutdown hook in test mode, so that the services are
stopped and the volumes handled according to the configuration in every
mode.
Fixes quarkusio#47980
The compose project is registered with the Testcontainers Ryuk resource reaper by its
com.docker.compose.projectlabel. Ryuk removes every resource carrying that label when the application exits (containers, networks, volumes and images) and cannot spare some of them, soquarkus.compose.devservices.remove-volumes=falsestill lost the volumes and, as @ozangunalp noted,stop-services=falsestill had the services stopped. Reproduced with a compose file declaring a named volume: about fifteen seconds after a@QuarkusTestJVM exits, the container and the volume are gone despiteremove-volumes=false.While reproducing, a second thing showed up: the running compose service is closed through the curated application's close tasks, which do not run at the end of a test JVM, so in tests Ryuk was the only thing stopping the services;
compose downnever ran. Skipping Ryuk alone would therefore have left the containers running after tests.Changes:
stop-servicesandremove-volumesare enabled, i.e. when everything Ryuk would remove is meant to be removed anyway; otherwise a log line says why Ryuk is not used;compose downis run from a JVM shutdown hook whenstop-servicesis enabled, so services are stopped and volumes handled according to the configuration in every mode;Verified with rootless Podman and a
@QuarkusTest, checkingpodman ps -a/podman volume lsafter the JVM exit:maincompose down -vat exit (and Ryuk still registered)remove-volumes=falsecompose downat exit, volume keptstop-services=falseComposeProjectTestgets a case for the Ryuk condition;extensions/devservices/deploymentis green (22).integration-tests/compose-devservicespassed 5/6 with the change (the RabbitMQ test failed on a Podman API "Broken pipe" creating a Redis container and passes alone); a later rerun of that module fails the same way onmainon this machine, so that is the local Podman service, not the change.