Skip to content

Change assertion to prevent IoTDBInterpreterTest from failing due to indeterminate ordering#5666

Closed
faaple wants to merge 2 commits intoapache:masterfrom
faaple:fix_IoTDBInterpreterTest
Closed

Change assertion to prevent IoTDBInterpreterTest from failing due to indeterminate ordering#5666
faaple wants to merge 2 commits intoapache:masterfrom
faaple:fix_IoTDBInterpreterTest

Conversation

@faaple
Copy link

@faaple faaple commented Apr 25, 2022

Some tests in the class org.apache.zeppelin.iotdb.IoTDBInterpreterTest can fail based on the order of iteration in ConcurrentHashMap. These tests are testShowTimeseries, testShowDevices, testShowDevicesWithSg, testShowAllTTL, and testShowStorageGroup.

I found the issue using NonDex:

mvn test-compile -pl tsfile -am
mvn -pl zeppelin-interpreter edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=org.apache.zeppelin.iotdb.IoTDBInterpreterTest

The test can fail because it assumes that the order of the data is determinate, and can be fixed it by ignoring the order.

List<String> actualList = new ArrayList<String>(Arrays.asList(actual.split("\n")));
List<String> expectedList = new ArrayList<String>(Arrays.asList(gt.split("\n")));
Assert.assertEquals(expectedList.get(0), actualList.get(0));
Assert.assertEquals(new HashSet<String>(expectedList), new HashSet<String>(actualList));
Copy link
Member

Choose a reason for hiding this comment

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

This modification has a benifit that we can know which line of results are incorrect.
However, IMO, it is sensitive about the order of the resultset table.
So, using Hashset to compare the result is not very good.
We may need to use ArrayList to split the result and compare them line by line.

@HTHou HTHou closed this Apr 11, 2023
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.

3 participants