[REFACTOR] 가상 스레드 전환 및 k6 테스트 시나리오 재구성#10
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
개요이 PR은 실험적인 virtual thread 구성을 제거하고 테스트 인프라를 단순화합니다. AsyncConfig와 관련 테스트 서비스를 삭제한 후 통합된 변경사항테스트 인프라 통합 및 단순화
예상 코드 리뷰 노력🎯 3 (중간) | ⏱️ ~25분 연관된 PR
추천 리뷰어
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/com/example/auctionnotification/notification/controller/NotificationTestController.java`:
- Line 23: The trigger endpoint's userId parameter in
NotificationTestController.trigger lacks validation and may accept negative or
out-of-range values; add input validation at the start of the trigger method to
reject invalid userId (e.g., null, <=0, or > a sensible max) by returning a 400
Bad Request (ResponseEntity.badRequest()) or throwing a validation exception,
and document the constraint; use the method name
NotificationTestController.trigger and parameter userId to locate where to add
the check and ensure unit tests cover invalid, boundary, and valid cases.
- Around line 22-32: Wrap the call to notificationService.save(...) inside
NotificationTestController.trigger with a try-catch that catches Exception, logs
the error (including the exception) and prevents a 500 response, then return a
consistent ResponseEntity (e.g., ResponseEntity.ok().build()) even on failure;
specifically, surround the notificationService.save(message) call, catch
Exception e, call your controller logger/error reporter with the exception and a
short context message, and still return a successful ResponseEntity from trigger
so k6 tests receive a consistent response.
In
`@src/main/java/com/example/auctionnotification/notification/service/SseEmitterService.java`:
- Line 45: The `@Async` annotations on SseEmitterService.send() and sendPing() are
not effective because `@EnableAsync` is missing; add `@EnableAsync` to your
application or a configuration class (e.g., annotate
AuctionNotificationApplication with `@EnableAsync`) and also define a TaskExecutor
bean configured for virtual threads (or wire a VirtualThreadTaskExecutor) so
Spring will use that executor for `@Async` methods; ensure SseEmitterService
remains a Spring-managed bean so its send()/sendPing() calls are executed
asynchronously by the configured TaskExecutor.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 901cbbeb-a2ad-4b75-b22d-45235fc95ad2
📒 Files selected for processing (8)
k6/case1-100vus.jsk6/case2-300vus.jsk6/case3-spike.jssrc/main/java/com/example/auctionnotification/common/config/AsyncConfig.javasrc/main/java/com/example/auctionnotification/notification/controller/NotificationTestController.javasrc/main/java/com/example/auctionnotification/notification/controller/TestNotificationController.javasrc/main/java/com/example/auctionnotification/notification/service/SseEmitterService.javasrc/main/java/com/example/auctionnotification/notification/service/TestNotificationService.java
💤 Files with no reviewable changes (3)
- src/main/java/com/example/auctionnotification/notification/service/TestNotificationService.java
- src/main/java/com/example/auctionnotification/common/config/AsyncConfig.java
- src/main/java/com/example/auctionnotification/notification/controller/TestNotificationController.java
| @PostMapping("/trigger") | ||
| public ResponseEntity<Void> trigger(@RequestParam(defaultValue = "1") Long userId) { | ||
| NotificationMessage message = new NotificationMessage( | ||
| NotificationType.NEW_BID, | ||
| userId, | ||
| 1L, | ||
| "테스트 경매 상품" | ||
| ); | ||
| notificationService.save(message); | ||
| return ResponseEntity.ok().build(); | ||
| } |
There was a problem hiding this comment.
예외 처리를 추가하세요.
notificationService.save()에서 예외가 발생하면 500 에러가 반환되어 k6 부하 테스트 결과가 왜곡될 수 있습니다. 테스트 엔드포인트라도 일관된 응답을 보장하기 위해 예외 처리가 필요합니다.
🛡️ 예외 처리 추가 제안
`@PostMapping`("/trigger")
public ResponseEntity<Void> trigger(`@RequestParam`(defaultValue = "1") Long userId) {
+ try {
NotificationMessage message = new NotificationMessage(
NotificationType.NEW_BID,
userId,
1L,
"테스트 경매 상품"
);
notificationService.save(message);
return ResponseEntity.ok().build();
+ } catch (Exception e) {
+ // 로그 기록 후 테스트를 위해 일관된 응답 반환
+ return ResponseEntity.status(500).build();
+ }
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/main/java/com/example/auctionnotification/notification/controller/NotificationTestController.java`
around lines 22 - 32, Wrap the call to notificationService.save(...) inside
NotificationTestController.trigger with a try-catch that catches Exception, logs
the error (including the exception) and prevents a 500 response, then return a
consistent ResponseEntity (e.g., ResponseEntity.ok().build()) even on failure;
specifically, surround the notificationService.save(message) call, catch
Exception e, call your controller logger/error reporter with the exception and a
short context message, and still return a successful ResponseEntity from trigger
so k6 tests receive a consistent response.
There was a problem hiding this comment.
테스트용이라서 그냥 넘어갈게 테스트 결과 왜곡 없이 나오는거 확인했어
There was a problem hiding this comment.
@soomin0209 확인해 주셨군요! 실제 테스트 결과에 영향이 없다면 괜찮습니다. 진행하세요 👍
| private final NotificationService notificationService; | ||
|
|
||
| @PostMapping("/trigger") | ||
| public ResponseEntity<Void> trigger(@RequestParam(defaultValue = "1") Long userId) { |
There was a problem hiding this comment.
userId 유효성 검증을 고려하세요.
테스트 엔드포인트이지만 음수나 비정상적인 큰 값이 전달될 경우 예상치 못한 동작이 발생할 수 있습니다. 간단한 유효성 검증을 추가하는 것을 권장합니다.
✅ 유효성 검증 추가 제안
`@PostMapping`("/trigger")
public ResponseEntity<Void> trigger(`@RequestParam`(defaultValue = "1") Long userId) {
+ if (userId == null || userId <= 0) {
+ return ResponseEntity.badRequest().build();
+ }
NotificationMessage message = new NotificationMessage(🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/main/java/com/example/auctionnotification/notification/controller/NotificationTestController.java`
at line 23, The trigger endpoint's userId parameter in
NotificationTestController.trigger lacks validation and may accept negative or
out-of-range values; add input validation at the start of the trigger method to
reject invalid userId (e.g., null, <=0, or > a sensible max) by returning a 400
Bad Request (ResponseEntity.badRequest()) or throwing a validation exception,
and document the constraint; use the method name
NotificationTestController.trigger and parameter userId to locate where to add
the check and ensure unit tests cover invalid, boundary, and valid cases.
There was a problem hiding this comment.
이것도 테스트용이라 넘어갈게
There was a problem hiding this comment.
@soomin0209 이해합니다! 테스트 전용 엔드포인트이고 @Profile("!prod")로 프로덕션에서는 비활성화되어 있으니 괜찮습니다. 👍
📝 작업 내용
✅ 체크리스트 (Checklist)
Summary by CodeRabbit
릴리스 노트
새로운 기능
리팩토링