Repository: flink
Updated Branches:
  refs/heads/release-1.4 9d2861946 -> 56c78cbcf


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

This closes #5012.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/56c78cbc
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/56c78cbc
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/56c78cbc

Branch: refs/heads/release-1.4
Commit: 56c78cbcfd6fddd7af0fee0ee8c179b7a75fb1a7
Parents: 9d28619
Author: zentol <ches...@apache.org>
Authored: Tue Nov 14 11:55:33 2017 +0100
Committer: zentol <ches...@apache.org>
Committed: Wed Nov 22 11:56:41 2017 +0100

----------------------------------------------------------------------
 .../org/apache/flink/yarn/YarnTestBase.java     | 24 +++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/56c78cbc/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YarnTestBase.java
----------------------------------------------------------------------
diff --git 
a/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YarnTestBase.java 
b/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YarnTestBase.java
index a701c90..4fc41c4 100644
--- a/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YarnTestBase.java
+++ b/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YarnTestBase.java
@@ -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);
                }
        }
 

Reply via email to