kevinrr888 commented on code in PR #5990:
URL: https://github.com/apache/accumulo/pull/5990#discussion_r2566653499


##########
test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java:
##########
@@ -454,4 +456,72 @@ public void getTimeTypeTest() throws 
TableNotFoundException, AccumuloException,
         "specified table does not exist");
   }
 
+  @Test
+  public void testTablePropsEqual() throws Exception {
+    // Want to ensure users can somehow create a table via the Java API that 
has exactly
+    // the same properties of another table (including changes to default 
properties), similar to
+    // the copy config option of the create table Shell command. Cloning the 
table is expected to
+    // be one way and modifying the properties after creation is expected to 
be another way.
+
+    // default iterator property which is automatically set on creation of all 
tables; want to
+    // ensure removal and changing this type of prop is retained on copying to 
another table
+    final String defaultScanIterProp = Property.TABLE_ITERATOR_PREFIX
+        + IteratorUtil.IteratorScope.scan.name().toLowerCase() + ".vers";
+    final String defaultScanIterPropMaxVers = Property.TABLE_ITERATOR_PREFIX
+        + IteratorUtil.IteratorScope.scan.name().toLowerCase() + 
".vers.opt.maxVersions";
+    final String defaultScanIterPropMaxVersDefault = "1";
+    final String defaultScanIterPropMaxVersNew = "999";
+    final String customTableProp = 
Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "foo";
+    final String customTablePropVal = "bar";
+    final String[] names = getUniqueNames(3);
+    final String table1 = names[0];
+    final String table2 = names[1];
+    final String table3 = names[2];
+
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      client.tableOperations().create(table1,
+          new NewTableConfiguration().setProperties(Map.of(customTableProp, 
customTablePropVal)));
+
+      Wait.waitFor(() -> {
+        var table1Props = client.tableOperations().getTableProperties(table1);
+        return table1Props.get(customTableProp).equals(customTablePropVal)
+            && table1Props.get(defaultScanIterProp) != null && table1Props
+                
.get(defaultScanIterPropMaxVers).equals(defaultScanIterPropMaxVersDefault);
+      });
+
+      // testing both modifying and deleting a default prop
+      client.tableOperations().modifyProperties(table1, props -> {
+        props.replace(defaultScanIterPropMaxVers, 
defaultScanIterPropMaxVersNew);
+        props.remove(defaultScanIterProp);
+      });
+
+      Wait.waitFor(() -> {
+        var table1Props = client.tableOperations().getTableProperties(table1);
+        return table1Props.get(customTableProp).equals(customTablePropVal)
+            && table1Props.get(defaultScanIterProp) == null
+            && 
table1Props.get(defaultScanIterPropMaxVers).equals(defaultScanIterPropMaxVersNew);
+      });
+
+      client.tableOperations().create(table2);
+      client.tableOperations().modifyProperties(table2, props -> {
+        try {
+          props.clear();
+          props.putAll(client.tableOperations().getTableProperties(table1));
+        } catch (AccumuloException | TableNotFoundException e) {
+          throw new RuntimeException(e);
+        }
+      });

Review Comment:
   Added in 797e39102700e1d187635fdd7d0fe0c0a8d1c721



-- 
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]

Reply via email to