atlas
atlas copied to clipboard
Fix flaky test in AtlasJanusGraphIndexClientTest#testGetTopTermsRandom4
What changes were proposed in this pull request?
The test AtlasJanusGraphIndexClientTest#testGetTopTermsRandom4 failed intermittently because HashMap iteration order is non-deterministic.
Changed generateTerms(...) to use LinkedHashMap so iteration order is consistent.
This is a test-only change.
How was this patch tested?
-
Reproduced flaky failures with NonDex, a tool that systematically perturbs iteration order to expose order-dependent bugs.
-
Example command:
mvn -pl graphdb/janus edu.illinois:nondex-maven-plugin:2.1.7:nondex \ -Dtest=org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphIndexClientTest#testGetTopTermsRandom4 \ -Drat.skip -
Before fix:
[INFO] Running org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphIndexClientTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.806 s <<< FAILURE! - in org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphIndexClientTest
[ERROR] org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphIndexClientTest.testGetTopTermsRandom4 Time elapsed: 0.423 s <<< FAILURE!
java.lang.AssertionError: expected [8] but found [7]
at org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphIndexClientTest.assertOrder(AtlasJanusGraphIndexClientTest.java:143)
at org.apache.atlas.repository.graphdb.janus.AtlasJanusGraphIndexClientTest.testGetTopTermsRandom4(AtlasJanusGraphIndexClientTest.java:99)
- After fix: test passes consistently under repeated NonDex runs.