Skip to content

Conversation

kabo87777
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant