generated from pricelees/issue-pr-template
refactor: k6 테스트 스크립트 수정
This commit is contained in:
parent
f9bb2f8746
commit
a16144a400
@ -14,9 +14,19 @@ import http from 'k6/http';
|
||||
export const options = {
|
||||
scenarios: {
|
||||
user_reservation: {
|
||||
executor: 'constant-vus',
|
||||
vus: 15,
|
||||
duration: '15m'
|
||||
executor: 'ramping-vus',
|
||||
startVUs: 0,
|
||||
stages: [
|
||||
{ duration: '1m', target: 5 },
|
||||
{ duration: '1m', target: 10 },
|
||||
{ duration: '1m', target: 15 },
|
||||
{ duration: '1m', target: 20 },
|
||||
{ duration: '1m', target: 25 },
|
||||
{ duration: '1m', target: 30 },
|
||||
{ duration: '1m', target: 35 },
|
||||
{ duration: '1m', target: 40 },
|
||||
{ duration: '1m', target: 0 },
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@ -86,8 +96,17 @@ export default function (data) {
|
||||
const res = http.get(`${BASE_URL}/stores/${storeId}/schedules?date=${targetDate}`)
|
||||
if (check(res, { '일정 조회 성공': (r) => r.status === 200 })) {
|
||||
sleep(20)
|
||||
const schedules = parseIdToString(res).data.schedules
|
||||
if (schedules) {
|
||||
let schedules = parseIdToString(res).data.schedules
|
||||
|
||||
if (!schedules || schedules.length === 0) {
|
||||
console.log("일정 없음. 1회 재시도")
|
||||
const storeId = randomItem(stores).storeId
|
||||
const targetDate = randomDayBetween(0, 6)
|
||||
const res = http.get(`${BASE_URL}/stores/${storeId}/schedules?date=${targetDate}`)
|
||||
schedules = parseIdToString(res).data.schedules
|
||||
}
|
||||
|
||||
if (schedules && schedules.length > 0) {
|
||||
group(`일부 테마는 상세 조회`, function () {
|
||||
const themesByStoreAndDate = schedules.map(s => s.theme)
|
||||
if (!themesByStoreAndDate && themesByStoreAndDate.length <= 0) {
|
||||
@ -112,7 +131,6 @@ export default function (data) {
|
||||
})
|
||||
|
||||
if (!availableScheduleId) {
|
||||
console.log("이용 가능한 일정 없음.")
|
||||
return;
|
||||
}
|
||||
|
||||
@ -224,6 +242,7 @@ export default function (data) {
|
||||
sleep(10)
|
||||
const temporalConfirmRes = http.post(`${BASE_URL}/reservations/${reservationId}/confirm`)
|
||||
if (check(temporalConfirmRes, { '임시 예약 확정 성공': (r) => r.status === 200})) {
|
||||
console.log("예약 확정 성공")
|
||||
return
|
||||
}
|
||||
throw new Error('임시 예약 확정 실패')
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import http from 'k6/http';
|
||||
import {check, sleep} from 'k6';
|
||||
import exec from 'k6/execution';
|
||||
import {getHeaders, login, parseIdToString} from "./common.js";
|
||||
import {BASE_URL, getHeaders, login, parseIdToString} from "./common.js";
|
||||
import {randomIntBetween} from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
|
||||
|
||||
|
||||
const BASE_URL = __ENV.BASE_URL || 'http://localhost:8080';
|
||||
|
||||
const TOTAL_ITERATIONS = 85212;
|
||||
|
||||
export const options = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user