Fix flaky test#2
Open
prathyushreddylpr wants to merge 1 commit into
Open
Conversation
|
Reviewed the PR and the fix looks good. |
|
Same comment as prathyushreddylpr/druid#1 |
Owner
Author
Updated |
|
You can proceed to open a real PR. Once you open a real PR, please mark this tentative PR as |
|
Have you opened a real PR for this? If so, please mark this as "Opened" in your |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixed the flaky test
withTextValuesMapinside theStandardImageMetadataSupportTestclass.TwelveMonkeys/imageio/imageio-core/src/test/java/com/twelvemonkeys/imageio/StandardImageMetadataSupportTest.java
Line 172 in a57a1d3
Root Cause
The test
withTextValuesMaphas been reported as flaky when run with the Nondex tool. The test failed because it is trying to compare the keys and values of a Map(entries) with that of the values in a NodeList. The values of the map are hardcoded in the code and compared with those of the values in NodeList. But the Map is initialized to be a HashMap and the HashMap in Java is implemented in such a way that it does not store the order in which the keys and values are inserted.Fix
In order to fix this test, instead of just retrieving the keys and values from the Hashmap. I have first checked if the key is present in the hashmap using
containsKey()function. If the key is present then the value corresponding to that key is compared to the value from the NodeListtextEntries. The code is updated in such a way that for each entry(irrespective of the order) in the hashmap, the attributes oftextEntries(both "keyword" and "value") are tested to be present in the HashMapentries.How this has been tested?
Java: openjdk version "11.0.20.1"
Maven: Apache Maven 3.6.3
Command used -
Command used -
Command used -
NonDex test passed after the fix.