Skip to content

Commit

Permalink
Fix PrioritizedThrottledTaskRunnerTests (elastic#93446)
Browse files Browse the repository at this point in the history
These tests try and execute `maxThreads` concurrent tasks to ensure that
the rest of the executor's queue has been processed, but due to elastic#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 elastic#92910
Closes elastic#92747
  • Loading branch information
DaveCTurner authored and mark-vieira committed Feb 2, 2023
1 parent 7c3e201 commit ed2f0cf
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<TestTask>("test", between(1, maxThreads * 2), executor);
final var totalPermits = between(1, maxThreads * 2);
Expand Down

0 comments on commit ed2f0cf

Please sign in to comment.