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 2017/05/25 11:06:40 UTC

[3/4] flink git commit: [FLINK-6320] fix unit test failing sometimes when deleting a temp directory

[FLINK-6320] fix unit test failing sometimes when deleting a temp directory

This closes #3966.


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

Branch: refs/heads/release-1.3
Commit: d1ae1cd73665c6870111a1d1d413e41dd77da095
Parents: 4767f84
Author: Nico Kruber <ni...@data-artisans.com>
Authored: Mon May 22 16:31:08 2017 +0200
Committer: zentol <ch...@apache.org>
Committed: Wed May 24 16:52:02 2017 +0200

----------------------------------------------------------------------
 .../JobManagerHAJobGraphRecoveryITCase.java     | 36 ++++++--------------
 1 file changed, 10 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/d1ae1cd7/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAJobGraphRecoveryITCase.java
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAJobGraphRecoveryITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAJobGraphRecoveryITCase.java
index 052195a..80b8e18 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAJobGraphRecoveryITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/JobManagerHAJobGraphRecoveryITCase.java
@@ -49,7 +49,6 @@ import org.apache.flink.runtime.taskmanager.TaskManager;
 import org.apache.flink.runtime.testingUtils.TestingCluster;
 import org.apache.flink.runtime.testingUtils.TestingUtils;
 import org.apache.flink.runtime.testtasks.BlockingNoOpInvokable;
-import org.apache.flink.runtime.testutils.CommonTestUtils;
 import org.apache.flink.runtime.testutils.JobManagerActorTestUtils;
 import org.apache.flink.runtime.testutils.JobManagerProcess;
 import org.apache.flink.runtime.testutils.ZooKeeperTestUtils;
@@ -58,7 +57,9 @@ import org.apache.flink.util.TestLogger;
 import org.apache.zookeeper.data.Stat;
 import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 import scala.Option;
 import scala.Some;
 import scala.Tuple2;
@@ -68,7 +69,6 @@ import scala.concurrent.duration.Deadline;
 import scala.concurrent.duration.FiniteDuration;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.Collection;
 import java.util.Queue;
 import java.util.UUID;
@@ -88,32 +88,16 @@ public class JobManagerHAJobGraphRecoveryITCase extends TestLogger {
 
 	private final static FiniteDuration TestTimeOut = new FiniteDuration(5, TimeUnit.MINUTES);
 
-	private static final File FileStateBackendBasePath;
-
-	static {
-		try {
-			FileStateBackendBasePath = CommonTestUtils.createTempDirectory();
-		}
-		catch (IOException e) {
-			throw new RuntimeException("Error in test setup. Could not create directory.", e);
-		}
-	}
+	@Rule
+	public TemporaryFolder tempFolder = new TemporaryFolder();
 
 	@AfterClass
 	public static void tearDown() throws Exception {
 		ZooKeeper.shutdown();
-
-		if (FileStateBackendBasePath != null) {
-			FileUtils.deleteDirectory(FileStateBackendBasePath);
-		}
 	}
 
 	@Before
 	public void cleanUp() throws Exception {
-		if (FileStateBackendBasePath != null) {
-			FileUtils.cleanDirectory(FileStateBackendBasePath);
-		}
-
 		ZooKeeper.deleteAll();
 	}
 
@@ -125,7 +109,7 @@ public class JobManagerHAJobGraphRecoveryITCase extends TestLogger {
 	@Test
 	public void testJobPersistencyWhenJobManagerShutdown() throws Exception {
 		Configuration config = ZooKeeperTestUtils.createZooKeeperHAConfig(
-				ZooKeeper.getConnectString(), FileStateBackendBasePath.getPath());
+				ZooKeeper.getConnectString(), tempFolder.getRoot().getPath());
 
 		// Configure the cluster
 		config.setInteger(ConfigConstants.LOCAL_NUMBER_JOB_MANAGER, 1);
@@ -172,7 +156,7 @@ public class JobManagerHAJobGraphRecoveryITCase extends TestLogger {
 	@Test
 	public void testClientNonDetachedListeningBehaviour() throws Exception {
 		Configuration config = ZooKeeperTestUtils.createZooKeeperHAConfig(
-				ZooKeeper.getConnectString(), FileStateBackendBasePath.getPath());
+				ZooKeeper.getConnectString(), tempFolder.getRoot().getPath());
 
 		// Test actor system
 		ActorSystem testSystem = null;
@@ -397,10 +381,10 @@ public class JobManagerHAJobGraphRecoveryITCase extends TestLogger {
 	/**
 	 * Fails the test if the recovery state (file state backend and ZooKeeper) is not clean.
 	 */
-	private static void verifyCleanRecoveryState(Configuration config) throws Exception {
+	private void verifyCleanRecoveryState(Configuration config) throws Exception {
 		// File state backend empty
 		Collection<File> stateHandles = FileUtils.listFiles(
-				FileStateBackendBasePath, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+				tempFolder.getRoot(), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
 
 		if (!stateHandles.isEmpty()) {
 			fail("File state backend is not clean: " + stateHandles);
@@ -429,10 +413,10 @@ public class JobManagerHAJobGraphRecoveryITCase extends TestLogger {
 	/**
 	 * Fails the test if the recovery state (file state backend and ZooKeeper) has been cleaned.
 	 */
-	private static void verifyRecoveryState(Configuration config) throws Exception {
+	private void verifyRecoveryState(Configuration config) throws Exception {
 		// File state backend empty
 		Collection<File> stateHandles = FileUtils.listFiles(
-			FileStateBackendBasePath, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+				tempFolder.getRoot(), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
 
 		if (stateHandles.isEmpty()) {
 			fail("File state backend has been cleaned: " + stateHandles);