|
@@ -18,6 +18,8 @@
|
|
|
package org.apache.hadoop.hdfs.server.namenode;
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
+import java.util.AbstractMap;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -226,10 +228,19 @@ public class TestDeleteRace {
|
|
|
private void testDeleteAndCommitBlockSynchronizationRace(boolean hasSnapshot)
|
|
|
throws Exception {
|
|
|
LOG.info("Start testing, hasSnapshot: " + hasSnapshot);
|
|
|
- final String testPaths[] = {
|
|
|
- "/test-file",
|
|
|
- "/testdir/testdir1/test-file"
|
|
|
- };
|
|
|
+ ArrayList<AbstractMap.SimpleImmutableEntry<String, Boolean>> testList =
|
|
|
+ new ArrayList<AbstractMap.SimpleImmutableEntry<String, Boolean>> ();
|
|
|
+ testList.add(
|
|
|
+ new AbstractMap.SimpleImmutableEntry<String, Boolean>("/test-file", false));
|
|
|
+ testList.add(
|
|
|
+ new AbstractMap.SimpleImmutableEntry<String, Boolean>("/test-file1", true));
|
|
|
+ testList.add(
|
|
|
+ new AbstractMap.SimpleImmutableEntry<String, Boolean>(
|
|
|
+ "/testdir/testdir1/test-file", false));
|
|
|
+ testList.add(
|
|
|
+ new AbstractMap.SimpleImmutableEntry<String, Boolean>(
|
|
|
+ "/testdir/testdir1/test-file1", true));
|
|
|
+
|
|
|
final Path rootPath = new Path("/");
|
|
|
final Configuration conf = new Configuration();
|
|
|
// Disable permissions so that another user can recover the lease.
|
|
@@ -247,8 +258,11 @@ public class TestDeleteRace {
|
|
|
|
|
|
DistributedFileSystem fs = cluster.getFileSystem();
|
|
|
int stId = 0;
|
|
|
- for (String testPath : testPaths) {
|
|
|
- LOG.info("test on " + testPath + " snapshot: " + hasSnapshot);
|
|
|
+ for(AbstractMap.SimpleImmutableEntry<String, Boolean> stest : testList) {
|
|
|
+ String testPath = stest.getKey();
|
|
|
+ Boolean mkSameDir = stest.getValue();
|
|
|
+ LOG.info("test on " + testPath + " mkSameDir: " + mkSameDir
|
|
|
+ + " snapshot: " + hasSnapshot);
|
|
|
Path fPath = new Path(testPath);
|
|
|
//find grandest non-root parent
|
|
|
Path grandestNonRootParent = fPath;
|
|
@@ -304,7 +318,11 @@ public class TestDeleteRace {
|
|
|
|
|
|
LOG.info("Deleting recursively " + grandestNonRootParent);
|
|
|
fs.delete(grandestNonRootParent, true);
|
|
|
-
|
|
|
+ if (mkSameDir && !grandestNonRootParent.toString().equals(testPath)) {
|
|
|
+ LOG.info("Recreate dir " + grandestNonRootParent + " testpath: "
|
|
|
+ + testPath);
|
|
|
+ fs.mkdirs(grandestNonRootParent);
|
|
|
+ }
|
|
|
delayer.proceed();
|
|
|
LOG.info("Now wait for result");
|
|
|
delayer.waitForResult();
|