Skip to content

Commit 009950d

Browse files
authored
Fix testScheduledFixedDelayRejection (#106630) (#106643)
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
1 parent d74e9f8 commit 009950d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

server/src/test/java/org/elasticsearch/threadpool/ThreadPoolTests.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ public void testScheduledOneShotForceExecution() {
358358
}
359359
}
360360

361-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/106618")
362361
public void testScheduledFixedDelayRejection() {
363362
final String name = "fixed-bounded";
364363
final ThreadPool threadPool = new TestThreadPool(
@@ -369,17 +368,14 @@ public void testScheduledFixedDelayRejection() {
369368
final PlainActionFuture<Void> future = new PlainActionFuture<>();
370369
final CountDownLatch latch = new CountDownLatch(1);
371370
try {
371+
blockExecution(threadPool.executor(name), latch);
372372
threadPool.scheduleWithFixedDelay(
373-
ActionRunnable.wrap(future, ignored -> Thread.yield()),
373+
ActionRunnable.wrap(future, ignored -> fail("should not execute")),
374374
TimeValue.timeValueMillis(between(1, 100)),
375375
name
376376
);
377377

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

0 commit comments

Comments
 (0)