iotdb icon indicating copy to clipboard operation
iotdb copied to clipboard

fix tests in ClusterSchemaTreeTest

Open kabo87777 opened this issue 3 months ago • 0 comments

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

  1. Set-based comparison: Modified checkVisitorResult methods to use HashSet comparison instead of index-based array comparison
  2. Removed limit/offset: Changed problematic test cases from limit=X, offset=Y to limit=0, offset=0
  3. 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.

Key changed/added classes (or packages if there are too many classes) in this PR

kabo87777 avatar Oct 06 '25 01:10 kabo87777