cshannon commented on code in PR #4254:
URL: https://github.com/apache/accumulo/pull/4254#discussion_r1493027974


##########
test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java:
##########
@@ -909,6 +909,82 @@ public void testDeleteCompactionService() throws Exception 
{
     }
   }
 
+  @Test
+  public void testUserCompactionRequested() throws Exception {
+
+    String tableName = getUniqueNames(1)[0];
+    try (final AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+
+      // configure tablet compaction iterator that slows compaction down so we 
can test
+      // that the USER_COMPACTION_REQUESTED column is set when a user 
compaction is requested
+      // when a system compaction is running and blocking
+
+      var ntc = new NewTableConfiguration();
+      IteratorSetting iterSetting = new IteratorSetting(50, 
SlowIterator.class);
+      SlowIterator.setSleepTime(iterSetting, 1);
+      ntc.attachIterator(iterSetting, EnumSet.of(IteratorScope.majc));
+      ntc.setProperties(Map.of(Property.TABLE_MAJC_RATIO.getKey(), "20"));
+      client.tableOperations().create(tableName, ntc);
+
+      // Insert MAX_DATA rows
+      try (BatchWriter bw = client.createBatchWriter(tableName)) {
+        for (int i = 0; i < MAX_DATA; i++) {
+          Mutation m = new Mutation(String.format("r:%04d", i));
+          m.put("", "", "" + i);
+          bw.addMutation(m);
+
+          if (i % 75 == 0) {
+            // create many files as this will cause a system compaction
+            bw.flush();
+            client.tableOperations().flush(tableName, null, null, true);
+          }
+        }
+      }
+      client.tableOperations().flush(tableName, null, null, true);
+
+      // set the compaction ratio 1 to trigger a system compaction
+      client.tableOperations().setProperty(tableName, 
Property.TABLE_MAJC_RATIO.getKey(), "1");
+
+      var tableId = 
TableId.of(client.tableOperations().tableIdMap().get(tableName));
+      var extent = new KeyExtent(tableId, null, null);
+
+      // Wait for the system compaction to start
+      Wait.waitFor(() -> {
+        var tabletMeta = ((ClientContext) 
client).getAmple().readTablet(extent);
+        var externalCompactions = tabletMeta.getExternalCompactions().size();
+        log.debug("Current external compactions {}", externalCompactions);
+        return externalCompactions == 1;
+      }, Wait.MAX_WAIT_MILLIS, 500);

Review Comment:
   I can do that, the default is actually 1 second, maybe we should make a 
follow on issue to consider changing the default to something like 100ms as 
that might be better for most tests



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