Skip to content

Commit

Permalink
Optimized EagerThreadPoolExecutorTest by decreasing maximumPoolSize (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zrlw authored Mar 6, 2025
1 parent 3771339 commit 25d6872
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ void testEagerThreadPoolFast() {
String name = "eager-tf";
int queues = 5;
int cores = 5;
int threads = 10;
// github actions usually run on 4 cores which could be determined by LoadStatusCheckerTest
int threads = 5;
// alive 1 second
long alive = 1000;

Expand All @@ -127,7 +128,7 @@ void testEagerThreadPoolFast() {
taskQueue.setExecutor(executor);

CountDownLatch countDownLatch1 = new CountDownLatch(1);
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 5; i++) {
executor.execute(() -> {
try {
countDownLatch1.await();
Expand All @@ -136,8 +137,8 @@ void testEagerThreadPoolFast() {
}
});
}
await().until(() -> executor.getPoolSize() == 10);
Assertions.assertEquals(10, executor.getActiveCount());
await().until(() -> executor.getPoolSize() == 5);
Assertions.assertEquals(5, executor.getActiveCount());

CountDownLatch countDownLatch2 = new CountDownLatch(1);
AtomicBoolean started = new AtomicBoolean(false);
Expand All @@ -153,8 +154,8 @@ void testEagerThreadPoolFast() {
}

await().until(() -> executor.getQueue().size() == 5);
Assertions.assertEquals(10, executor.getActiveCount());
Assertions.assertEquals(10, executor.getPoolSize());
Assertions.assertEquals(5, executor.getActiveCount());
Assertions.assertEquals(5, executor.getPoolSize());
Assertions.assertFalse(started.get());
countDownLatch1.countDown();

Expand Down

0 comments on commit 25d6872

Please sign in to comment.