ctubbsii commented on a change in pull request #2098:
URL: https://github.com/apache/accumulo/pull/2098#discussion_r631245845
##########
File path:
test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
##########
@@ -68,6 +115,67 @@ protected int defaultTimeoutSeconds() {
return 4 * 60;
}
+ @Test
+ public void testBadSelector() throws Exception {
+ try (AccumuloClient c =
Accumulo.newClient().from(getClientProps()).build()) {
+ final String tableName = getUniqueNames(1)[0];
+ NewTableConfiguration tc = new NewTableConfiguration();
+ // Ensure compactions don't kick off
+ tc.setProperties(Map.of(Property.TABLE_MAJC_RATIO.getKey(), "10.0"));
+ c.tableOperations().create(tableName, tc);
+ // Create multiple RFiles
+ BatchWriter bw = c.createBatchWriter(tableName);
+ Mutation m = new Mutation("1");
+ m.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m2 = new Mutation("2");
+ m2.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m2);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m3 = new Mutation("3");
+ m3.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m3);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m4 = new Mutation("4");
+ m4.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m4);
+ bw.close();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+
+ List<String> files = FunctionalTestUtils.getRFilePaths(c, tableName);
+ assertEquals(4, files.size());
+
+ String subset = files.get(0).substring(files.get(0).lastIndexOf('/') +
1) + ","
+ + files.get(3).substring(files.get(3).lastIndexOf('/') + 1);
+
+ CompactionConfig config = new CompactionConfig()
+ .setSelector(new
PluginConfig(RandomErrorThrowingSelector.class.getName(),
+ Map.of(RandomErrorThrowingSelector.FILE_LIST_PARAM, subset)))
+ .setWait(true);
+ c.tableOperations().compact(tableName, config);
+
+ List<String> files2 = FunctionalTestUtils.getRFilePaths(c, tableName);
+ assertFalse(files2.contains(files.get(0)));
+ assertTrue(files2.contains(files.get(1)));
+ assertTrue(files2.contains(files.get(2)));
+ assertFalse(files2.contains(files.get(3)));
Review comment:
```suggestion
// check that the subset of files selected are compacted, but the
others remain untouched
List<String> filesAfterCompact = FunctionalTestUtils.getRFilePaths(c,
tableName);
assertFalse(filesAfterCompact.contains(files.get(0)));
assertTrue(filesAfterCompact.contains(files.get(1)));
assertTrue(filesAfterCompact.contains(files.get(2)));
assertFalse(filesAfterCompact.contains(files.get(3)));
```
##########
File path:
test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
##########
@@ -68,6 +115,67 @@ protected int defaultTimeoutSeconds() {
return 4 * 60;
}
+ @Test
+ public void testBadSelector() throws Exception {
+ try (AccumuloClient c =
Accumulo.newClient().from(getClientProps()).build()) {
+ final String tableName = getUniqueNames(1)[0];
+ NewTableConfiguration tc = new NewTableConfiguration();
+ // Ensure compactions don't kick off
+ tc.setProperties(Map.of(Property.TABLE_MAJC_RATIO.getKey(), "10.0"));
+ c.tableOperations().create(tableName, tc);
+ // Create multiple RFiles
+ BatchWriter bw = c.createBatchWriter(tableName);
+ Mutation m = new Mutation("1");
+ m.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m2 = new Mutation("2");
+ m2.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m2);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m3 = new Mutation("3");
+ m3.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m3);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m4 = new Mutation("4");
+ m4.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m4);
+ bw.close();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+
+ List<String> files = FunctionalTestUtils.getRFilePaths(c, tableName);
+ assertEquals(4, files.size());
+
+ String subset = files.get(0).substring(files.get(0).lastIndexOf('/') +
1) + ","
+ + files.get(3).substring(files.get(3).lastIndexOf('/') + 1);
+
+ CompactionConfig config = new CompactionConfig()
+ .setSelector(new
PluginConfig(RandomErrorThrowingSelector.class.getName(),
+ Map.of(RandomErrorThrowingSelector.FILE_LIST_PARAM, subset)))
+ .setWait(true);
+ c.tableOperations().compact(tableName, config);
+
+ List<String> files2 = FunctionalTestUtils.getRFilePaths(c, tableName);
+ assertFalse(files2.contains(files.get(0)));
+ assertTrue(files2.contains(files.get(1)));
+ assertTrue(files2.contains(files.get(2)));
+ assertFalse(files2.contains(files.get(3)));
+
+ List<Text> rows = new ArrayList<>();
+ rows.add(new Text("1"));
+ rows.add(new Text("2"));
+ rows.add(new Text("3"));
+ rows.add(new Text("4"));
+ c.createScanner(tableName).forEach((k, v) -> {
+ assertTrue(rows.remove(k.getRow()));
+ });
+ assertEquals(0, rows.size());
Review comment:
```suggestion
List<String> rows = new ArrayList<>();
c.createScanner(tableName).forEach((k, v) ->
rows.add(k.getRow().toString()));
assertEquals(List.of("1", "2", "3", "4"), actualRows);
```
##########
File path:
test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
##########
@@ -68,6 +115,67 @@ protected int defaultTimeoutSeconds() {
return 4 * 60;
}
+ @Test
+ public void testBadSelector() throws Exception {
+ try (AccumuloClient c =
Accumulo.newClient().from(getClientProps()).build()) {
+ final String tableName = getUniqueNames(1)[0];
+ NewTableConfiguration tc = new NewTableConfiguration();
+ // Ensure compactions don't kick off
+ tc.setProperties(Map.of(Property.TABLE_MAJC_RATIO.getKey(), "10.0"));
+ c.tableOperations().create(tableName, tc);
+ // Create multiple RFiles
+ BatchWriter bw = c.createBatchWriter(tableName);
+ Mutation m = new Mutation("1");
+ m.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m2 = new Mutation("2");
+ m2.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m2);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m3 = new Mutation("3");
+ m3.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m3);
+ bw.flush();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
+ Mutation m4 = new Mutation("4");
+ m4.put("cf", "cq", new Value(new byte[0]));
+ bw.addMutation(m4);
+ bw.close();
+ c.tableOperations().flush(tableName, new Text("0"), new Text("9"), true);
Review comment:
```suggestion
try (BatchWriter bw = c.createBatchWriter(tableName)) {
for (int i = 1; i <= 4; i++) {
Mutation m = new Mutation(Integer.toString(i));
m.put("cf", "cq", new Value());
bw.addMutation(m);
bw.flush();
c.tableOperations().flush(tableName, null, null, true);
}
}
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]