提交 7a434c39 编写于 作者: Z zentol

[FLINK-8070][yarn][tests] Print errors found in log files

This closes #5012.
上级 c6879cd5
......@@ -69,6 +69,7 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
......@@ -307,6 +308,7 @@ public abstract class YarnTestBase extends TestLogger {
Assert.assertTrue("Expecting directory " + cwd.getAbsolutePath() + " to exist", cwd.exists());
Assert.assertTrue("Expecting directory " + cwd.getAbsolutePath() + " to be a directory", cwd.isDirectory());
List<String> prohibitedExcerpts = new ArrayList<>();
File foundFile = findFile(cwd.getAbsolutePath(), new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
......@@ -331,6 +333,24 @@ public abstract class YarnTestBase extends TestLogger {
// logging in FATAL to see the actual message in TRAVIS tests.
Marker fatal = MarkerFactory.getMarker("FATAL");
LOG.error(fatal, "Prohibited String '{}' in line '{}'", aProhibited, lineFromFile);
StringBuilder logExcerpt = new StringBuilder();
logExcerpt.append(System.lineSeparator());
logExcerpt.append(lineFromFile);
logExcerpt.append(System.lineSeparator());
// extract potential stack trace from log
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (!line.isEmpty() && (Character.isWhitespace(line.charAt(0)) || line.startsWith("Caused by"))) {
logExcerpt.append(line);
logExcerpt.append(System.lineSeparator());
} else {
break;
}
}
prohibitedExcerpts.add(logExcerpt.toString());
return true;
}
}
......@@ -355,7 +375,9 @@ public abstract class YarnTestBase extends TestLogger {
while (scanner.hasNextLine()) {
LOG.warn("LINE: " + scanner.nextLine());
}
Assert.fail("Found a file " + foundFile + " with a prohibited string: " + Arrays.toString(prohibited));
Assert.fail(
"Found a file " + foundFile + " with a prohibited string (one of " + Arrays.toString(prohibited) + "). " +
"Excerpts:" + System.lineSeparator() + prohibitedExcerpts);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册