YARN-8327. Fix TestAggregatedLogFormat#testReadAcontainerLogs1 on Windows. Contributed by Giovanni Matteo Fumarola.

(cherry picked from commit f09dc73001)
This commit is contained in:
Inigo Goiri 2018-05-23 15:59:30 -07:00
parent 61b5b2f4f7
commit fa8af4aab5
1 changed files with 12 additions and 7 deletions

View File

@ -254,13 +254,18 @@ public class TestAggregatedLogFormat {
// Since we could not open the fileInputStream for stderr, this file is not // Since we could not open the fileInputStream for stderr, this file is not
// aggregated. // aggregated.
String s = writer.toString(); String s = writer.toString();
int expectedLength =
"LogType:stdout".length() int expectedLength = "LogType:stdout".length()
+ (logUploadedTime ? ("\nLog Upload Time:" + Times.format(System + (logUploadedTime
.currentTimeMillis())).length() : 0) ? (System.lineSeparator() + "Log Upload Time:"
+ ("\nLogLength:" + numChars).length() + Times.format(System.currentTimeMillis())).length()
+ "\nLog Contents:\n".length() + numChars + "\n".length() : 0)
+ "\nEnd of LogType:stdout\n".length(); + (System.lineSeparator() + "LogLength:" + numChars).length()
+ (System.lineSeparator() + "Log Contents:" + System.lineSeparator())
.length()
+ numChars + ("\n").length() + ("End of LogType:stdout"
+ System.lineSeparator() + System.lineSeparator()).length();
Assert.assertTrue("LogType not matched", s.contains("LogType:stdout")); Assert.assertTrue("LogType not matched", s.contains("LogType:stdout"));
Assert.assertTrue("log file:stderr should not be aggregated.", !s.contains("LogType:stderr")); Assert.assertTrue("log file:stderr should not be aggregated.", !s.contains("LogType:stderr"));
Assert.assertTrue("log file:logs should not be aggregated.", !s.contains("LogType:logs")); Assert.assertTrue("log file:logs should not be aggregated.", !s.contains("LogType:logs"));