-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sorted Strings to Fix test flakiness in testHumanPrinterAll #1
base: trunk
Are you sure you want to change the base?
Conversation
|
Most of the changes I wanted to suggest have been suggested by @bbelide2. You can maybe add a line to indicate that the test execution has not been hindered by your changes. |
Fixed
The exact error is very Huge and it is a assertion error. Pasting the whole string would not be useful
I am not sure how you can embed a link. I tried copy perma link but that didn't work. @bbelide2 can you tell me how to embed the code
The above template for the PR follows the hadoop default PR template.
Yes. However, HashMap is used at multiple places for constructing the string, Including the source code and the tests. The above fix address the tests without touch the source code.
Fixed |
Looks good now. For embedding the code, you just have to select the code, copy permalink and paste the link in the description. |
Hey sukesh, I have done the same. unfortunately, I am not able to make the code be seen in the PR description |
0ce8ce9
to
32af584
Compare
32af584
to
777daa6
Compare
This fix looks good and elegant to me. Using |
This fix looks good to me. Converting the string to a list and checking if they're the same (without the order) seems a good idea. |
Setup:
Java version: openjdk 11.0.20.1
Maven version: Apache Maven 3.6.3
Description of PR
The test
org.apache.hadoop.mapreduce.jobhistory.TestHistoryViewerPrinter#testHumanPrinterAll
can fail due to flakiness. These flakiness occurs because the test utilizes Hashmaps values and converts the values to string to perform the comparision and the order of the objects returned may not be necessarily maintained. This can be detected by utilizing the Nondex plugin.Steps to reproduce:
git clone https://github.com/apache/hadoop
mvn install -pl hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core -am -DskipTests
mvn -pl hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core test -Dtests=org.apache.hadoop.mapreduce.jobhistory.TestHistoryViewerPrinter#testHumanPrinterAll
mvn -pl hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.hadoop.mapreduce.jobhistory.TestHistoryViewerPrinter#testHumanPrinterAll
-DnondexMode=ONE
& FULL Mode-DnondexMode=FULL
(shuffles differently for each call)For code changes:
The test utilizes Hashmap for storing job information and builts the string using HashMap.values(). However, the order of the objects returned by a Hashmap may not be maintained. Hence the test fails due to the string comparision. The following error occurs
Fix
The Fix involves extracting a single line of the string and sorting them to perform the string comparision. Since the strings are sorted, The comparision passes successfully. The Alternate way of sorting was converting to json but string being built is not json. Moreover, There was no library available to convert string to json.
How was this patch tested?
The fix was tested by adding a suitable fix and running the Nondex plugin again and ensuring that all the tests pass in FULL Mode and ONE Mode of the Nondex runs.