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 826a0863cb2244f4e35a39d7adb9361a584b2039..513a9fc0b94158f4fb2054f43ae4a22cdaac7801 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 class YARNSessionCapacitySchedulerITCase extends YarnTestBase { "-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 class YARNSessionCapacitySchedulerITCase extends YarnTestBase { "-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 4de964abcdecc09ae089b43fd8befaafeae90eec..6028d9834f910e9be8ed010babca90e45e4f6234 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.List; import java.util.Map; import java.util.Scanner; import java.util.concurrent.ConcurrentMap; +import java.util.regex.Pattern; /** @@ -446,12 +447,12 @@ public abstract class YarnTestBase extends TestLogger { * 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 @@ public abstract class YarnTestBase extends TestLogger { 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.