keith-turner commented on code in PR #4466:
URL: https://github.com/apache/accumulo/pull/4466#discussion_r1600647819
##########
test/src/main/java/org/apache/accumulo/test/compaction/CompactionPriorityQueueMetricsIT.java:
##########
@@ -401,10 +413,67 @@ public void testQueueMetrics() throws Exception {
}
}
}
- UtilWaitThread.sleep(3500);
+
UtilWaitThread.sleep(TestStatsDRegistryFactory.pollingFrequency.toMillis());
+ }
+ }
+
+ /**
+ * 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();
+ verifyData(c, tableName, 0, 100 * 100 - 1, false);
}
- shutdownTailer.set(true);
- thread.join();
+ final long sleepMillis =
TestStatsDRegistryFactory.pollingFrequency.toMillis();
+
+ // wait for compaction jobs to be queued
+ Wait.waitFor(() -> getJobsQueued() > 0, 60_000, sleepMillis,
+ "Expected to see compaction jobs queued");
+
+ // change compactor settings so that compactions no longer need to run
+ context.tableOperations().setProperty(tableName,
Property.TABLE_MAJC_RATIO.getKey(), "2000");
+ context.tableOperations().setProperty(tableName,
Property.TABLE_FILE_MAX.getKey(), "2000");
+
+ // wait for queue to clear
+ Wait.waitFor(() -> getJobsQueued() == 0, 60_000, sleepMillis,
+ "Expected job queue to be cleared once compactions no longer need to
happen");
}
+
+ /**
+ * @return the number of jobs queued in the compaction queue. Returns -1 if
no metrics are found.
+ */
+ private int getJobsQueued() throws InterruptedException {
Review Comment:
Adding this method was nice, made the test much shorter and easier to
understand.
--
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]