This is an automated email from the ASF dual-hosted git repository. ayushsaxena pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push: new d6bb47e5db2f MAPREDUCE-7459. Fixed TestHistoryViewerPrinter flakiness during string comparison (#6215). Contributed by Rajiv Ramachandran. d6bb47e5db2f is described below commit d6bb47e5db2fac8236b23ad30389b5ae69a5c2bd Author: rRajivramachandran <rrajiv9...@gmail.com> AuthorDate: Fri Nov 3 20:53:50 2023 -0500 MAPREDUCE-7459. Fixed TestHistoryViewerPrinter flakiness during string comparison (#6215). Contributed by Rajiv Ramachandran. Reviewed-by: Inigo Goiri <inigo...@apache.org> Signed-off-by: Ayush Saxena <ayushsax...@apache.org> --- .../mapreduce/jobhistory/TestHistoryViewerPrinter.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestHistoryViewerPrinter.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestHistoryViewerPrinter.java index cb508f6d29b9..3a1408bdff9d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestHistoryViewerPrinter.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestHistoryViewerPrinter.java @@ -24,6 +24,7 @@ import org.apache.hadoop.mapreduce.Counters; import org.apache.hadoop.mapreduce.JobID; import org.apache.hadoop.mapreduce.JobStatus; import org.apache.hadoop.mapreduce.TaskType; +import org.assertj.core.api.Assertions; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -35,7 +36,9 @@ import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.TimeZone; import java.util.Locale; @@ -160,6 +163,13 @@ public class TestHistoryViewerPrinter { LINE_SEPARATOR, outStr); } + private static void assertEqualLines(String str1, String str2) { + final List<String> linesFromStr1 = Arrays.asList(str1.trim().split("\n")); + final List<String> linesFromStr2 = Arrays.asList(str2.trim().split("\n")); + + Assertions.assertThat(linesFromStr1).containsExactlyInAnyOrderElementsOf(linesFromStr2); + } + @Test public void testHumanPrinterAll() throws Exception { JobHistoryParser.JobInfo job = createJobInfo(); @@ -168,7 +178,7 @@ public class TestHistoryViewerPrinter { TimeZone.getTimeZone("GMT")); String outStr = run(printer); if (System.getProperty("java.version").startsWith("1.7")) { - Assert.assertEquals("\n" + + assertEqualLines("\n" + "Hadoop job: job_1317928501754_0001\n" + "=====================================\n" + "User: rkanter\n" + @@ -356,7 +366,7 @@ public class TestHistoryViewerPrinter { "localhost\ttask_1317928501754_0001_m_000002, " + LINE_SEPARATOR, outStr); } else { - Assert.assertEquals("\n" + + assertEqualLines("\n" + "Hadoop job: job_1317928501754_0001\n" + "=====================================\n" + "User: rkanter\n" + --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org