[ 
https://issues.apache.org/jira/browse/MAPREDUCE-7459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17778822#comment-17778822
 ] 

ASF GitHub Bot commented on MAPREDUCE-7459:
-------------------------------------------

goiri commented on code in PR #6215:
URL: https://github.com/apache/hadoop/pull/6215#discussion_r1369245079


##########
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestHistoryViewerPrinter.java:
##########
@@ -160,6 +161,14 @@ public void testHumanPrinter() throws Exception {
         LINE_SEPARATOR, outStr);
   }
 
+  public static boolean compareStrings(String str1, String str2) {
+    String[] lines1 = str1.trim().split("\n");
+    String[] lines2 = str2.trim().split("\n");
+    Arrays.sort(lines1);
+    Arrays.sort(lines2);
+    return Arrays.equals(lines1, lines2);

Review Comment:
   You don't use the output.
   You maye want to call it something closer to assert and also do a final:
   ```
   assertEquals(lines1, lines2)
   ```





> Sort strings to fix flaky test
> ------------------------------
>
>                 Key: MAPREDUCE-7459
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-7459
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>          Components: test
>    Affects Versions: 3.3.6
>         Environment: Java version: openjdk 11.0.20.1
> Maven version: Apache Maven 3.6.3
>            Reporter: Rajiv Ramachandran
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 3.3.6
>
>
> 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. 
> The stack trace is as follows:
> testHumanPrinterAll(org.apache.hadoop.mapreduce.jobhistory.TestHistoryViewerPrinter)
>   Time elapsed: 0.297 s  <<< FAILURE!
> org.junit.ComparisonFailure:
> expected:<...8501754_0001_m_00000[7    6-Oct-2011 19:15:09    6-Oct-2011 
> 19:15:16 (7sec)
> SUCCEEDED MAP task list for job_1317928501754_0001
> TaskId        StartTime    FinishTime    Error    InputSplits
> ====================================================
> task_1317928501754_0001_m_000006    6-Oct-2011 19:15:08    6-Oct-2011 
> 19:15:14 (6sec)
> ...
> /tasklog?attemptid=attempt_1317928501754_0001_m_000003]_1
> REDUCE task list...> but was:<...8501754_0001_m_00000[5    6-Oct-2011 
> 19:15:07    6-Oct-2011 19:15:12 (5sec)
> SUCCEEDED MAP task list for job_1317928501754_0001
> TaskId        StartTime    FinishTime    Error    InputSplits
> ====================================================
> task_1317928501754_0001_m_000006    6-Oct-2011 19:15:08    6-Oct-2011 
> 19:15:14 (6sec)
> SUCCEEDED MAP task list for job_1317928501754_0001
> TaskId        StartTime    FinishTime    Error    InputSplits
> ====================================================
> task_1317928501754_0001_m_000004    6-Oct-2011 19:15:06    6-Oct-2011 
> 19:15:10 (4sec)
> SUCCEEDED MAP task list for job_1317928501754_0001
> TaskId        StartTime    FinishTime    Error    InputSplits
> ====================================================
> task_1317928501754_0001_m_000007    6-Oct-2011 19:15:09    6-Oct-2011 
> 19:15:16 (7sec)
> ...
> /tasklog?attemptid=attempt_1317928501754_0001_m_000006]_1



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: mapreduce-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: mapreduce-issues-h...@hadoop.apache.org

Reply via email to