← 输入框|github.com|刷新
Skip to content

Fixing flaky test in AlignmentToolsTest.java - #906

Closed
Vidishab18 wants to merge 1 commit into
biojava:masterfrom
Vidishab18:one_flaky_test_fixed
Closed

Vidishab18 wants to merge 1 commit into
biojava:masterfrom
Vidishab18:one_flaky_test_fixed

Conversation

@Vidishab18

Copy link
Copy Markdown
Contributor

The test AlignmentToolsTest#testToConciseAlignmentString is flaky due to the order dependence in AlignmentTools class toConciseAlignmentString method in S seedNode = alig.keySet().iterator().next(); to which the HashMap is passed from the test testToConciseAlignmentString. Due to the non-deterministic order of iteration, it can be produce different structures since the Oracle specification about HashMap says that "This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time." The documentation is here for your reference:https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html

The retrieval of the elements using keySet() can be non-deterministic for a HashMap and can cause AlignmentToolsTest#testToConciseAlignmentString to be a flaky test. The HashMap is now replaced with the LinkedHashMap so that the non-deterministic iteration order of HashMap is eliminated.

@sbliven

sbliven commented Dec 7, 2020

Copy link
Copy Markdown
Member

I created #907 to discuss the issue behind this PR.

@sbliven sbliven left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you run this patch against your test tool? The first thing toConciseAlignmentString does is copy the input to a HashMap, so changing the input to LinkedHashMap should not make a difference.

I think a better solution is to copy input into a TreeMap within toConciseAlignmentString to ensure ordered enumeration.

@josemduarte

Copy link
Copy Markdown
Contributor

This has been inactive a long time. I'll close

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