umamaheswararao commented on a change in pull request #2107:
URL: https://github.com/apache/hadoop/pull/2107#discussion_r448050802
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java
##########
@@ -765,4 +766,154 @@ public void
testMkdirsShouldReturnFalseWhenFallbackFSNotAvailable()
assertTrue(fsTarget.exists(test));
}
}
+
+ /**
+ * Tests that the create file should be successful when the parent directory
+ * is same as the existent fallback directory. The new file should be created
+ * in fallback.
+ */
+ @Test
+ public void testCreateFileOnInternalMountDirWithSameDirTreeExistInFallback()
+ throws Exception {
+ Configuration conf = new Configuration();
+ ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0",
+ new Path(targetTestRoot.toString()).toUri());
+ Path dir1 = new Path(targetTestRoot,
+ "fallbackDir/user1/hive/warehouse/partition-0");
+ fsTarget.mkdirs(dir1);
+ Path fallbackTarget = new Path(targetTestRoot, "fallbackDir");
+ ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri());
+
+ try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) {
+ Path p = new Path("/user1/hive/warehouse/test.file");
+ Path test = Path.mergePaths(fallbackTarget, p);
+ assertFalse(fsTarget.exists(test));
+ assertTrue(fsTarget.exists(test.getParent()));
+ vfs.createNewFile(p);
+ assertTrue(fsTarget.exists(test));
+ }
+ }
+
+ /**
+ * Tests the making of a new directory which is not matching to any of
+ * internal directory.
+ */
+ @Test
+ public void testCreateNewFileWithOutMatchingToMountDirOrFallbackDirPath()
+ throws Exception {
+ Configuration conf = new Configuration();
+ ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0",
+ new Path(targetTestRoot.toString()).toUri());
+ Path fallbackTarget = new Path(targetTestRoot, "fallbackDir");
+ fsTarget.mkdirs(fallbackTarget);
+ ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri());
+ try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) {
+ Path p = new Path("/user2/test.file");
+ Path test = Path.mergePaths(fallbackTarget, p);
Review comment:
Done. Thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]