You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2021/05/12 14:59:57 UTC

[GitHub] [accumulo] keith-turner commented on a change in pull request #2098: Fixes #1628 - add test where selector throws an error

keith-turner commented on a change in pull request #2098:
URL: https://github.com/apache/accumulo/pull/2098#discussion_r631118585



##########
File path: test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
##########
@@ -68,6 +116,54 @@ 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];
+      c.tableOperations().create(tableName);
+      // Ensure compactions don't kick off
+      c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "10.0");
+      // 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.getRFileNames(c, tableName);
+      Assert.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.getRFileNames(c, tableName);
+      Assert.assertFalse(files2.contains(files.get(0)));
+      Assert.assertFalse(files2.contains(files.get(3)));

Review comment:
       ```suggestion
         Assert.assertFalse(files2.contains(files.get(0)));
         Assert.assertTrue(files2.contains(files.get(1)));
         Assert.assertTrue(files2.contains(files.get(2)));
         Assert.assertFalse(files2.contains(files.get(3)));
   ```

##########
File path: test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
##########
@@ -68,6 +116,54 @@ 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];
+      c.tableOperations().create(tableName);
+      // Ensure compactions don't kick off
+      c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "10.0");

Review comment:
       setting these props are eventually consistent, so not sure when tserver will see the config update.  Could set the prop at table creation time instead, avoiding any possible race conditions in the test. 

##########
File path: test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
##########
@@ -68,6 +116,54 @@ 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];
+      c.tableOperations().create(tableName);
+      // Ensure compactions don't kick off
+      c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "10.0");
+      // 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.getRFileNames(c, tableName);
+      Assert.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.getRFileNames(c, tableName);
+      Assert.assertFalse(files2.contains(files.get(0)));
+      Assert.assertFalse(files2.contains(files.get(3)));
+    }

Review comment:
       It would be nice to scan table and verify data is as expected.




-- 
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:
users@infra.apache.org