File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/test/java/com/somemore/domains/volunteer/service Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1212import java .util .concurrent .CountDownLatch ;
1313import java .util .concurrent .ExecutorService ;
1414import java .util .concurrent .Executors ;
15+ import java .util .concurrent .TimeUnit ;
1516
1617import static com .somemore .global .auth .oauth .domain .OAuthProvider .NAVER ;
1718import static org .assertj .core .api .Assertions .assertThat ;
19+ import static org .assertj .core .api .Fail .fail ;
1820
1921class 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 );
You can’t perform that action at this time.
0 commit comments