Skip to content

Fix flaky test#2

Open
prathyushreddylpr wants to merge 1 commit into
masterfrom
fixflakytest2
Open

Fix flaky test#2
prathyushreddylpr wants to merge 1 commit into
masterfrom
fixflakytest2

Conversation

@prathyushreddylpr

@prathyushreddylpr prathyushreddylpr commented Sep 26, 2023

Copy link
Copy Markdown
Owner

Description
Fixed the flaky test withTextValuesMap inside the StandardImageMetadataSupportTest class.

Root Cause
The test withTextValuesMap has 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 NodeList textEntries. The code is updated in such a way that for each entry(irrespective of the order) in the hashmap, the attributes of textEntries(both "keyword" and "value") are tested to be present in the HashMap entries.

How this has been tested?

Java: openjdk version "11.0.20.1"
Maven: Apache Maven 3.6.3

  1. Module build - Successful
    Command used -
mvn install -pl infra/common -am -DskipTests
  1. Regular test - Successful
    Command used -
mvn -pl imageio/imageio-core test -Dtest=com.twelvemonkeys.imageio.StandardImageMetadataSupportTest#withTextValuesMap
  1. NonDex test - Failed
    Command used -
mvn -pl imageio/imageio-core edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=com.twelvemonkeys.imageio.StandardImageMetadataSupportTest#withTextValuesMap

NonDex test passed after the fix.

@yesh385

yesh385 commented Sep 28, 2023

Copy link
Copy Markdown

Reviewed the PR and the fix looks good.

@zzjas

zzjas commented Oct 5, 2023

Copy link
Copy Markdown

Same comment as prathyushreddylpr/druid#1

@prathyushreddylpr

Copy link
Copy Markdown
Owner Author

Same comment as prathyushreddylpr/druid#1

Updated

@zzjas

zzjas commented Oct 6, 2023

Copy link
Copy Markdown

You can proceed to open a real PR. Once you open a real PR, please mark this tentative PR as Opened in your tentative_pr.csv file and also raise a PR to IDoFT marking this as Opened. Thanks!

@zzjas

zzjas commented Oct 17, 2023

Copy link
Copy Markdown

Have you opened a real PR for this? If so, please mark this as "Opened" in your tentative_pr.csv file and also raise a PR to IDoFT marking this as Opened. Thanks!

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