diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java index fa9de74..21d59db 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java @@ -296,6 +296,8 @@ public void testContainerLogsFileAccess() throws IOException { // It is trying simulate a situation where first log file is owned by // different user (probably symlink) and second one by the user itself. + // The first file should not be aggregated. Because this log file has the invalid + // user name. when(logValue.getUser()).thenReturn(randomUser).thenReturn( ugi.getShortUserName()); logWriter.append(logKey, logValue); @@ -320,6 +322,9 @@ public void testContainerLogsFileAccess() throws IOException { expectedOwner = adminsGroupString; } } + + // This file: stderr should not be aggregated. + // And we will not aggregate the log message. String stdoutFile1 = StringUtils.join( File.separator, @@ -327,10 +332,8 @@ public void testContainerLogsFileAccess() throws IOException { workDir.getAbsolutePath(), "srcFiles", testContainerId1.getApplicationAttemptId().getApplicationId() .toString(), testContainerId1.toString(), stderr })); - String message1 = - "Owner '" + expectedOwner + "' for path " + stdoutFile1 - + " did not match expected owner '" + randomUser + "'"; - + + // The file: stdout is expected to be aggregated. String stdoutFile2 = StringUtils.join( File.separator, @@ -343,7 +346,6 @@ public void testContainerLogsFileAccess() throws IOException { + stdoutFile2 + " did not match expected owner '" + ugi.getShortUserName() + "'"; - Assert.assertTrue(line.contains(message1)); Assert.assertFalse(line.contains(message2)); Assert.assertFalse(line.contains(data + testContainerId1.toString() + stderr));