Skip to content

Commit 6899080

Browse files
author
xiezhineng
committed
RBF: mv test to TestRouterRPCMultipleDestinationMountTableResolver
1 parent eb9adfe commit 6899080

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAllResolver.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.apache.hadoop.hdfs.server.federation.store.protocol.GetMountTableEntriesResponse;
4949
import org.apache.hadoop.hdfs.server.federation.store.records.MountTable;
5050
import org.apache.hadoop.hdfs.server.namenode.TestFileTruncate;
51-
import org.apache.hadoop.test.LambdaTestUtils;
5251
import org.junit.After;
5352
import org.junit.Before;
5453
import org.junit.Test;
@@ -206,23 +205,6 @@ private void testAll(final String path) throws Exception {
206205
assertDirsEverywhere(path, 9);
207206
assertFilesDistributed(path, 16);
208207

209-
// Test rename to not multi mount dir
210-
routerFs.mkdirs(new Path(path+ "/dir2/dir23"));
211-
routerFs.mkdirs(new Path(path+ "/dir2/dir23/dir_1"));
212-
routerFs.mkdirs(new Path(path+ "/dir2/dir23/dir_2"));
213-
LambdaTestUtils.intercept(IOException.class, "The number of" +
214-
" remote locations for both source and target should be same.",
215-
() ->{
216-
routerFs.rename(new Path(path+ "/dir2/dir23/dir_1"),
217-
new Path("/NOT_MULTI_MOUNT_DIR"));
218-
});
219-
routerFs.delete(new Path(path + "/dir2/dir23"), true);
220-
221-
// Removing a directory should remove it from every subcluster
222-
routerFs.delete(new Path(path + "/dir2/dir22/dir220"), true);
223-
assertDirsEverywhere(path, 8);
224-
assertFilesDistributed(path, 10);
225-
226208
// Removing all sub directories
227209
routerFs.delete(new Path(path + "/dir0"), true);
228210
routerFs.delete(new Path(path + "/dir1"), true);

hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRPCMultipleDestinationMountTableResolver.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,48 @@ public void testWriteWithUnavailableSubCluster() throws IOException {
720720
}
721721
}
722722

723+
/**
724+
* Test rename a dir from src dir (mapped to both ns0 and ns1) to ns0
725+
*/
726+
@Test
727+
public void testRenameWithMultiDestinations() throws Exception {
728+
//create a mount point with multiple destinations
729+
String srcDir = "/mount-source-dir";
730+
Path path = new Path(srcDir);
731+
Map<String, String> destMap = new HashMap<>();
732+
destMap.put("ns0", srcDir);
733+
destMap.put("ns1", srcDir);
734+
nnFs0.mkdirs(path);
735+
nnFs1.mkdirs(path);
736+
MountTable addEntry =
737+
MountTable.newInstance(srcDir, destMap);
738+
addEntry.setDestOrder(DestinationOrder.RANDOM);
739+
addEntry.setFaultTolerant(true);
740+
assertTrue(addMountTable(addEntry));
741+
742+
//create a mount point with a single destinations ns0
743+
String targetDir = "/ns0_test";
744+
nnFs0.mkdirs(new Path(targetDir));
745+
MountTable addDstEntry = MountTable.newInstance(targetDir,
746+
Collections.singletonMap("ns0", targetDir));
747+
assertTrue(addMountTable(addDstEntry));
748+
749+
//mkdir sub dirs in srcDir mapping ns0 & ns1
750+
routerFs.mkdirs(new Path(srcDir + "/dir1"));
751+
routerFs.mkdirs(new Path(srcDir + "/dir1/dir_11"));
752+
routerFs.mkdirs(new Path(srcDir + "/dir1/dir_12"));
753+
routerFs.mkdirs(new Path(targetDir));
754+
755+
//try to rename sub dir in srcDir (mapping to ns0 & ns1) to targetDir
756+
// (mapping ns0)
757+
LambdaTestUtils.intercept(IOException.class, "The number of" +
758+
" remote locations for both source and target should be same.",
759+
() -> {
760+
routerFs.rename(new Path(srcDir + "/dir1/dir_11"),
761+
new Path(targetDir));
762+
});
763+
}
764+
723765
/**
724766
* Test to verify rename operation on directories in case of multiple
725767
* destinations.

0 commit comments

Comments
 (0)