Skip to content

Chore/#101 vacancy subscribe load test - #102

Closed
johe00123 wants to merge 2 commits into
mainfrom
chore/#101-vacancy-subscribe-load-test
Closed

Chore/#101 vacancy subscribe load test#102
johe00123 wants to merge 2 commits into
mainfrom
chore/#101-vacancy-subscribe-load-test

Conversation

@johe00123

Copy link
Copy Markdown
Contributor

📢 기능 설명

필요시 실행결과 스크린샷 첨부

연결된 issue

연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.

close #{이슈넘버}

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 이슈넘버를 적었는가?

johe00123 added 2 commits May 29, 2026 00:30
3-Phase 구조로 SADD/SMEMBERS/TTL 각각 측정
- PHASE 1: POST /api/v1/vacancy 100회 호출로 SADD 부하
- PHASE 2: k6/experimental/redis 로 SMEMBERS 응답시간 측정
- PHASE 3: TTL/EXISTS 로 키 자동 삭제 확인
@johe00123 johe00123 closed this May 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a k6 load test script (11-vacancy-test.js) to measure Redis SADD/SMEMBERS response times and verify TTL expiration, along with a Spring Boot utility (VacancyLoadTestTokenGenerator.java) to generate JWT tokens for the test. The review feedback suggests using the @Commit annotation in the token generator to eliminate the need for manual code changes during testing, updating the k6 script's documentation to reflect this simplification, and conditionally initializing the Redis client in the k6 script to avoid unnecessary connection attempts during the subscription phase.

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

테스트가 완료된 후 데이터를 데이터베이스에 커밋하기 위해 @Commit 어노테이션을 사용할 수 있습니다. 이렇게 하면 사용자가 테스트 실행 시 매번 @Transactional을 수동으로 주석 처리하고 다시 원복해야 하는 번거로움과 실수를 방지할 수 있습니다.

org.springframework.test.annotation.Commit을 임포트하여 적용해 주세요.

Suggested change
import org.springframework.transaction.annotation.Transactional;
import org.springframework.test.annotation.Commit;
import org.springframework.transaction.annotation.Transactional;

Comment on lines +44 to +46
@Test
@Transactional
void generateTokens() throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

메서드에 @Commit 어노테이션을 추가하여 테스트 실행 후 트랜잭션이 자동으로 커밋되도록 설정합니다.

Suggested change
@Test
@Transactional
void generateTokens() throws IOException {
@Test
@Transactional
@Commit
void generateTokens() throws IOException {

Comment thread k6/11-vacancy-test.js
Comment on lines +49 to +54
* 1. 백엔드 코드 임시 수정 (테스트 끝나면 반드시 원복!)
* 파일: backend/src/test/java/com/catchtable/loadtest/VacancyLoadTestTokenGenerator.java
* generateTokens() 위의 `@Transactional` 어노테이션을 주석 처리한다.
* ( @Transactional 이 살아있으면 시드 유저가 롤백되어 k6 요청에서 USER_NOT_FOUND 발생 )
*
* 2. 시드 유저 100명 + 토큰 100개 생성 (backend 디렉토리에서)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

VacancyLoadTestTokenGenerator@Commit 어노테이션을 적용하면 테스트 실행 시 코드를 임시로 수정하고 원복할 필요가 없어집니다. 따라서 이 가이드 부분을 제거하고 단계를 단순화할 수 있습니다.

Suggested change
* 1. 백엔드 코드 임시 수정 (테스트 끝나면 반드시 원복!)
* 파일: backend/src/test/java/com/catchtable/loadtest/VacancyLoadTestTokenGenerator.java
* generateTokens() 위의 `@Transactional` 어노테이션을 주석 처리한다.
* ( @Transactional 살아있으면 시드 유저가 롤백되어 k6 요청에서 USER_NOT_FOUND 발생 )
*
* 2. 시드 유저 100 + 토큰 100 생성 (backend 디렉토리에서)
* 1. 시드 유저 100 + 토큰 100 생성 (backend 디렉토리에서)

Comment thread k6/11-vacancy-test.js
Comment on lines +144 to +145
* - VacancyLoadTestTokenGenerator.java 의 `@Transactional` 주석 원복.
* - 시드 데이터 정리:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

테스트 종료 후 @Transactional 주석을 원복하는 수동 단계가 더 이상 필요하지 않으므로 가이드에서 제거합니다.

Suggested change
* - VacancyLoadTestTokenGenerator.java `@Transactional` 주석 원복.
* - 시드 데이터 정리:
* - 시드 데이터 정리:

Comment thread k6/11-vacancy-test.js
const auth = REDIS_PASSWORD ? `:${encodeURIComponent(REDIS_PASSWORD)}@` : '';
return `redis://${auth}${REDIS_ADDR}`;
})();
const redisClient = new redis.Client(REDIS_URL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

PHASEsubscribe일 때는 Redis를 사용하지 않으므로, Redis 클라이언트를 무조건 생성하기보다는 해당 페이즈가 아닐 때만 조건부로 생성하는 것이 좋습니다. 이렇게 하면 Redis 연결이 불가능한 환경에서 subscribe 부하 테스트만 실행할 때 발생할 수 있는 불필요한 연결 시도나 오류를 방지할 수 있습니다.

Suggested change
const redisClient = new redis.Client(REDIS_URL);
const redisClient = PHASE !== 'subscribe' ? new redis.Client(REDIS_URL) : null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant