-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor/#209] 테스트 컨테이너 및 액션 개선 #327
Conversation
417caec
to
e1f2e7c
Compare
b1e3dce
to
33d576b
Compare
6050fad
to
be97c6a
Compare
be97c6a
to
cda632b
Compare
b03c32a
to
5bc7062
Compare
|
||
- name: Test with Gradle | ||
run: | | ||
./gradlew --info test | ||
./gradlew test -parallel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전체 테스트를 수행하는 경우에는 병렬로 실행할 수 있도록 -parallel 옵션 추가하였습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이거 ㄹㅇ 굳굳
- name: Cache Api Repo Jooq | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
./api-repo/src/generated | ||
./api-repo/src/main/resources/db/migration | ||
key: ${{ runner.os }}-api-repo-jooq-${{ hashFiles('./api-repo/src/generated/**', './api-repo/src/main/resources/db/migration/**') }} | ||
restore-keys: | | ||
${{ runner.os }}-api-repo-jooq- | ||
|
||
- name: Cache Batch Jooq | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
./batch/src/generated | ||
./batch/src/main/resources/db/migration | ||
key: ${{ runner.os }}-batch-jooq-${{ hashFiles('./batch/src/generated/**', './batch/src/main/resources/db/migration/**') }} | ||
restore-keys: | | ||
${{ runner.os }}-batch-jooq- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jooq 관련 파일을 캐싱합니다.
restore-keys: | | ||
${{ runner.os }}-batch-jooq- | ||
|
||
api-test: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래 각각의 모듈 별로 필요한 캐싱된 값을 받아 테스트를 수행합니다.
- "13306:3306" | ||
- "33306:3306" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로컬 환경이 켜져있어도 테스트 수행할 수 있고
병렬로 테스트 수행하기 위해 포트를 변경해주었습니다.
-> 모듈별로 독립된 포트로
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이제 로컬에서 디비 컨태이너를 내리지 않고도 테스트가 가능하겠네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네!!😃
/** Common */ | ||
@Autowired | ||
lateinit var apiControllerExceptionHandler: ApiControllerExceptionHandler | ||
|
||
@Autowired | ||
lateinit var objectMapper: ObjectMapper | ||
|
||
lateinit var webTestClient: WebTestClient | ||
|
||
@Autowired | ||
lateinit var mockMvc: MockMvc | ||
|
||
@MockBean | ||
lateinit var tokenResolver: TokenResolver | ||
|
||
/** AdminControllerTest */ | ||
@Autowired | ||
lateinit var adminController: AdminController | ||
|
||
@MockBean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
부모 테스트 클래스를 가지고 있어도
자식 클래스에 @MockBean이 들어가면 컨텍스트가 달라져 컨테이너가 다시 뜨는 문제가 있었어요!
그래서 @MockBean 클래스를 부모 클래스에서 주입 받도록 수정하였고
그김에 공통으로 사용하는 클래스 역시 부모 클래스에서 한번에 주입 받도록 수정하였습니다.
우선 수정은 하였는데 자세한 것은 추후 보충해서 공유할께요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://youtu.be/N06UeRrWFdY?si=Exobuxb1xFS0NGoM
요 영상을 참고해서 수정하였어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나중에 mockmvc만 사용하도록 바꾸는거 어때요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요건 다른 pr로 진행할께요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
많이 개선되었네요👍🏻
🎫 연관 이슈
resolved: #209
💁♂️ PR 내용
🙏 작업
🙈 PR 참고 사항
📸 스크린샷
1m 18s -> 1m 5s
미미하지만 개선.. 하였습니다.
컨테이너가 한번만 떠야 환경을 위한 도커도 한번만 떠서 개선하였습니다.!
🤖 테스트 체크리스트