Replies: 1 comment 5 replies
|
thanks for the feedback, did you report some issues? |
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
After upgrading from Micronaut <4.x version> to Micronaut <5.0.x>, some existing tests began failing in ways I believe relate to how properties/environments are resolved in Micronaut 5. I couldn't find much prior discussion, so I'm opening this to understand what changed.
1. Properties not available when the shutdown hook is called
In JobRunr we use a startup hook to startup different processes and a shutdown hook to stop them. We use configuration properties to determine what needs to be started or stopped. See https://github.com/jobrunr/jobrunr/blob/reproducer/micronaut-5-regression/framework-support/jobrunr-micronaut-feature/jobrunr-micronaut/src/main/java/org/jobrunr/micronaut/autoconfigure/JobRunrStarter.java.
The issue is that since the upgrade to Micronaut 5, the web server which is started in different test cases is not stopped after being enabled. The flag set by the test is not available to the shutdown hook, but it's available to the startup hook. This seems to only happen in tests.
To reproduce you may start
JobRunrFactoryTest: https://github.com/jobrunr/jobrunr/blob/reproducer/micronaut-5-regression/framework-support/jobrunr-micronaut-feature/jobrunr-micronaut/src/test/java/org/jobrunr/micronaut/autoconfigure/JobRunrFactoryTest.java.(This issue is easy to workaround, we can rely on the Bean's presence instead of the configuration flag)
2. Placeholders not resolvable with
@MicronautTest(rebuildContext = true)When a property value placeholder is included in tests, the following exception is thrown:
My understanding is that when the test class is instantiated, the placeholder is resolved. But the above exception is thrown for each test case. I believe this to be related to the context being rebuilt. Once the flag
rebuildContext = trueis removed, the exception is no longer thrown. Essentially, property placeholders can't be used in combination with@MicronautTest(rebuildContext = true).As it stands, we basically need to design our tests to avoid the combination of placeholders and
rebuildContext = true.To reproduce you may start
AsyncJobTest: https://github.com/jobrunr/jobrunr/blob/reproducer/micronaut-5-regression/framework-support/jobrunr-micronaut-feature/jobrunr-micronaut-tests/src/test/java/org/jobrunr/scheduling/AsyncJobTest.javaAll reactions