Skip to content

[REFACTOR] 가상 스레드 전환 및 k6 테스트 시나리오 재구성#10

Merged
soomin0209 merged 2 commits into
devfrom
feature/virtual-thread-test
May 11, 2026
Merged

[REFACTOR] 가상 스레드 전환 및 k6 테스트 시나리오 재구성#10
soomin0209 merged 2 commits into
devfrom
feature/virtual-thread-test

Conversation

@soomin0209
Copy link
Copy Markdown
Collaborator

@soomin0209 soomin0209 commented May 10, 2026

📝 작업 내용

  • ThreadPoolTaskExecutor 제거 (AsyncConfig 삭제)
  • 테스트용 임시 로직 제거 (TestNotificationController, TestNotificationService)
  • NotificationTestController 실제 서비스 로직 기반으로 재구성
  • k6 테스트를 100VUs / 300VUs / Spike 시나리오로 재구성 (Tomcat 기본 스레드 200개 기준 전후 비교)

✅ 체크리스트 (Checklist)

  • 브랜치 이름 규칙을 준수했나요? (예: feat/login)
  • 코딩 컨벤션을 준수했나요?
  • 기능에 대한 테스트 코드를 작성/수행했나요?
  • 불필요한 주석이나 로그(console.log)를 제거했나요?

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 스파이크 부하 테스트 시나리오 추가
  • 리팩토링

    • 부하 테스트 구성 업데이트 (가상 사용자 수 및 테스트 엔드포인트 통합)
    • 비동기 실행자 설정 간소화
    • 테스트 컨트롤러 통합

Review Change Stack

@soomin0209 soomin0209 changed the title refactor: 가상 스레드 전환 및 k6 테스트 시나리오 재구성 [REFACTOR] 가상 스레드 전환 및 k6 테스트 시나리오 재구성 May 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@soomin0209 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 35 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 16801088-8e23-4fe7-9e64-ac077e273743

📥 Commits

Reviewing files that changed from the base of the PR and between 69c92b2 and 1c9dcfb.

📒 Files selected for processing (1)
  • src/main/java/com/example/auctionnotification/AuctionNotificationApplication.java

개요

이 PR은 실험적인 virtual thread 구성을 제거하고 테스트 인프라를 단순화합니다. AsyncConfig와 관련 테스트 서비스를 삭제한 후 통합된 /test/notifications/trigger 엔드포인트로 대체하고, k6 부하 테스트 스크립트를 업데이트하며, SseEmitterService는 기본 async executor를 사용하도록 전환합니다.

변경사항

테스트 인프라 통합 및 단순화

레이어 / 파일 요약
Async 구성 제거
src/main/java/com/example/auctionnotification/common/config/AsyncConfig.java
ThreadPoolTaskExecutor와 virtual-thread executor 빈 정의가 포함된 AsyncConfig 클래스 전체 삭제. SseEmitterService에서 주입되던 named executor 빈이 더 이상 사용되지 않음.
레거시 테스트 서비스 제거
src/main/java/com/example/auctionnotification/notification/controller/TestNotificationController.java, src/main/java/com/example/auctionnotification/notification/service/TestNotificationService.java
TestNotificationController와 TestNotificationService 클래스 전체 삭제. AsyncConfig에 의존하던 /test/platform-thread/test/virtual-thread 엔드포인트 제거.
통합 테스트 엔드포인트 구현
src/main/java/com/example/auctionnotification/notification/controller/NotificationTestController.java
새로운 NotificationTestController 추가. 단일 /test/notifications/trigger POST 엔드포인트로 이전의 두 엔드포인트 기능 통합. NotificationMessage(type=NEW_BID)를 생성하여 NotificationService를 통해 저장.
SseEmitterService Async 한정자 업데이트
src/main/java/com/example/auctionnotification/notification/service/SseEmitterService.java
send()sendPing() 메서드의 @Async("notificationExecutorWithVT") 한정자 제거. AsyncConfig 삭제에 따라 기본 async executor 사용으로 변경.
k6 부하 테스트 업데이트
k6/case1-100vus.js, k6/case2-300vus.js, k6/case3-spike.js
k6 테스트 스크립트를 새로운 /test/notifications/trigger 엔드포인트 호출로 업데이트. Case1은 VU 200에서 100으로 감소, Case2는 VU 200에서 300으로 증가, 새로운 spike 테스트(Case3) 추가. 모든 스크립트에 userId 쿼리 매개변수와 10초 타임아웃 옵션 포함.

예상 코드 리뷰 노력

🎯 3 (중간) | ⏱️ ~25분

연관된 PR

추천 리뷰어

  • imprity
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 요약하고 있으며, 가상 스레드 전환과 k6 테스트 시나리오 재구성이라는 주요 변경사항을 정확히 반영하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿을 따르고 있으며, 작업 내용과 체크리스트를 모두 포함하고 있습니다. 다만 '관련 이슈' 섹션이 비어있습니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/virtual-thread-test

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0dfb5fd and 69c92b2.

📒 Files selected for processing (8)
  • k6/case1-100vus.js
  • k6/case2-300vus.js
  • k6/case3-spike.js
  • src/main/java/com/example/auctionnotification/common/config/AsyncConfig.java
  • src/main/java/com/example/auctionnotification/notification/controller/NotificationTestController.java
  • src/main/java/com/example/auctionnotification/notification/controller/TestNotificationController.java
  • src/main/java/com/example/auctionnotification/notification/service/SseEmitterService.java
  • src/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

Comment on lines +22 to +32
@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();
}
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

예외 처리를 추가하세요.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트용이라서 그냥 넘어갈게 테스트 결과 왜곡 없이 나오는거 확인했어

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soomin0209 확인해 주셨군요! 실제 테스트 결과에 영향이 없다면 괜찮습니다. 진행하세요 👍

private final NotificationService notificationService;

@PostMapping("/trigger")
public ResponseEntity<Void> trigger(@RequestParam(defaultValue = "1") Long userId) {
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 테스트용이라 넘어갈게

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soomin0209 이해합니다! 테스트 전용 엔드포인트이고 @Profile("!prod")로 프로덕션에서는 비활성화되어 있으니 괜찮습니다. 👍

Copy link
Copy Markdown
Contributor

@imprity imprity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown

@hhjo96 hhjo96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@soomin0209 soomin0209 merged commit a0f7bfe into dev May 11, 2026
2 checks passed
@soomin0209 soomin0209 deleted the feature/virtual-thread-test branch May 11, 2026 00:45
@soomin0209 soomin0209 added Refactor 코드 개선 Test 테스트 관련 labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor 코드 개선 Test 테스트 관련

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants