umamaheswararao commented on a change in pull request #3353:
URL: https://github.com/apache/hadoop/pull/3353#discussion_r698559465
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestViewDistributedFileSystem.java
##########
@@ -89,4 +91,30 @@ public void testEmptyDelegationToken() throws IOException {
}
}
}
+
+ @Test
+ public void testRenameWithOptions() throws IOException {
+ Configuration conf = getTestConfiguration();
+ MiniDFSCluster cluster = null;
+ try {
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
+ URI defaultUri =
+ URI.create(conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY));
+ conf.set("fs.viewfs.mounttable." + defaultUri.getHost() +
".linkFallback",
+ defaultUri.toString());
+ conf.setLong(CommonConfigurationKeys.FS_TRASH_INTERVAL_KEY, 30000);
+ try (ViewDistributedFileSystem fileSystem =
+ (ViewDistributedFileSystem) FileSystem.get(conf)) {
+ final Path testDir = new Path("/test");
+ final Path renameDir = new Path("/testRename");
+ fileSystem.mkdirs(testDir);
+ fileSystem.rename(testDir, renameDir, Options.Rename.TO_TRASH);
+ Assert.assertTrue(fileSystem.exists(renameDir));
Review comment:
@jojochuang The root cause for this issue is not really due to trash
right. Issue is with rename with options API itself. Irrespective of the
options flag, Issue comes. So, just passed To_trash flag as started debug
through that API. In trash case the target dir formed by TrashDefaultPolicy. In
this test I am giving my own target. Here rename responsibility is to do raname
to the given path. So, I am asserting to my given dir. NN using this flags to
do some additional checks at server.
ex: In FSDirRenameOp
```
if(renameToTrash) {
// if destination is the trash directory,
// besides the permission check on "rename"
// we need to enforce the check for "delete"
// otherwise, it would expose a
// security hole that stuff moved to trash
// will be deleted by superuser
fsd.checkPermission(pc, srcIIP, false, null, FsAction.WRITE, null,
FsAction.ALL, true);
} else {
// Rename does not operate on link targets
// Do not resolveLink when checking permissions of src and dst
// Check write access to parent of src
fsd.checkPermission(pc, srcIIP, false, null, FsAction.WRITE, null,
null, false);
}
```
Let me know if you are still concern with the flag, I can change it to
overwrite flag. We can also add moveToTrash API ( Once we know the root cause,
I thought my test should focus on cause.) I tested manually trash and it worked.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]