提交 d92aeb7a 编写于 作者: M Maximilian Michels

[FLINK-3864][yarn] check for prohibited strings in log output

- enables actual checking of output which didn't work until now
- uses regexp to check for prohibited strings

This closes #2125
上级 a5aa4e11
......@@ -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()");
}
......
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册