keith-turner commented on code in PR #4466:
URL: https://github.com/apache/accumulo/pull/4466#discussion_r1595994243


##########
test/src/main/java/org/apache/accumulo/test/compaction/CompactionPriorityQueueMetricsIT.java:
##########
@@ -401,10 +413,109 @@ public void testQueueMetrics() throws Exception {
           }
         }
       }
-      UtilWaitThread.sleep(3500);
+      
UtilWaitThread.sleep(TestStatsDRegistryFactory.pollingFrequency.toMillis());
     }
+  }
 
-    shutdownTailer.set(true);
-    thread.join();
+  /**
+   * Test that the compaction queue is cleared when compactions no longer need 
to happen.
+   */
+  @Test
+  public void testCompactionQueueClearedWhenNotNeeded() throws Exception {
+    ServerContext context = getCluster().getServerContext();
+    try (AccumuloClient c = 
Accumulo.newClient().from(getClientProps()).build()) {
+
+      String dir = getDir("/testBulkFile-");
+      FileSystem fs = getCluster().getFileSystem();
+      fs.mkdirs(new Path(dir));
+
+      // Create splits so there are two groupings of tablets with similar file 
counts.
+      String splitString = "500 1000 1500 2000 3750 5500 7250 9000";
+      addSplits(c, tableName, splitString);
+
+      for (int i = 0; i < 100; i++) {
+        writeData(dir + "/f" + i + ".", aconf, i * 100, (i + 1) * 100 - 1);
+      }
+      c.tableOperations().importDirectory(dir).to(tableName).load();
+
+      try (TabletsMetadata tm = 
context.getAmple().readTablets().forTable(tableId).build()) {
+        // Get each tablet's file sizes
+        for (TabletMetadata tablet : tm) {
+          long fileSize = tablet.getFiles().size();
+          log.debug("Number of files in tablet {}: {}", 
tablet.getExtent().toString(), fileSize);
+        }
+      }
+      verifyData(c, tableName, 0, 100 * 100 - 1, false);
+    }
+
+    final long sleepMillis = 
TestStatsDRegistryFactory.pollingFrequency.toMillis();
+
+    Wait.waitFor(() -> {
+      while (!queueMetrics.isEmpty()) {
+        var qm = queueMetrics.take();
+        if 
(qm.getName().contains(MetricsProducer.METRICS_COMPACTOR_JOB_PRIORITY_QUEUE_JOBS_QUEUED)
+            && qm.getTags().containsValue(QUEUE1_METRIC_LABEL)) {
+          if (Integer.parseInt(qm.getValue()) > 0) {
+            return true;
+          }
+        }
+      }
+      return false;
+    }, 60_000, sleepMillis, "did not see Q1 metrics");
+
+    Wait.waitFor(() -> {

Review Comment:
   What is the purpose of this wait loop?



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