From 802a0fb03282fcd9feac9992c7e13c097fbe155e Mon Sep 17 00:00:00 2001 From: Chaiyong Ragkhitwetsagul Date: Sun, 2 Aug 2026 05:18:59 +0700 Subject: [PATCH] Update TaskExecutorTests.java Replaced unbounded test-thread latch waits with asserted ten-second waits so failures terminate clearly. Signed-off-by: Chaiyong Ragkhitwetsagul --- .../opensearch/cluster/service/TaskExecutorTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/test/java/org/opensearch/cluster/service/TaskExecutorTests.java b/server/src/test/java/org/opensearch/cluster/service/TaskExecutorTests.java index 28905c570ebfe..5cbc49f7589f1 100644 --- a/server/src/test/java/org/opensearch/cluster/service/TaskExecutorTests.java +++ b/server/src/test/java/org/opensearch/cluster/service/TaskExecutorTests.java @@ -213,8 +213,8 @@ public TimeValue timeout() { submitTask("unblock-task", unblockTask); block.countDown(); - block2.await(); - blockCompleted.await(); + assertTrue(block2.await(10, TimeUnit.SECONDS)); + assertTrue(blockCompleted.await(10, TimeUnit.SECONDS)); } public void testTimeoutTask() throws Exception { @@ -257,7 +257,7 @@ public void onFailure(String source, Exception e) { }; submitTask("block-task", test2); - timedOut.await(); + assertTrue(timedOut.await(10, TimeUnit.SECONDS)); block.countDown(); final CountDownLatch allProcessed = new CountDownLatch(1); TestTask test3 = new TestTask() { @@ -273,7 +273,7 @@ public void onFailure(String source, Exception e) { } }; submitTask("block-task", test3); - allProcessed.await(); // executed another task to double check that execute on the timed out update task is not called... + assertTrue(allProcessed.await(10, TimeUnit.SECONDS)); // executed another task to double check that execute on the timed out update task is not called... assertThat(executeCalled.get(), equalTo(false)); } @@ -304,7 +304,7 @@ public void testPrioritizedTasks() throws Exception { } block.close(); - latch.await(); + assertTrue(latch.await(10, TimeUnit.SECONDS)); Priority prevPriority = null; for (PrioritizedTask task : tasks) {