keith-turner commented on code in PR #5990:
URL: https://github.com/apache/accumulo/pull/5990#discussion_r2586087636
##########
test/src/main/java/org/apache/accumulo/test/NewTableConfigurationIT.java:
##########
@@ -519,19 +521,66 @@ public void testNtcChaining() throws AccumuloException,
AccumuloSecurityExceptio
}
@Test
- public void testIteratorConflictsWithDefault() throws Exception {
- String[] tableNames = getUniqueNames(2);
- String table1 = tableNames[0];
- String table2 = tableNames[1];
+ public void testConflictsWithDefaults() throws Exception {
+ // tests trying to add properties that conflict with the default table
properties
+ String table = getUniqueNames(1)[0];
try (AccumuloClient client =
Accumulo.newClient().from(getClientProps()).build()) {
+ /*
+ * conflicts from iterators set via attachIterator()
+ */
// add an iterator with same priority as the default iterator
var iterator1 = new IteratorSetting(20, "foo", "foo.bar");
- assertThrows(IllegalArgumentException.class, () ->
client.tableOperations().create(table1,
- new NewTableConfiguration().attachIterator(iterator1)));
+ var exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new
NewTableConfiguration().attachIterator(iterator1)));
+ assertTrue(exception.getMessage().contains("iterator priority
conflict"));
// add an iterator with same name as the default iterator
var iterator2 = new IteratorSetting(10, "vers", "foo.bar");
- assertThrows(IllegalArgumentException.class, () ->
client.tableOperations().create(table2,
- new NewTableConfiguration().attachIterator(iterator2)));
+ exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new
NewTableConfiguration().attachIterator(iterator2)));
+ assertTrue(exception.getMessage().contains("iterator name conflict"));
+ // try to attach the exact default iterators
+ IteratorConfigUtil.getInitialTableIteratorSettings().forEach((setting,
scopes) -> {
+ var exception1 = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new NewTableConfiguration().attachIterator(setting,
scopes)));
+ assertTrue(exception1.getMessage().contains("iterator name conflict")
+ || exception1.getMessage().contains("iterator priority conflict"));
+ });
+
+ /*
+ * conflicts from iterators set via properties
+ */
+ // add an iterator with same priority as the default iterator
+ Map<String,String> props = new HashMap<>();
+ for (IteratorScope iterScope : IteratorScope.values()) {
+ props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".foo",
"20,foo.bar");
+ }
+ exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new NewTableConfiguration().setProperties(props)));
+ assertTrue(exception.getMessage().contains("iterator priority
conflict"));
+ props.clear();
+ // add an iterator with same name as the default iterator
+ for (IteratorScope iterScope : IteratorScope.values()) {
+ props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers",
"10,foo.bar");
+ }
+ exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new NewTableConfiguration().setProperties(props)));
+ assertTrue(exception.getMessage().contains("iterator name conflict"));
+ props.clear();
+ // try to attach the exact default iterators
+ exception = assertThrows(IllegalStateException.class,
+ () -> client.tableOperations().create(table, new
NewTableConfiguration()
+ .setProperties(IteratorConfigUtil.getInitialTableIterators())));
+ assertTrue(exception.getMessage().contains("iterator name conflict")
+ || exception.getMessage().contains("iterator priority conflict"));
+
+ /*
+ * conflicts with default, non-iterator properties
+ */
+ props.put(Property.TABLE_CONSTRAINT_PREFIX + "1", "foo");
Review Comment:
Could have another test case that passes the constraint w/ the default value
and that should not fail.
##########
test/src/main/java/org/apache/accumulo/test/NewTableConfigurationIT.java:
##########
@@ -519,19 +521,66 @@ public void testNtcChaining() throws AccumuloException,
AccumuloSecurityExceptio
}
@Test
- public void testIteratorConflictsWithDefault() throws Exception {
- String[] tableNames = getUniqueNames(2);
- String table1 = tableNames[0];
- String table2 = tableNames[1];
+ public void testConflictsWithDefaults() throws Exception {
+ // tests trying to add properties that conflict with the default table
properties
+ String table = getUniqueNames(1)[0];
try (AccumuloClient client =
Accumulo.newClient().from(getClientProps()).build()) {
+ /*
+ * conflicts from iterators set via attachIterator()
+ */
// add an iterator with same priority as the default iterator
var iterator1 = new IteratorSetting(20, "foo", "foo.bar");
- assertThrows(IllegalArgumentException.class, () ->
client.tableOperations().create(table1,
- new NewTableConfiguration().attachIterator(iterator1)));
+ var exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new
NewTableConfiguration().attachIterator(iterator1)));
+ assertTrue(exception.getMessage().contains("iterator priority
conflict"));
// add an iterator with same name as the default iterator
var iterator2 = new IteratorSetting(10, "vers", "foo.bar");
- assertThrows(IllegalArgumentException.class, () ->
client.tableOperations().create(table2,
- new NewTableConfiguration().attachIterator(iterator2)));
+ exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new
NewTableConfiguration().attachIterator(iterator2)));
+ assertTrue(exception.getMessage().contains("iterator name conflict"));
+ // try to attach the exact default iterators
+ IteratorConfigUtil.getInitialTableIteratorSettings().forEach((setting,
scopes) -> {
+ var exception1 = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new NewTableConfiguration().attachIterator(setting,
scopes)));
+ assertTrue(exception1.getMessage().contains("iterator name conflict")
+ || exception1.getMessage().contains("iterator priority conflict"));
+ });
+
+ /*
+ * conflicts from iterators set via properties
+ */
+ // add an iterator with same priority as the default iterator
+ Map<String,String> props = new HashMap<>();
+ for (IteratorScope iterScope : IteratorScope.values()) {
+ props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".foo",
"20,foo.bar");
+ }
+ exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new NewTableConfiguration().setProperties(props)));
+ assertTrue(exception.getMessage().contains("iterator priority
conflict"));
+ props.clear();
+ // add an iterator with same name as the default iterator
+ for (IteratorScope iterScope : IteratorScope.values()) {
+ props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers",
"10,foo.bar");
+ }
+ exception = assertThrows(IllegalStateException.class, () ->
client.tableOperations()
+ .create(table, new NewTableConfiguration().setProperties(props)));
+ assertTrue(exception.getMessage().contains("iterator name conflict"));
+ props.clear();
+ // try to attach the exact default iterators
Review Comment:
Wondering if this case should create the table w/o failing. The impl could
create a tmp map that removes exact matches of the defaults for its check.
Seems like it would be ok to do that, wondering if there are downsides I am not
considering.
--
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]