virajith commented on a change in pull request #2100:
URL: https://github.com/apache/hadoop/pull/2100#discussion_r445808907
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeWithHdfsScheme.java
##########
@@ -235,6 +237,57 @@ public void testListStatusOnNonMountedPath() throws
Exception {
Assert.fail("It should fail as no mount link with /nonMount");
}
}
+ /**
+ * Create mount links as follows
+ * hdfs://localhost:xxx/HDFSUser --> hdfs://localhost:xxx/HDFSUser/
+ * hdfs://localhost:xxx/local --> file://TEST_ROOT_DIR/root/
+ * and check that "viewfs:/" paths work without specifying authority when
then default mount table name
Review comment:
fixed.
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeWithHdfsScheme.java
##########
@@ -235,6 +237,57 @@ public void testListStatusOnNonMountedPath() throws
Exception {
Assert.fail("It should fail as no mount link with /nonMount");
}
}
+ /**
+ * Create mount links as follows
+ * hdfs://localhost:xxx/HDFSUser --> hdfs://localhost:xxx/HDFSUser/
+ * hdfs://localhost:xxx/local --> file://TEST_ROOT_DIR/root/
+ * and check that "viewfs:/" paths work without specifying authority when
then default mount table name
+ * is set correctly.
+ */
+ @Test
+ public void testAccessViewFsPathWithoutAuthority() throws Exception {
+ final Path hdfsTargetPath = new Path(defaultFSURI + HDFS_USER_FOLDER);
+ addMountLinks(defaultFSURI.getAuthority(),
+ new String[] {HDFS_USER_FOLDER, LOCAL_FOLDER },
+ new String[] {hdfsTargetPath.toUri().toString(),
+ localTargetDir.toURI().toString() },
+ conf);
+
+ // /HDFSUser/test
+ Path hdfsDir = new Path(HDFS_USER_FOLDER + "/test");
+ // /local/test
+ Path localDir = new Path(LOCAL_FOLDER + "/test");
+
+ try (ViewFileSystemOverloadScheme fs = (ViewFileSystemOverloadScheme)
FileSystem.get(conf)) {
+ fs.mkdirs(hdfsDir); // /HDFSUser/testfile
+ fs.mkdirs(localDir); // /local/test
+ }
+
+ FileStatus[] expectedStatus;
+ try (FileSystem fs = FileSystem.get(conf)) {
+ expectedStatus = fs.listStatus(new Path("/"));
+ }
+
+ // check for viewfs path without authority
+ Path viewFsRootPath = new Path("viewfs:/");
+ try {
+ viewFsRootPath.getFileSystem(conf);
+ Assert.fail("Mount table with authority default should not be
initialized");
+ } catch (IOException e) {
+ assertTrue(e.getMessage().contains("Empty Mount table in config for
viewfs://default/"));
+ }
+
+ // set the name of the default mount table here and subsequent calls
should succeed.
+ conf.set(Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE_NAME_KEY,
defaultFSURI.getAuthority());
+
+ try (FileSystem fs = viewFsRootPath.getFileSystem(conf)) {
+ FileStatus[] status = fs.listStatus(viewFsRootPath);
+ // compare only the final components of the paths as full paths have
different schemes (hdfs:/ vs. viewfs:/).
+ List<String> expectedPaths = Arrays.stream(expectedStatus).map(s ->
s.getPath().getName()).collect(Collectors.toList());
Review comment:
fixed.
----------------------------------------------------------------
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]