-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#44]Feat: K6 테스트 코드 추가
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import http from 'k6/http'; | ||
import { check, sleep } from 'k6'; | ||
|
||
export let options = { | ||
stages: [ | ||
{ duration: '3m', target: 25 }, // 먼저 3분 동안 VUser 1에서 25까지 서서히 올린다. | ||
{ duration: '3m',target: 25 }, // Vuser 25에서 10분간 유지한다. | ||
{ duration: '3m', target: 125 }, // 다시 3분간 25에서 125까지 서서히 올린다. | ||
{ duration: '3m',target: 125 }, // 30분간 유지 | ||
{ duration: '3m', target: 0 }, // 3분 동안 Vuser 0으로 내려온다. | ||
], | ||
thresholds: { | ||
http_req_duration: ['p(95)<138'], // 전체 요청의 95%가 138ms 안에 들어오면 성공 | ||
}, | ||
}; | ||
|
||
const BASE_URL = 'http://localhost:8000/api/pets'; | ||
|
||
export default function () { | ||
// 사용자 ID를 2 또는 3으로 설정 | ||
const user_id = Math.random() < 0.5 ? 2 : 3; | ||
const url = `${BASE_URL}/list/${user_id}/`; | ||
|
||
// API 요청 | ||
const res = http.get(url); | ||
|
||
// 응답 확인 | ||
check(res, { | ||
'status is 200': (r) => r.status === 200, | ||
'response has data': (r) => r.json().length > 0, | ||
}); | ||
|
||
// 부하 테스트 간 지연 | ||
sleep(1); | ||
} |