kevinrr888 commented on code in PR #5990:
URL: https://github.com/apache/accumulo/pull/5990#discussion_r2578935997
##########
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:
good spot on the typo. Fixed in db8d7f5221cddd5bf04952f4e578994e90b9f3ec.
Also removed the entrySet calls, not sure why I had those
--
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]