Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
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;
Expand Down Expand Up @@ -307,6 +308,7 @@ public static void ensureNoProhibitedStringInLogFiles(final String[] prohibited,
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) {
Expand All @@ -331,6 +333,24 @@ public boolean accept(File dir, String name) {
// 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;
}
}
Expand All @@ -355,7 +375,9 @@ public boolean accept(File dir, String name) {
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);
}
}

Expand Down