ctubbsii commented on code in PR #5334:
URL: https://github.com/apache/accumulo/pull/5334#discussion_r2012885226


##########
test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java:
##########
@@ -350,4 +353,64 @@ public void testCloneMetadataTable() {
           "mc1", CloneConfiguration.empty()));
     }
   }
+
+  @Test
+  public void testCloneIntoDiffNamespace() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+      client.tableOperations().create(tableName);
+      client.namespaceOperations().create("new");
+      client.tableOperations().clone(tableName, "new." + tableName, 
CloneConfiguration.empty());
+    }
+  }
+
+  @Test
+  public void testCloneIntoDiffNamespaceDoesntExist() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+      client.tableOperations().create(tableName);
+      assertThrows(AccumuloException.class, () -> 
client.tableOperations().clone(tableName,
+          "missing." + tableName, CloneConfiguration.empty()));
+    }
+  }
+
+  @Test
+  public void testCloneIntoAccumuloNamespace() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String tableName = getUniqueNames(1)[0];
+      client.tableOperations().create(tableName);
+      assertThrows(AccumuloException.class, () -> 
client.tableOperations().clone(tableName,
+          "accumulo." + tableName, CloneConfiguration.empty()));
+    }
+  }
+
+  @Test
+  public void testCloneNamespacePermissions() throws Exception {
+    final String tableName = getUniqueNames(1)[0];
+    final String newUserName = "NEW_USER";
+    final String srcNs = "src";
+    final String srcTableName = srcNs + "." + tableName;
+    final String destNs = "dst";
+    final String dstTableName = destNs + "." + tableName;
+
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      client.namespaceOperations().create(srcNs);
+      client.tableOperations().create(srcTableName);
+      client.namespaceOperations().create(destNs);
+      client.securityOperations().createLocalUser(newUserName, new 
PasswordToken(newUserName));
+      // User needs WRITE or ALTER_TABLE on the src table to flush it as part 
of the clone operation
+      client.securityOperations().grantTablePermission(newUserName, 
srcTableName,
+          TablePermission.ALTER_TABLE);
+      client.securityOperations().grantTablePermission(newUserName, 
srcTableName,
+          TablePermission.READ);

Review Comment:
   > I copied 
[this](https://github.com/apache/accumulo/pull/5334/files#diff-89ff01550cac0c44b957f8c13e910aed15aee2f419bcdcb825517ebefdf22a94R425)
 test to the 2.1 branch and is succeeds as is with no modifications. Based on 
what you are saying above, this test should have failed because the clone 
operation should have succeeded instead of throwing an exception.
   
   @dlmarion what's the status of this PR? Based on this comment, it seems like 
you were saying the problem isn't reproducible in 2.1. However, your test 
reproduces it for me in 2.1, and this PR seems to fix it. So... I think this PR 
is ready.



-- 
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: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to