[TEST] 예약 생성 기능 테스트#233
Merged
Merged
Conversation
Friox
approved these changes
Aug 7, 2025
Jimin730
approved these changes
Aug 7, 2025
Jimin730
left a comment
Contributor
There was a problem hiding this comment.
동시성 테스트 부분은 테스트 코드도 아주 복잡하네요..
단순한 테스트 코드만 작성해보았는데 이렇게 복잡한 테스트 코드도 한 번 참고 해 볼 수 있어서 좋았습니다! 고생하셨습니다!
9179f75 to
73e6ca4
Compare
Ogu1208
reviewed
Aug 7, 2025
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.
관련 Issue (필수)
주요 변경 사항 (필수)
테스트를 진행하는 과정에서 로직 오류를 발견하여 아래와 같이 수정하였습니다.
객차 타입 검증 로직 수정
유효하지 않은 좌석에 대한 검증 순서에 문제가 있어, 검증 로직의 흐름을 보다 명확하게 조정하였습니다.
DTO로 전달된 승객 정보 List 복사 처리
record 내부의 List는 불변이 아니기 때문에 정렬 등 가공 시 원본이 변경될 수 있습니다. 데이터 무결성을 위해 new ArrayList<>()로 복사하여 사용하도록 수정했습니다.
운행 순서 검증 로직 추가
기차 스케줄과 일치하지 않는 순서로 예매를 시도하는 경우 적절한 예외를 반환하도록 검증 로직을 추가하였습니다.
리뷰어 참고 사항
테스트 작성 중 동시성 이슈가 발생하여, 이를 해결하기 위해 다양한 락 처리 방식들을 공부하면서 적용하려고 하였습니다.
다만, 트랜잭션이 분리되어 있고 좌석이 아닌 겹치는 구간을 기준으로 락을 걸어야 하는 구조적 특성상, 최적의 방법을 찾기 어려웠습니다.
일단 이중 락 방식으로 일단 동시성 문제를 해결하였고 k6로 400명 테스트에서 기존 코드와 비교하여 성능 차이는 크지 않음을 확인했습니다.
비관적 락이 두 번 발생하다 보니 성능에 영향을 줄 수 있는 여지가 있어, 추후 시간적 여유가 생기면 더 나은 구조와 방법으로 성능 개선을 진행할 예정입니다.
추가 정보
없음
PR 작성 체크리스트 (필수)