Skip to content

Commit 03126bd

Browse files
committed
fix: 동시성 테스트 스레드 획득 에러 수정
- 스레드 풀의 크기를 16으로 감소
1 parent 0914343 commit 03126bd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/test/java/com/somemore/domains/volunteer/service/UpdateVolunteerLockServiceTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import java.util.concurrent.CountDownLatch;
1313
import java.util.concurrent.ExecutorService;
1414
import java.util.concurrent.Executors;
15+
import java.util.concurrent.TimeUnit;
1516

1617
import static com.somemore.global.auth.oauth.domain.OAuthProvider.NAVER;
1718
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.assertj.core.api.Fail.fail;
1820

1921
class UpdateVolunteerLockServiceTest extends IntegrationTestSupport {
2022

@@ -59,7 +61,8 @@ void updateVolunteerStatsWithConcurrency() throws InterruptedException {
5961
int hours = 4;
6062
int threadCnt = 100;
6163

62-
ExecutorService executorService = Executors.newFixedThreadPool(32);
64+
// 스레드 풀 크기를 줄여서 경합 감소 32 -> 16
65+
ExecutorService executorService = Executors.newFixedThreadPool(16);
6366
CountDownLatch latch = new CountDownLatch(threadCnt);
6467

6568
// when
@@ -74,6 +77,11 @@ void updateVolunteerStatsWithConcurrency() throws InterruptedException {
7477
}
7578
latch.await();
7679

80+
// 대기 시간을 충분히 늘림
81+
if (!latch.await(10, TimeUnit.SECONDS)) {
82+
fail("작업 완료 대기");
83+
}
84+
7785
// then
7886
Volunteer find = volunteerRepository.findById(id).orElseThrow();
7987
assertThat(find.getTotalVolunteerCount()).isEqualTo(threadCnt);

0 commit comments

Comments
 (0)