Skip to content

Commit

Permalink
Fix testScheduledFixedDelayRejection (#106630) (#106642)
Browse files Browse the repository at this point in the history
Not really necessary to allow the scheduled task to race against the
blocks, and this race is a source of test flakiness. Fixed by imposing
the blocks first.

Closes #106618
  • Loading branch information
DaveCTurner committed Mar 22, 2024
1 parent 672d14d commit 72aa514
Showing 1 changed file with 3 additions and 7 deletions.
Expand Up @@ -465,7 +465,6 @@ public void testScheduledOneShotForceExecution() {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/106618")
public void testScheduledFixedDelayRejection() {
final var name = "fixed-bounded";
final var threadPool = new TestThreadPool(
Expand All @@ -476,17 +475,14 @@ public void testScheduledFixedDelayRejection() {
final var future = new PlainActionFuture<Void>();
final var latch = new CountDownLatch(1);
try {
blockExecution(threadPool.executor(name), latch);
threadPool.scheduleWithFixedDelay(
ActionRunnable.wrap(future, ignored -> Thread.yield()),
ActionRunnable.wrap(future, ignored -> fail("should not execute")),
TimeValue.timeValueMillis(between(1, 100)),
threadPool.executor(name)
);

while (future.isDone() == false) {
// might not block all threads the first time round if the scheduled runnable is running, so must keep trying
blockExecution(threadPool.executor(name), latch);
}
expectThrows(EsRejectedExecutionException.class, () -> FutureUtils.get(future));
expectThrows(EsRejectedExecutionException.class, () -> FutureUtils.get(future, 10, TimeUnit.SECONDS));
} finally {
latch.countDown();
assertTrue(terminate(threadPool));
Expand Down

0 comments on commit 72aa514

Please sign in to comment.