From ed2f0cfba12b695d4901352ba8cace2031a523cf Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 2 Feb 2023 10:28:58 +0000 Subject: [PATCH] Fix PrioritizedThrottledTaskRunnerTests (#93446) These tests try and execute `maxThreads` concurrent tasks to ensure that the rest of the executor's queue has been processed, but due to #93443 (and the executor's zero timeout) this sometimes doesn't work. This commit fixes the problem by making every thread a core thread so that they do not time out. Closes #92910 Closes #92747 --- .../util/concurrent/PrioritizedThrottledTaskRunnerTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f1955ebcddacb..01ecce705856f 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 @@ -39,7 +39,7 @@ public class PrioritizedThrottledTaskRunnerTests extends ESTestCase { public void setUp() throws Exception { super.setUp(); maxThreads = between(1, 10); - executor = EsExecutors.newScaling("test", 1, maxThreads, 0, TimeUnit.MILLISECONDS, false, threadFactory, threadContext); + executor = EsExecutors.newScaling("test", maxThreads, maxThreads, 0, TimeUnit.NANOSECONDS, false, threadFactory, threadContext); } @Override @@ -197,7 +197,7 @@ public void testEnqueueSpawnsNewTasksUpToMax() throws Exception { public void testFailsTasksOnRejectionOrShutdown() throws Exception { final var executor = randomBoolean() - ? EsExecutors.newScaling("test", 1, maxThreads, 0, TimeUnit.MILLISECONDS, true, threadFactory, threadContext) + ? EsExecutors.newScaling("test", maxThreads, maxThreads, 0, TimeUnit.MILLISECONDS, true, threadFactory, threadContext) : EsExecutors.newFixed("test", maxThreads, between(1, 5), threadFactory, threadContext, false); final var taskRunner = new PrioritizedThrottledTaskRunner("test", between(1, maxThreads * 2), executor); final var totalPermits = between(1, maxThreads * 2);