Fix: Stabilize more `dubbo-config-spring` reference-related tests by Disabling Metrics Initialization and Ensuring Test Isolation
What is the purpose of the change?
This PR stabilizes more reference-related tests inside dubbo-config-spring that were intermittently failing under randomized execution orders (NonDex) due to shared Dubbo/Spring framework state leaking across test boundaries. The following tests were consistently among the flaky failures before this fix, but now pass reliably across all NonDex seeds:
- LocalCallMultipleReferenceAnnotationsTest:
testLocalCall - LocalCallReferenceMixTest:
testLocalCall - LocalCallReferenceAnnotationTest:
testLocalCall - LocalCallTest:
testLocalCall
LocalCallMultipleReferenceAnnotationsTest also required tightening of the reference-bean assertions to avoid brittle assumptions about bean naming, while preserving the intended semantics of the test.
Root Cause
These failures are identical to previously fixed issues in:
- https://github.com/apache/dubbo/pull/15778
- https://github.com/apache/dubbo/pull/15782
- https://github.com/apache/dubbo/pull/15785
Each of those PRs addressed flakiness caused by Micrometer’s CompositeMeterRegistry, which can throw an ArrayIndexOutOfBoundsException when it iterates over internal IdentityHashMap structures under randomized execution orders (NonDex).
The tests mentioned above suffered from the same underlying issue:
Dubbo framework state was leaking between test methods. This meant that the behavior of reference creation in one test could affect subsequent tests, causing nondeterministic failures.
Changes Made
To fully isolate each test method and eliminate shared state, the following changes were applied:
- Disabled the metrics subsystem at the beginning of each test.
- Cleared all system properties via
SysProps.clear()in the lifecycle hooks to avoid cross-test pollution. - Reset framework state using
DubboBootstrap.reset()to ensure isolation between tests. - Updated the assertions in
LocalCallMultipleReferenceAnnotationsTestto account for valid variation in reference-bean naming, while still enforcing the correct reference-sharing behavior.
Verification
You can try running the following snippet of code from the dubbo repo root, on both pre-fix and post-fix code
./mvnw -q -pl dubbo-config/dubbo-config-spring \
edu.illinois:nondex-maven-plugin:2.2.1:nondex \
-DnondexRuns=50
The tests should fail intermittently on the pre-fix version, but pass consistently across all seeds on the post-fix version.
NonDex run logs will be available under the dubbo-config/dubbo-config-spring/.nondex directory.
Checklist
- [x] Make sure there is a GitHub_issue field for the change.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
- [x] Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 60.57%. Comparing base (4a119ca) to head (da2e3ad).
:warning: Report is 1 commits behind head on 3.3.
Additional details and impacted files
@@ Coverage Diff @@
## 3.3 #15840 +/- ##
============================================
- Coverage 60.75% 60.57% -0.18%
+ Complexity 11713 11118 -595
============================================
Files 1938 1938
Lines 88688 88692 +4
Branches 13387 13387
============================================
- Hits 53882 53728 -154
- Misses 29271 29393 +122
- Partials 5535 5571 +36
| Flag | Coverage Δ | |
|---|---|---|
| integration-tests-java21 | 32.37% <ø> (+<0.01%) |
:arrow_up: |
| integration-tests-java8 | ? |
|
| samples-tests-java21 | ? |
|
| samples-tests-java8 | 29.72% <ø> (+0.03%) |
:arrow_up: |
| unit-tests-java11 | 59.09% <ø> (+0.03%) |
:arrow_up: |
| unit-tests-java17 | 58.55% <ø> (-0.02%) |
:arrow_down: |
| unit-tests-java21 | 58.58% <ø> (+<0.01%) |
:arrow_up: |
| unit-tests-java25 | 58.53% <ø> (+0.02%) |
:arrow_up: |
| unit-tests-java8 | 59.11% <ø> (+0.03%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.