Skip to content

Commit

Permalink
[FLINK-8200][tests] Use TemporaryFolder in RocksDBAsyncSnapshotTest
Browse files Browse the repository at this point in the history
This closes apache#5122.
  • Loading branch information
wenlong.lwl authored and zentol committed Jan 8, 2018
1 parent 10aae99 commit 4ac348d
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.flink.api.common.typeutils.base.StringSerializer;
import org.apache.flink.api.common.typeutils.base.VoidSerializer;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.configuration.ConfigConstants;
import org.apache.flink.core.testutils.OneShotLatch;
import org.apache.flink.runtime.checkpoint.CheckpointMetaData;
import org.apache.flink.runtime.checkpoint.CheckpointMetrics;
Expand Down Expand Up @@ -60,7 +59,9 @@
import org.apache.flink.util.TestLogger;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
Expand All @@ -70,7 +71,6 @@
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RunnableFuture;
Expand All @@ -95,6 +95,12 @@
@SuppressWarnings("serial")
public class RocksDBAsyncSnapshotTest extends TestLogger {

/**
* Temporary fold for test.
*/
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();

/**
* This ensures that asynchronous state handles are actually materialized asynchronously.
*
Expand All @@ -119,7 +125,7 @@ public String getKey(String value) throws Exception {

StreamConfig streamConfig = testHarness.getStreamConfig();

File dbDir = new File(new File(ConfigConstants.DEFAULT_TASK_MANAGER_TMP_PATH, UUID.randomUUID().toString()), "state");
File dbDir = temporaryFolder.newFolder();

RocksDBStateBackend backend = new RocksDBStateBackend(new MemoryStateBackend());
backend.setDbStoragePath(dbDir.getAbsolutePath());
Expand Down Expand Up @@ -225,7 +231,7 @@ public String getKey(String value) throws Exception {

StreamConfig streamConfig = testHarness.getStreamConfig();

File dbDir = new File(new File(ConfigConstants.DEFAULT_TASK_MANAGER_TMP_PATH, UUID.randomUUID().toString()), "state");
File dbDir = temporaryFolder.newFolder();

BlockingStreamMemoryStateBackend memoryStateBackend = new BlockingStreamMemoryStateBackend();

Expand Down Expand Up @@ -333,7 +339,7 @@ public void testCleanupOfSnapshotsInFailureCase() throws Exception {

RocksDBStateBackend backend = new RocksDBStateBackend(stateBackend);

backend.setDbStoragePath("file:https:///tmp/foobar");
backend.setDbStoragePath(temporaryFolder.newFolder().toURI().toString());

AbstractKeyedStateBackend<Void> keyedStateBackend = backend.createKeyedStateBackend(
env,
Expand Down

0 comments on commit 4ac348d

Please sign in to comment.