dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

Fix: Stabilize `GenericServiceTest.testGenericComplexCompute4FullServiceMetadata` under NonDex

Open Anshul-creator opened this issue 1 week ago • 1 comments

What is the purpose of the change?

This PR stabilizes the test GenericServiceTest.testGenericComplexCompute4FullServiceMetadata, which was exhibiting order-dependent flakiness under randomized execution orders (NonDex).

Root Cause

The test compared the returned result string against ComplexObject.toString() using strict assertEquals(...). However, ComplexObject.toString() includes a Map field (maps={...}), and the iteration order of HashMap entries is not guaranteed. As a result, the serialized string could differ only in map-entry ordering (e.g., {v1_k1=..., v1_k2=...} vs {v1_k2=..., v1_k1=...}), causing intermittent assertion failures.

Changes Made

  • Preserved the existing strict assertEquals(...) checks for the overall result format.
  • Added order-insensitive assertions that validate:
    • the result starts with the expected "haha###" / "haha2###" prefix, and
    • the result contains both expected map entries (v1_k1=v1_v1 and v1_k2=v1_v2), regardless of ordering.
  • Kept the rest of the test logic unchanged.

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-compatible \
  edu.illinois:nondex-maven-plugin:2.2.1:nondex \
  -DnondexRuns=100 \
  -Dtest=org.apache.dubbo.generic.GenericServiceTest#testGenericComplexCompute4FullServiceMetadata

The test 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-compatible/.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?

Anshul-creator avatar Dec 14 '25 19:12 Anshul-creator

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 60.79%. Comparing base (efed26c) to head (75ab6e7).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #15848      +/-   ##
============================================
+ Coverage     60.77%   60.79%   +0.01%     
+ Complexity    11710    11706       -4     
============================================
  Files          1938     1938              
  Lines         88692    88692              
  Branches      13387    13387              
============================================
+ Hits          53903    53919      +16     
+ Misses        29260    29245      -15     
+ Partials       5529     5528       -1     
Flag Coverage Δ
integration-tests-java21 32.37% <ø> (+<0.01%) :arrow_up:
integration-tests-java8 32.51% <ø> (+0.07%) :arrow_up:
samples-tests-java21 32.06% <ø> (+0.08%) :arrow_up:
samples-tests-java8 29.71% <ø> (+0.02%) :arrow_up:
unit-tests-java11 59.10% <ø> (+0.04%) :arrow_up:
unit-tests-java17 58.57% <ø> (ø)
unit-tests-java21 58.57% <ø> (-0.03%) :arrow_down:
unit-tests-java25 58.53% <ø> (+<0.01%) :arrow_up:
unit-tests-java8 59.09% <ø> (+0.04%) :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.

codecov-commenter avatar Dec 14 '25 19:12 codecov-commenter