You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2021/02/16 13:58:52 UTC
[flink] branch master updated: [FLINK-21339][tests] Enable and fix
ExceptionUtilsITCase
This is an automated email from the ASF dual-hosted git repository.
chesnay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new 29b4dce [FLINK-21339][tests] Enable and fix ExceptionUtilsITCase
29b4dce is described below
commit 29b4dceec5e03eda646eaa3437987a4ca14b626b
Author: Chesnay Schepler <ch...@apache.org>
AuthorDate: Thu Feb 11 18:02:51 2021 +0100
[FLINK-21339][tests] Enable and fix ExceptionUtilsITCase
---
.../java/org/apache/flink/test/util/TestProcessBuilder.java | 13 ++++++++++++-
...ExceptionUtilsITCases.java => ExceptionUtilsITCase.java} | 4 +++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestProcessBuilder.java b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestProcessBuilder.java
index 5d2c595..5771e6f 100644
--- a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestProcessBuilder.java
+++ b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestProcessBuilder.java
@@ -44,6 +44,8 @@ public class TestProcessBuilder {
private MemorySize jvmMemory = MemorySize.parse("80mb");
+ private boolean withCleanEnvironment = false;
+
public TestProcessBuilder(String mainClass) throws IOException {
File tempLogFile =
File.createTempFile(getClass().getSimpleName() + "-", "-log4j.properties");
@@ -70,7 +72,11 @@ public class TestProcessBuilder {
StringWriter processOutput = new StringWriter();
StringWriter errorOutput = new StringWriter();
- Process process = new ProcessBuilder(commands).start();
+ final ProcessBuilder processBuilder = new ProcessBuilder(commands);
+ if (withCleanEnvironment) {
+ processBuilder.environment().clear();
+ }
+ Process process = processBuilder.start();
new PipeForwarder(process.getInputStream(), processOutput);
new PipeForwarder(process.getErrorStream(), errorOutput);
@@ -100,6 +106,11 @@ public class TestProcessBuilder {
return this;
}
+ public TestProcessBuilder withCleanEnvironment() {
+ withCleanEnvironment = true;
+ return this;
+ }
+
/** {@link Process} with it's {@code processOutput}. */
public static class TestProcess {
private final Process process;
diff --git a/flink-tests/src/test/java/org/apache/flink/runtime/util/ExceptionUtilsITCases.java b/flink-tests/src/test/java/org/apache/flink/runtime/util/ExceptionUtilsITCase.java
similarity index 97%
rename from flink-tests/src/test/java/org/apache/flink/runtime/util/ExceptionUtilsITCases.java
rename to flink-tests/src/test/java/org/apache/flink/runtime/util/ExceptionUtilsITCase.java
index 0ffabaf..611e4bc 100644
--- a/flink-tests/src/test/java/org/apache/flink/runtime/util/ExceptionUtilsITCases.java
+++ b/flink-tests/src/test/java/org/apache/flink/runtime/util/ExceptionUtilsITCase.java
@@ -43,7 +43,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/** Tests for {@link ExceptionUtils} which require to spawn JVM process and set JVM memory args. */
-public class ExceptionUtilsITCases extends TestLogger {
+public class ExceptionUtilsITCase extends TestLogger {
private static final int DIRECT_MEMORY_SIZE = 10 * 1024; // 10Kb
private static final int DIRECT_MEMORY_ALLOCATION_PAGE_SIZE = 1024; // 1Kb
private static final int DIRECT_MEMORY_PAGE_NUMBER =
@@ -87,6 +87,8 @@ public class ExceptionUtilsITCases extends TestLogger {
for (String arg : args) {
taskManagerProcessBuilder.addMainClassArg(arg);
}
+ // JAVA_TOOL_OPTIONS is configured on CI which would affect the process output
+ taskManagerProcessBuilder.withCleanEnvironment();
TestProcess p = taskManagerProcessBuilder.start();
p.getProcess().waitFor();
assertThat(p.getErrorOutput().toString().trim(), is(""));