generated from pricelees/issue-pr-template
[#58] K6 성능 테스트 도입 #59
@ -14,9 +14,19 @@ import http from 'k6/http';
|
|||||||
export const options = {
|
export const options = {
|
||||||
scenarios: {
|
scenarios: {
|
||||||
user_reservation: {
|
user_reservation: {
|
||||||
executor: 'constant-vus',
|
executor: 'ramping-vus',
|
||||||
vus: 15,
|
startVUs: 0,
|
||||||
duration: '15m'
|
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}`)
|
const res = http.get(`${BASE_URL}/stores/${storeId}/schedules?date=${targetDate}`)
|
||||||
if (check(res, { '일정 조회 성공': (r) => r.status === 200 })) {
|
if (check(res, { '일정 조회 성공': (r) => r.status === 200 })) {
|
||||||
sleep(20)
|
sleep(20)
|
||||||
const schedules = parseIdToString(res).data.schedules
|
let schedules = parseIdToString(res).data.schedules
|
||||||
if (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 () {
|
group(`일부 테마는 상세 조회`, function () {
|
||||||
const themesByStoreAndDate = schedules.map(s => s.theme)
|
const themesByStoreAndDate = schedules.map(s => s.theme)
|
||||||
if (!themesByStoreAndDate && themesByStoreAndDate.length <= 0) {
|
if (!themesByStoreAndDate && themesByStoreAndDate.length <= 0) {
|
||||||
@ -112,7 +131,6 @@ export default function (data) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!availableScheduleId) {
|
if (!availableScheduleId) {
|
||||||
console.log("이용 가능한 일정 없음.")
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +242,7 @@ export default function (data) {
|
|||||||
sleep(10)
|
sleep(10)
|
||||||
const temporalConfirmRes = http.post(`${BASE_URL}/reservations/${reservationId}/confirm`)
|
const temporalConfirmRes = http.post(`${BASE_URL}/reservations/${reservationId}/confirm`)
|
||||||
if (check(temporalConfirmRes, { '임시 예약 확정 성공': (r) => r.status === 200})) {
|
if (check(temporalConfirmRes, { '임시 예약 확정 성공': (r) => r.status === 200})) {
|
||||||
|
console.log("예약 확정 성공")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
throw new Error('임시 예약 확정 실패')
|
throw new Error('임시 예약 확정 실패')
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
import http from 'k6/http';
|
import http from 'k6/http';
|
||||||
import {check, sleep} from 'k6';
|
import {check, sleep} from 'k6';
|
||||||
import exec from 'k6/execution';
|
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';
|
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;
|
const TOTAL_ITERATIONS = 85212;
|
||||||
|
|
||||||
export const options = {
|
export const options = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user