Skip to content

Commit 25d6872

Browse files
authored
Optimized EagerThreadPoolExecutorTest by decreasing maximumPoolSize (#15205)
1 parent 3771339 commit 25d6872

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/eager/EagerThreadPoolExecutorTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ void testEagerThreadPoolFast() {
110110
String name = "eager-tf";
111111
int queues = 5;
112112
int cores = 5;
113-
int threads = 10;
113+
// github actions usually run on 4 cores which could be determined by LoadStatusCheckerTest
114+
int threads = 5;
114115
// alive 1 second
115116
long alive = 1000;
116117

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

129130
CountDownLatch countDownLatch1 = new CountDownLatch(1);
130-
for (int i = 0; i < 10; i++) {
131+
for (int i = 0; i < 5; i++) {
131132
executor.execute(() -> {
132133
try {
133134
countDownLatch1.await();
@@ -136,8 +137,8 @@ void testEagerThreadPoolFast() {
136137
}
137138
});
138139
}
139-
await().until(() -> executor.getPoolSize() == 10);
140-
Assertions.assertEquals(10, executor.getActiveCount());
140+
await().until(() -> executor.getPoolSize() == 5);
141+
Assertions.assertEquals(5, executor.getActiveCount());
141142

142143
CountDownLatch countDownLatch2 = new CountDownLatch(1);
143144
AtomicBoolean started = new AtomicBoolean(false);
@@ -153,8 +154,8 @@ void testEagerThreadPoolFast() {
153154
}
154155

155156
await().until(() -> executor.getQueue().size() == 5);
156-
Assertions.assertEquals(10, executor.getActiveCount());
157-
Assertions.assertEquals(10, executor.getPoolSize());
157+
Assertions.assertEquals(5, executor.getActiveCount());
158+
Assertions.assertEquals(5, executor.getPoolSize());
158159
Assertions.assertFalse(started.get());
159160
countDownLatch1.countDown();
160161

0 commit comments

Comments
 (0)