iotdb
iotdb copied to clipboard
fix tests in ClusterSchemaTreeTest
Fix Non-Deterministic Behavior in ClusterSchemaTreeTest
Problem
Five tests in ClusterSchemaTreeTest were failing non-deterministically under NonDex due to reliance on collection iteration order:
-
testAppendMeasurementPath -
testMergeSchemaTree -
testMultiWildcard -
testSchemaTreeVisitor -
testSchemaTreeWithScope
Way to Reproduce
# Run NonDex to reproduce the non-deterministic failures
mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex \
-Dtest=org.apache.iotdb.db.queryengine.common.schematree.ClusterSchemaTreeTest \
-DnondexRuns=3
# Expected result: Tests fail with different seeds
# Example failure:
# java.lang.AssertionError: expected:<[root.sg.d2.a.s2, root.sg.d2.s1]>
# but was:<[root.sg.d2.a.s1, root.sg.d2.a.s2]>
Root Cause
Tests used order-dependent array comparisons combined with limit/offset parameters on non-deterministically ordered collections (ConcurrentHashMap).
Solution
-
Set-based comparison: Modified
checkVisitorResultmethods to useHashSetcomparison instead of index-based array comparison -
Removed limit/offset: Changed problematic test cases from
limit=X, offset=Ytolimit=0, offset=0 - Updated expectations: Adjusted expected results to include all matching paths
This PR has:
- [ ] been self-reviewed.
- [ ] concurrent read
- [ ] concurrent write
- [ ] concurrent read and write
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods.
- [ ] added or updated version, license, or notice information
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage.
- [ ] added integration tests.
- [ ] been tested in a test IoTDB cluster.