From 0fc9484ef6493e17649ffa99773237801338e913 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 3 Jan 2023 09:37:48 +0000 Subject: [PATCH] Ensure actual rejections occur --- .../util/concurrent/PrioritizedThrottledTaskRunnerTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java b/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java index 6853d6b94d248..c52380b4dc126 100644 --- a/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java +++ b/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java @@ -189,6 +189,7 @@ public void testFailsTasksOnRejectionOrShutdown() throws Exception { final var totalPermits = between(1, maxThreads * 2); final var permits = new Semaphore(totalPermits); final var taskCompleted = new CountDownLatch(between(1, maxThreads * 2)); + final var rejectionCountDown = new CountDownLatch(between(1, maxThreads * 2)); final var spawnThread = new Thread(() -> { try { @@ -197,7 +198,7 @@ public void testFailsTasksOnRejectionOrShutdown() throws Exception { taskRunner.enqueueTask(new TestTask(taskCompleted::countDown, getRandomPriority()) { @Override public void onRejection(Exception e) { - // ok + rejectionCountDown.countDown(); } @Override @@ -214,6 +215,7 @@ public void onAfter() { assertTrue(taskCompleted.await(10, TimeUnit.SECONDS)); executor.shutdown(); assertTrue(executor.awaitTermination(30, TimeUnit.SECONDS)); + assertTrue(rejectionCountDown.await(10, TimeUnit.SECONDS)); spawnThread.interrupt(); spawnThread.join(); assertThat(taskRunner.runningTasks(), equalTo(0));