Description
openedon Sep 10, 2024
Describe the bug
While working on #43074 I noticed that when I set system properties related to logging (e.g. quarkus.logging."org.hibernate".level=TRACE
) before a test using QuarkusUnitTest
, then these properties still apply in test classes that execute afterwards -- even if I reset them after each test!
I thought "fair enough, setting system properties dynamically probably isn't recommended anyway".
But then I started doing something like this:
@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClass(MyMappedSuperclass.class)
.addClass(MyAbstractEntity.class)
.addClass(MyConcreteEntity.class)
.addClass(FieldAccessEnhancedDelegate.class))
.withConfigurationResource("application.properties")
.overrideConfigKey("quarkus.hibernate-orm.log.bind-parameters", "true");
... which simply sets a Quarkus property related to logging (bind-parameters
) in application.properties
.
And again, that setting affected test classes that executed afterwards.
So, it seems to me QuarkusUnitTest
leaks logging configuration from one test to the next... somehow.
QuarkusUnitTest
being internal, it's not that bad, but what worries me more is the possibility that this leak could also happen in actual application tests, for example those that use a QuarkusTestProfile
to enable tracing in one particular test only. I did not try that, but that's something we should investigate to decide how critical this leak is.
Expected behavior
Customizing log configuration in one test should not affect following test classes in the same run.
Actual behavior
Customizing log configuration in one test affects all following test classes in the same run.
How to Reproduce?
- Clone https://github.com/yrodiere/quarkus/tree/test-logging-config-leak (note it's branch
test-logging-config-leak
, notmain
) - Notice in the Git history that the logging config is modified in
PublicFieldAccessInheritanceTest
through propertyquarkus.hibernate-orm.log.bind-parameters
. - Notice in the Git history that the logging config is not modified in
LogBindParametersDefaultValueTest
. - Build Quarkus locally.
- Run
./mvnw clean test -pl extensions/hibernate-orm/deployment -Dtest='PublicFieldAccessInheritanceTest,LogBindParametersDefaultValueTest'
- Notice the test output for
LogBindParametersDefaultValueTest
shows TRACE logs, even though we don't enable them in this test. - Notice
LogBindParametersDefaultValueTest
failed because of these unexpected logs.
Output of uname -a
or ver
No response
Output of java -version
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
No response
Additional information
No response