abhishekdas99 commented on a change in pull request #2010:
URL: https://github.com/apache/hadoop/pull/2010#discussion_r424754297
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java
##########
@@ -261,4 +261,53 @@ public void testConfLinkFallbackWithMountPoint() throws
Exception {
e.getMessage().contains(expectedErrorMsg));
}
}
+
+ @Test
+ public void testListingWithFallbackLink() throws Exception {
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/dir1"));
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/dir2"));
+ String clusterName = Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE;
+ URI viewFsUri = new URI(FsConstants.VIEWFS_SCHEME, clusterName,
+ "/", null, null);
+
+ int itemCount = 0;
+ try(FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ itemCount = vfs.listStatus(new Path(viewFsUri.toString())).length;
+ }
+
+ ConfigUtil.addLinkFallback(conf, clusterName,
+ new Path(targetTestRoot, "fallbackDir").toUri());
+
+ try (FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ FileStatus[] statuses = vfs.listStatus(new Path(viewFsUri.toString()));
+ assertTrue("Listing didn't include fallback link",
+ statuses.length == itemCount + 2);
+ }
+ }
+
+ @Test
+ public void testListingWithFallbackLinkWithSameMountDirectories()
+ throws Exception {
+ // Creating two directories under the fallback dircetory.
+ // user directory already exists as configured mount point.
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/user"));
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/user1"));
+ String clusterName = Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE;
+ URI viewFsUri = new URI(FsConstants.VIEWFS_SCHEME, clusterName,
+ "/", null, null);
+
+ int itemCount = 0;
+ try(FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ itemCount = vfs.listStatus(new Path(viewFsUri.toString())).length;
+ }
+
+ ConfigUtil.addLinkFallback(conf, clusterName,
+ new Path(targetTestRoot, "fallbackDir").toUri());
+
+ try (FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ FileStatus[] statuses = vfs.listStatus(new Path(viewFsUri.toString()));
+ assertTrue("The same directory name in fallback link should be shaded",
Review comment:
Added a check to make sure the fallback path is not the one which has
the same naem as the mount path.
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java
##########
@@ -261,4 +261,53 @@ public void testConfLinkFallbackWithMountPoint() throws
Exception {
e.getMessage().contains(expectedErrorMsg));
}
}
+
+ @Test
+ public void testListingWithFallbackLink() throws Exception {
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/dir1"));
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/dir2"));
+ String clusterName = Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE;
+ URI viewFsUri = new URI(FsConstants.VIEWFS_SCHEME, clusterName,
+ "/", null, null);
+
+ int itemCount = 0;
+ try(FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ itemCount = vfs.listStatus(new Path(viewFsUri.toString())).length;
+ }
+
+ ConfigUtil.addLinkFallback(conf, clusterName,
+ new Path(targetTestRoot, "fallbackDir").toUri());
+
+ try (FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ FileStatus[] statuses = vfs.listStatus(new Path(viewFsUri.toString()));
+ assertTrue("Listing didn't include fallback link",
+ statuses.length == itemCount + 2);
+ }
+ }
+
+ @Test
+ public void testListingWithFallbackLinkWithSameMountDirectories()
+ throws Exception {
+ // Creating two directories under the fallback dircetory.
+ // user directory already exists as configured mount point.
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/user"));
+ fsTarget.mkdirs(new Path(targetTestRoot, "fallbackDir/user1"));
+ String clusterName = Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE;
+ URI viewFsUri = new URI(FsConstants.VIEWFS_SCHEME, clusterName,
+ "/", null, null);
+
+ int itemCount = 0;
+ try(FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ itemCount = vfs.listStatus(new Path(viewFsUri.toString())).length;
+ }
+
+ ConfigUtil.addLinkFallback(conf, clusterName,
+ new Path(targetTestRoot, "fallbackDir").toUri());
+
+ try (FileSystem vfs = FileSystem.get(viewFsUri, conf)) {
+ FileStatus[] statuses = vfs.listStatus(new Path(viewFsUri.toString()));
+ assertTrue("The same directory name in fallback link should be shaded",
Review comment:
Added a check to make sure the fallback path is not the one which has
the same name as the mount path.
----------------------------------------------------------------
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]