Fix: Stabilize dubbo-config-spring tests by Disabling Metrics Initialization and Ensuring Test Isolation #15819
+14 −0
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?
This PR stabilizes a large set of tests across three Spring-related test classes inside
dubbo-config-springthat 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:ConfigTest:
testGenericServiceConfig,testSystemPropertyOverrideReferenceConfig,testServiceClass,testProviderNestedService,testSystemPropertyOverrideProtocol,test_noMethodInterface_methodsKeyHasValue,testInitReference,testDubboProtocolPortOverride,testAppendFilter,testSystemPropertyOverrideMultiProtocol,testMultiProtocol,testGenericServiceConfigThroughSpringDubboNamespaceHandlerTest:
testMetricsAggregation,testDelayFixedTime,testDefaultProtocol,testCustomParameter,testProviderXmlOnConfigurationClass,testProviderXml,testProperty,testNotificationWithWrongBean,testMonitor,testMultiProtocol,testTimeoutConfig,testModuleInfoJavaConfigReferenceBeanTest:
testGenericServiceAnnotationBean,testReferenceBean,testLazyProxy2,testAnnotationBean,testLazyProxy1,testGenericServiceReferenceBean,testAnnotationAtField,testLazyProxy3Root Cause
These failures are identical to previously fixed issues in:
ExporterSideConfigUrlTestby disabling metrics initialization during URL export #15778MethodConfigTestby disabling metrics initialization to avoid Micrometer nondeterminism #15782ServiceConfigTestby isolating system properties and cached state #15785Each of those PRs addressed flakiness caused by Micrometer’s
CompositeMeterRegistry, which can throw anArrayIndexOutOfBoundsExceptionwhen it iterates over internalIdentityHashMapstructures under randomized execution orders (NonDex).ConfigTest,DubboNamespaceHandlerTest,JavaConfigReferenceBeanTestsuffered 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:
SysProps.clear()in the lifecycle hooks to avoid cross-test pollution.DubboBootstrap.reset()to ensure isolation between tests.DubboNamespaceHandlerTest.testMetricsPrometheus(), metrics are explicitly re-enabled in a controlled and isolated way to test Prometheus behavior without leaking state into other tests.Verification
You can try running the following snippet of code from the dubbo repo root, on both pre-fix and post-fix code
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/.nondexdirectory.Checklist