Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a few non deterministic tests #14020

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yugvajani
Copy link

Description

This PR fixes three non deterministic tests :

  • org.apache.iotdb.session.SessionCacheLeaderTest.testInsertTabletsWithSessionBroken
  • org.apache.iotdb.commons.path.PathPatternTreeTest.testPathPatternTreeSplit
  • org.apache.iotdb.confignode.persistence.schema.ConfigMTreeTest.testGetAllFileNamesByPath

These tests failed under NonDex tool as explained in the issue IOTDB-6352 .

Steps to Reproduce

To reproduce the problem, first build the module and then run the nondex command:

  • For SessionCacheLeaderTest:

mvn install -pl iotdb-client/session -am -DskipTests

mvn -pl iotdb-client/session edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.iotdb.session.SessionCacheLeaderTest#testInsertTabletsWithSessionBroken

The reason for the flakiness of this test is that HashMap does not guarantee the order of its entries. This unordered behaviour can lead to differences in the insertion or iteration order of the map. The fix involves replacing it with LinkedHashMap which guarantees the order.

  • For PathPatternTreeTest:

mvn install -pl iotdb-core/node-commons -am -DskipTests

mvn -pl iotdb-core/node-commons edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.iotdb.commons.path.PathPatternTreeTest#testPathPatternTreeSplit

The reason for the flakiness of this test is due to the order of the path returned by getAllPathPatterns function which gives a non deterministic order. The simple fix for this is to sort the output of getAllPathPatterns which will give a deterministic output.

  • For ConfigMTreeTest:

mvn install -pl iotdb-core/confignode -am -DskipTests

mvn -pl iotdb-core/confignode edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.iotdb.confignode.persistence.schema.ConfigMTreeTest#testGetAllFileNamesByPath

The reason for the flakiness of this test is due to the path returned by getBelongedDatabases function which gives a non deterministic order. The fix involves converting both the list to HashSet which makes the comparisions order independent.

Please let me know if you have any questions or need any additional justification/changes from my side.


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

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.

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