From a87249b64055e9e16c11025e545f657218e9f16a Mon Sep 17 00:00:00 2001 From: Maximilian Michels Date: Fri, 17 Jun 2016 14:29:17 +0200 Subject: [PATCH] [FLINK-3864] Yarn tests don't check for prohibited strings in log output --- .../yarn/YARNSessionCapacitySchedulerITCase.java | 8 ++++---- .../java/org/apache/flink/yarn/YarnTestBase.java | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YARNSessionCapacitySchedulerITCase.java b/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YARNSessionCapacitySchedulerITCase.java index 826a0863cb224..513a9fc0b9415 100644 --- a/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YARNSessionCapacitySchedulerITCase.java +++ b/flink-yarn-tests/src/test/java/org/apache/flink/yarn/YARNSessionCapacitySchedulerITCase.java @@ -120,8 +120,8 @@ public void perJobYarnCluster() { "-ytm", "1024", exampleJarLocation.getAbsolutePath()}, /* test succeeded after this string */ "Job execution complete", - /* prohibited strings: (we want to see (2/2)) */ - new String[]{"System.out)(1/1) switched to FINISHED "}, + /* prohibited strings: (we want to see "DataSink (...) (2/2) switched to FINISHED") */ + new String[]{"DataSink \\(.*\\) \\(1/1\\) switched to FINISHED"}, RunTypes.CLI_FRONTEND, 0, true); LOG.info("Finished perJobYarnCluster()"); } @@ -360,8 +360,8 @@ public void perJobYarnClusterWithParallelism() { "-ytm", "1024", exampleJarLocation.getAbsolutePath()}, /* test succeeded after this string */ "Job execution complete", - /* prohibited strings: (we want to see (2/2)) */ - new String[]{"System.out)(1/1) switched to FINISHED "}, + /* prohibited strings: (we want to see "DataSink (...) (2/2) switched to FINISHED") */ + new String[]{"DataSink \\(.*\\) \\(1/1\\) switched to FINISHED"}, RunTypes.CLI_FRONTEND, 0, true); LOG.info("Finished perJobYarnClusterWithParallelism()"); } 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 4de964abcdecc..6028d9834f910 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 @@ -60,6 +60,7 @@ import java.util.Map; import java.util.Scanner; import java.util.concurrent.ConcurrentMap; +import java.util.regex.Pattern; /** @@ -446,12 +447,12 @@ protected void runWithArgs(String[] args, String terminateAfterString, String[] * The test has been passed once the "terminateAfterString" has been seen. * @param args Command line arguments for the runner * @param terminateAfterString the runner is searching the stdout and stderr for this string. as soon as it appears, the test has passed - * @param failOnStrings The runner is searching stdout and stderr for the strings specified here. If one appears, the test has failed + * @param failOnPatterns The runner is searching stdout and stderr for the pattern (regexp) specified here. If one appears, the test has failed * @param type Set the type of the runner * @param returnCode Expected return code from the runner. * @param checkLogForTerminateString If true, the runner checks also the log4j logger for the terminate string */ - protected void runWithArgs(String[] args, String terminateAfterString, String[] failOnStrings, RunTypes type, int returnCode, boolean checkLogForTerminateString) { + protected void runWithArgs(String[] args, String terminateAfterString, String[] failOnPatterns, RunTypes type, int returnCode, boolean checkLogForTerminateString) { LOG.info("Running with args {}", Arrays.toString(args)); outContent = new ByteArrayOutputStream(); @@ -473,10 +474,10 @@ protected void runWithArgs(String[] args, String terminateAfterString, String[] sleep(1000); String outContentString = outContent.toString(); String errContentString = errContent.toString(); - if(failOnStrings != null) { - for (String failOnString : failOnStrings) { - if (outContentString.contains(failOnString) - || errContentString.contains(failOnString)) { + if(failOnPatterns != null) { + for (String failOnString : failOnPatterns) { + Pattern pattern = Pattern.compile(failOnString); + if (pattern.matcher(outContentString).find() || pattern.matcher(errContentString).find()) { LOG.warn("Failing test. Output contained illegal string '" + failOnString + "'"); sendOutput(); // stopping runner.