umamaheswararao commented on a change in pull request #2088:
URL: https://github.com/apache/hadoop/pull/2088#discussion_r444024934
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java
##########
@@ -359,4 +361,249 @@ public void
testListingWithFallbackLinkWithSameMountDirectories()
assertTrue(vfs.getFileStatus(childDir).isDirectory());
}
}
+
+ /**
+ * Tests ListStatus on non-link parent with fallback configured.
+ *
=============================Example.======================================
+ * ===== Fallback path tree =============== Mount Path Tree
==================
+ *
===========================================================================
+ * * / ***** /
*****************
+ * * / ***** /
*****************
+ * * user1 ***** user1
*****************
+ * * / ***** /
*****************
+ * * hive ***** hive
*****************
+ * * / \ ***** /
*****************
+ * * warehouse warehouse1 ***** warehouse
*****************
+ * * (-rwxr--r--) ***** (-r-xr--r--)
*****************
+ * * / ***** /
*****************
+ * * partition-0 ***** partition-0
*****************
+ *
===========================================================================
+ *
===========================================================================
+ * *** ls /user1/hive
*********
+ * *** viewfs://default/user1/hive/warehouse (-rwxr--r--)
*********
+ * *** viewfs://default/user1/hive/warehouse1
*********
+ *
===========================================================================
+ */
+ @Test
+ public void testListingWithFallbackLinkWithSameMountDirectoryTree()
+ throws Exception {
+ Configuration conf = new Configuration();
+ conf.setBoolean(Constants.CONFIG_VIEWFS_MOUNT_LINKS_AS_SYMLINKS, false);
+ ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0",
+ new Path(targetTestRoot.toString()).toUri());
+ // Creating multiple directories path under the fallback directory.
+ // "/user1/hive/warehouse/partition-0" directory already exists as
+ // configured mount point.
+ Path dir1 = new Path(targetTestRoot,
+ "fallbackDir/user1/hive/warehouse/partition-0");
+ Path dir2 = new Path(targetTestRoot, "fallbackDir/user1/hive/warehouse1");
+ fsTarget.mkdirs(dir1);
+ fsTarget.mkdirs(dir2);
+ fsTarget.setPermission(new Path(targetTestRoot, "fallbackDir/user1/hive/"),
+ FsPermission.valueOf("-rwxr--r--"));
+ URI viewFsUri = new URI(FsConstants.VIEWFS_SCHEME,
+ Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, "/", null, null);
+
+ HashSet<Path> beforeFallback = new HashSet<>();
+ try (FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ for (FileStatus stat : vfs
+ .listStatus(new Path(viewFsUri.toString(), "/user1/hive/"))) {
+ beforeFallback.add(stat.getPath());
+ }
+ }
+ ConfigUtil
+ .addLinkFallback(conf, new Path(targetTestRoot,
"fallbackDir").toUri());
+
+ try (FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ HashSet<Path> afterFallback = new HashSet<>();
+ for (FileStatus stat : vfs
+ .listStatus(new Path(viewFsUri.toString(), "/user1/hive/"))) {
+ afterFallback.add(stat.getPath());
+ if (dir1.getName().equals(stat.getPath().getName())) {
+ // make sure fallback dir listed out with correct permissions, but
not
+ // with link permissions.
+ assertEquals(FsPermission.valueOf("-rwxr--r--"),
+ stat.getPermission());
+ }
+ }
+ //
+ //viewfs://default/user1/hive/warehouse
+ afterFallback.removeAll(beforeFallback);
+ assertTrue("The same directory name in fallback link should be shaded",
Review comment:
done.
----------------------------------------------------------------
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]