This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch elasticity in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push: new e1f655b109 fixes periodic failure with CompactionIT (#4201) e1f655b109 is described below commit e1f655b1095f4113270022f905ff5da996b69d67 Author: Keith Turner <ktur...@apache.org> AuthorDate: Thu Feb 1 09:25:42 2024 -0500 fixes periodic failure with CompactionIT (#4201) The test CompactionIT.testConcurrentSplit() would periodically fail because it relied on the old behavior of WaitFor. Changed the test to use custom code that waits up to three seconds for a condition to be met and then continues. --- .../accumulo/test/functional/CompactionIT.java | 33 ++++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java index b734819200..8f083fd4e3 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java @@ -472,12 +472,17 @@ public class CompactionIT extends AccumuloClusterHarness { splits.add(new Text(String.format("r:%04d", i))); } - // wait a bit for some tablets to have files selected, it possible the compaction have - // completed before this so do not wait long - Wait.waitFor( - () -> countTablets(tableName, tabletMetadata -> tabletMetadata.getSelectedFiles() != null) - > 0, - 3000, 10); + // Wait a bit for some tablets to have files selected, it possible the compaction have + // completed before this so do not wait long. Once files are selected compactions can start. + // This speed bump is an attempt to increase the chance that splits and compactions run + // concurrently. Wait.waitFor() is not used here because it will throw an exception if the + // time limit is exceeded. + long startTime = System.nanoTime(); + while (System.nanoTime() - startTime < SECONDS.toNanos(3) + && countTablets(tableName, tabletMetadata -> tabletMetadata.getSelectedFiles() != null) + == 0) { + Thread.sleep(10); + } // add 10 more splits to the table c.tableOperations().addSplits(tableName, splits); @@ -487,12 +492,16 @@ public class CompactionIT extends AccumuloClusterHarness { splits.add(new Text(String.format("r:%04d", i))); } - // wait a bit for some tablets to be compacted, it possible the compaction have completed - // before this so do not wait long - Wait.waitFor( - () -> countTablets(tableName, tabletMetadata -> !tabletMetadata.getCompacted().isEmpty()) - > 0, - 3000, 10); + // Wait a bit for some tablets to be compacted, it possible the compaction have completed + // before this so do not wait long. Wait.waitFor() is not used here because it will throw an + // exception if the time limit is exceeded. This is just a speed bump, its ok if the condition + // is not met within the time limit. + startTime = System.nanoTime(); + while (System.nanoTime() - startTime < SECONDS.toNanos(3) + && countTablets(tableName, tabletMetadata -> !tabletMetadata.getCompacted().isEmpty()) + == 0) { + Thread.sleep(10); + } // add 80 more splits to the table c.tableOperations().addSplits(tableName, splits);