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


##########
test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java:
##########
@@ -454,4 +456,65 @@ 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.
+
+    // 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);
+      });
+
+      // one option to create a table with the same config, including default 
prop changes
+      client.tableOperations().create(table2, new 
NewTableConfiguration().withoutDefaults()
+          .setProperties(client.tableOperations().getTableProperties(table1)));
+      // another option is cloning the table
+      client.tableOperations().clone(table1, table3, 
CloneConfiguration.empty());
+
+      Wait.waitFor(() -> {
+        var table1Props = client.tableOperations().getTableProperties(table1);
+        var table2Props = client.tableOperations().getTableProperties(table2);
+        var table3Props = client.tableOperations().getTableProperties(table2);
+        return table1Props.entrySet().equals(table2Props.entrySet())
+            && table1Props.entrySet().equals(table3Props.entrySet());

Review Comment:
   ```suggestion
           var table3Props = 
client.tableOperations().getTableProperties(table3);
           return table1Props.equals(table2Props) && 
table1Props.equals(table3Props);
   ```
   I think there was a copy paste bug from the line above. It was using 
`table2` instead of `table3`. Also I'm pretty sure we can just to `.equals()` 
on the map instead of `.entrySet().equals()` for the same effect and simpler 
code.



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