fix: make SpringBootConfigPropsTest immune to leaked metrics System properties - #16420
Open
jamespud wants to merge 1 commit into
Open
fix: make SpringBootConfigPropsTest immune to leaked metrics System properties#16420jamespud wants to merge 1 commit into
jamespud wants to merge 1 commit into
Conversation
…roperties SpringBootConfigPropsTest intermittently fails in CI with 'expected: <prometheus> but was: <disabled>'. The module's metrics-disabling tests set the JVM System property dubbo.metrics.protocol=disabled, and Dubbo's config resolution gives System properties the highest precedence, so depending on test execution order it overrides the test's @SpringBootTest property dubbo.metrics.protocol=prometheus. Changes: - SpringBootConfigPropsTest / SpringBootMultipleConfigPropsTest: clear the leaked dubbo.metrics.protocol / dubbo.metrics.enabled System properties in @BeforeAll before DubboBootstrap.reset(), so prometheus is bound regardless of prior test state. - SysProps (dubbo-config-spring and dubbo-config-api test helpers, dubbo-test-common): make reset() also clear the recorded System properties (previously it only cleared the internal map), removing the footgun that could leak such properties between tests.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16420 +/- ##
============================================
+ Coverage 60.87% 60.89% +0.01%
+ Complexity 11766 11763 -3
============================================
Files 1953 1953
Lines 89273 89273
Branches 13473 13473
============================================
+ Hits 54346 54363 +17
+ Misses 29333 29314 -19
- Partials 5594 5596 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
SpringBootConfigPropsTestintermittently fails in CI withexpected: <prometheus> but was: <disabled>atSpringBootConfigPropsTest.java:106.The module's metrics-disabling tests set the JVM System property
dubbo.metrics.protocol=disabled. Dubbo's config resolution (Environment.getConfigurationMaps()) gives System properties the highest precedence, so depending on test execution order within the JVM fork, that property overrides this test's@SpringBootTestpropertydubbo.metrics.protocol=prometheus, and the assertion fails.Root cause
dubbo-config-springcontains 30+ tests that setdubbo.metrics.protocol=disabled(some viaSysProps.setProperty, i.e. real System properties) to disable metrics in their scenarios.MetricsConfigthrough Dubbo's own configuration chain, whereSystemConfigurationranks first — higher than the Spring inlined test property.MetricsConfig.protocolbecomesdisabled.Reproduction (before fix):
mvn -pl dubbo-config/dubbo-config-spring -am test -Dtest=SpringBootConfigPropsTest -Ddubbo.metrics.protocol=disabledfails with the same assertion.Brief changelog
SpringBootConfigPropsTest/SpringBootMultipleConfigPropsTest: in@BeforeAll, clear the leakeddubbo.metrics.protocol/dubbo.metrics.enabledSystem properties beforeDubboBootstrap.reset(), soprometheusis always bound regardless of prior test state.SysProps(dubbo-config-spring / dubbo-config-api test helpers and dubbo-test-common): makereset()also clear the recorded System properties (previously it only cleared the internal map), removing the footgun that could leak such properties between tests.Verifying the change
-Ddubbo.metrics.protocol=disabled) passes for bothSpringBootConfigPropsTestandSpringBootMultipleConfigPropsTest.ConfigTest,DubboConfigAliasPostProcessorTest,DubboNamespaceHandlerTest,JavaConfigBeanTest, etc.) and dubbo-config-api (ConfigCenterConfigTest,ServiceConfigTest,ApplicationConfigTest,ReferenceCacheTest,MultiInstanceTest) all pass.