flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [4/9] flink git commit: [FLINK-5817] [test] (followup) Fix temporary folder and temp file path generation
Date Mon, 20 Feb 2017 11:07:00 GMT
[FLINK-5817] [test] (followup) Fix temporary folder and temp file path generation

This makes sure the TemporaryFolder rule is already evaluated by the time
the temp files are generated.

This also injects a random parent directory to ensure that even for fix directory/file
names, the absolute path is randomized.


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

Branch: refs/heads/release-1.2
Commit: fc5a20a81f71b81850292bba2643ef37acfb6c2f
Parents: d1b148c
Author: Stephan Ewen <sewen@apache.org>
Authored: Sun Feb 19 16:21:07 2017 +0100
Committer: Stephan Ewen <sewen@apache.org>
Committed: Mon Feb 20 02:07:54 2017 +0100

----------------------------------------------------------------------
 .../org/apache/flink/test/util/AbstractTestBase.java   | 13 ++++++-------
 .../java/org/apache/flink/test/util/TestBaseUtils.java |  4 ++++
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/fc5a20a8/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/AbstractTestBase.java
----------------------------------------------------------------------
diff --git a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/AbstractTestBase.java
b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/AbstractTestBase.java
index 544d473..be9b0b7 100644
--- a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/AbstractTestBase.java
+++ b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/AbstractTestBase.java
@@ -24,7 +24,7 @@ import com.google.common.io.Files;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster;
 
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.rules.TemporaryFolder;
 
 import scala.concurrent.duration.FiniteDuration;
@@ -49,8 +49,8 @@ public abstract class AbstractTestBase extends TestBaseUtils {
 
 	protected int numTaskManagers = 1;
 
-	@Rule
-	public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+	@ClassRule
+	public static final TemporaryFolder temporaryFolder = new TemporaryFolder();
 
 
 	/** The mini cluster that runs the test programs */
@@ -106,12 +106,12 @@ public abstract class AbstractTestBase extends TestBaseUtils {
 	// --------------------------------------------------------------------------------------------
 
 	public String getTempDirPath(String dirName) throws IOException {
-		File f = temporaryFolder.newFolder(dirName);
+		File f = createAndRegisterTempFile(dirName);
 		return f.toURI().toString();
 	}
 
 	public String getTempFilePath(String fileName) throws IOException {
-		File f = temporaryFolder.newFile(fileName);
+		File f = createAndRegisterTempFile(fileName);
 		return f.toURI().toString();
 	}
 
@@ -122,7 +122,6 @@ public abstract class AbstractTestBase extends TestBaseUtils {
 	}
 
 	public File createAndRegisterTempFile(String fileName) throws IOException {
-		return temporaryFolder.newFile(fileName);
+		return new File(temporaryFolder.newFolder(), fileName);
 	}
-
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/fc5a20a8/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
----------------------------------------------------------------------
diff --git a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
index 8431226..cc7c0e2 100644
--- a/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
+++ b/flink-test-utils-parent/flink-test-utils/src/main/java/org/apache/flink/test/util/TestBaseUtils.java
@@ -74,6 +74,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import static org.apache.flink.util.Preconditions.checkArgument;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -283,6 +285,8 @@ public class TestBaseUtils extends TestLogger {
 			String resultPath,
 			String[] excludePrefixes,
 			boolean inOrderOfFiles) throws IOException {
+		
+		checkArgument(resultPath != null, "resultPath cannot be be null");
 
 		final BufferedReader[] readers = getResultReader(resultPath, excludePrefixes, inOrderOfFiles);
 		try {


Mime
View raw message