micronaut-projects / micronaut-maven-plugin

Maven plugin to execute Micronaut applications
https://micronaut-projects.github.io/micronaut-maven-plugin/latest/
Apache License 2.0
20 stars 21 forks source link

mn:run shuts down the test resources service after compile and doesn't restart it. #1100

Closed npiguet closed 4 months ago

npiguet commented 4 months ago

Expected Behavior

When my webapp is recompiled due to a change in the code, my application and all the containers it depends on are restarted. Then my application works as expected.

Ideally, to save some time, the test containers are never shut down and not restarted either (oracle is really slow to start).

Actual Behaviour

When my webapp is recompiled due to a change in the code, it restarts. However all the containers started by Micronaut test resources are shut down and never restarted, causing the application to fail to start

Steps To Reproduce

INFO] 📝 Detected change in src/main/resources/application-test.yml. Recompiling/restarting... [INFO] [info] Shutting down Micronaut Test Resources service

I've done a but of debugging, and it looks like this is caused by mn:run calling mvn compile in a different process when it detects changes to the watched directories. When that happens the new mvn compile runs as expected, but before terminating hits TestResourcesLifecycleExtension.afterSessionEnd(), which unconditionally stops the test resources service.

As far as I can tell, nothing in either process restarts it.

I would personally love it if it DID NOT shut down the test containers at all.

Environment Information

JDK 17 Ubuntu 22.04 Micronaut 4.4.2 micronaut-maven-plugin 4.5.3

graemerocher commented 4 months ago

this is definitely a bug and unfortunate behaviour //cc @alvarosanchez @melix

npiguet commented 4 months ago

Running mvn mn:start-testresources-service in a separate terminal before mn:run works around the problem. That mechanism works as expected

alvarosanchez commented 4 months ago

I have identified the problem, hoping to have a fix soon.