#60 PlaceReadServiceTest 비동기 로직 대기하도록 수정#63
Merged
Conversation
- latch.await() 이후 await().untilAsserted()를 사용하여, 비동기 DB 업데이트(조회수 증가)가 완료될 때까지 대기하도록 변경
jcw1031
reviewed
Feb 17, 2026
Comment on lines
+110
to
+115
| await().atMost(10, TimeUnit.SECONDS) // 10개 스레드이므로 넉넉하게 10초 대기 | ||
| .untilAsserted(() -> { // viewCount가 10이 될 때까지 반복 | ||
| Place finalPlace = placeRepository.findById(testPlace.getId()).get(); | ||
| // log.info("[동시] Awaitility 폴링 중... 최종 조회수: {}", finalPlace.getViewCount()); | ||
| assertThat(finalPlace.getViewCount()).isEqualTo(numberOfThreads); | ||
| }); |
Member
There was a problem hiding this comment.
awaitility라는 라이브러리는 처음 봤는데 나름 유용한 것 같네?
근데 만약 조회수 로직에 이슈가 있어서 조회수가 정상적으로 업데이트가 안 되면 최대 10초까지 대기하게 될 것 같아서 더 좋은 방법은 없을까 싶긴 하다
조회수 증가 로직을 mocking해서 단순하게 n번 호출되었는지를 검증하는 방법도 있긴 한데, 테스트하려는 게 멀티 스레드 환경에서 조회수가 정상적으로 잘 업데이트 되는지를 검증하는 거라면 mocking하는 게 좋은 방법은 아닌 것 같기도 하고..
Member
There was a problem hiding this comment.
지금 방식도 크게 문제는 없을 것 같긴 해~
동시성 테스트 작성한 것도 좋은 것 같구
jcw1031
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 PR 제목
PlaceReadServiceTest 비동기 로직 대기하도록 수정
✅ 작업 내용
PlaceReadServiceTest비동기 테스트 로직 수정@Async로 인한 조회수 비동기 업데이트를 테스트하기 위해Awaitility사용await().untilAsserted()를 사용해, DB 업데이트가 완료될 때까지 대기한 후assertThat을 검증하도록 수정🎯 관련 이슈
💬 기타 공유하고 싶은 내용
이전엔 괜찮다가 갑자기 테스트 코드가 깨졌는데 이전에 왜 됐는지가 의문.....
이것과 관련해서
동시성,스레드풀,비동기에 대해서 공부를 더 해보면 좋을까요??