daryn-sharp commented on a change in pull request #2919:
URL: https://github.com/apache/hadoop/pull/2919#discussion_r617656673
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNestedEncryptionZones.java
##########
@@ -210,6 +214,80 @@ public void testNestedEZWithRoot() throws Exception {
"File not in trash : " + nestedTrashFile, fs.exists(nestedTrashFile));
}
+ @Test(timeout = 60000)
+ public void testRenameBetweenEncryptionZones() throws Exception {
+ String key1 = TOP_EZ_KEY;
+ String key2 = NESTED_EZ_KEY;
+ Path top = new Path("/dir");
+ Path ez1 = new Path(top, "ez1");
+ Path ez2 = new Path(top, "ez2");
+ Path ez3 = new Path(top, "ez3");
+ Path p = new Path(ez1, "file");
+ fs.mkdirs(ez1, FsPermission.getDirDefault());
+ fs.mkdirs(ez2, FsPermission.getDirDefault());
+ fs.mkdirs(ez3, FsPermission.getDirDefault());
+ fs.createEncryptionZone(ez1, key1);
+ fs.createEncryptionZone(ez2, key2);
+ fs.createEncryptionZone(ez3, key1);
+ fs.create(p).close();
+
+ // cannot rename between 2 EZs with different keys.
+ try {
+ fs.rename(p, new Path(ez2, "file"));
+ } catch (RemoteException re) {
+ Assert.assertEquals(
+ p + " can't be moved from encryption zone " + ez1 +
+ " to encryption zone " + ez2 + ".",
+ re.getMessage().split("\n")[0]);
+ }
+ // can rename between 2 EZs with the same key.
+ Assert.assertTrue(fs.rename(p, new Path(ez3, "file")));
+ }
+
+ @Test(timeout = 60000)
+ public void testRemoveEncryptionZoneWithAncestorKey() throws Exception {
+ removeEZDirUnderAncestor(TOP_EZ_KEY);
+ }
+
+ @Test(timeout = 60000)
+ public void testRemoveEncryptionZoneWithNoAncestorKey() throws Exception {
+ removeEZDirUnderAncestor(null);
+ }
+
+ private void removeEZDirUnderAncestor(String parentKey) throws Exception {
Review comment:
As further clarification, the use case for removing a nested EZ that
shares the same key is: user wants to test EZ on a subtree of a large directory
so they request an EZ on /big-dir/I-want-to-test-EZ/. They are satisfied it
works so they request the EZ to be moved up to /big-dir to cover the entire
tree.
The current impl won't allow the EZ xattr on /big-dir/I-want-to-test-EZ to
be removed – even though it shares the same key with the EZ on /big-dir. It
also won't allow moving files from /big-dir/I-want-to-test-EZ to other places
in /big-dir – even though they share the same key.
--
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]