refactor: 예약 성능 테스트 스크립트 수정

This commit is contained in:
이상진 2025-10-12 15:49:06 +09:00
parent 0ff0f4e9fc
commit da81474ff4

View File

@ -95,22 +95,28 @@ export default function (data) {
let availableScheduleId, selectedThemeId, selectedThemeInfo, reservationId, totalAmount let availableScheduleId, selectedThemeId, selectedThemeInfo, reservationId, totalAmount
group(`매장=${storeId}, 날짜=${targetDate}의 일정 조회`, function () { group(`매장=${storeId}, 날짜=${targetDate}의 일정 조회`, function () {
const res = http.get(`${BASE_URL}/stores/${storeId}/schedules?date=${targetDate}`) let searchTrial = 0
if (check(res, { '일정 조회 성공': (r) => r.status === 200 })) { let schedules
sleep(20)
let schedules = parseIdToString(res).data.schedules
if (!schedules || schedules.length === 0) { while (searchTrial < 5) {
console.log("일정 없음. 1회 재시도")
const storeId = randomItem(stores).storeId
const targetDate = randomDayBetween(1, 4)
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 })) { const result = check(res, {'일정 조회 성공': (r) => r.status === 200})
if (result !== true) {
continue
}
schedules = parseIdToString(res).data.schedules schedules = parseIdToString(res).data.schedules
if (schedules && schedules.length > 0) {
break
} }
searchTrial++
sleep(10)
}
if (schedules.length <= 0) {
console.log(`5회 시도에도 일정 조회 실패`)
return;
} }
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) {
@ -130,8 +136,6 @@ export default function (data) {
availableScheduleId = availableSchedule.schedule.id availableScheduleId = availableSchedule.schedule.id
selectedThemeId = availableSchedule.theme.id selectedThemeId = availableSchedule.theme.id
} }
}
}
}) })
if (!availableScheduleId) { if (!availableScheduleId) {
@ -139,27 +143,27 @@ export default function (data) {
} }
let isScheduleHeld = false let isScheduleHeld = false
group(`일정 Holding 및 테마 정보 조회 -> 예약 과정중 첫 페이지의 작업 완료`, function () { group(`일정 Holding 및 테마 정보 조회 -> 예약 과정중 첫 페이지의 작업 완료`, function () {
const holdRes = http.post(`${BASE_URL}/schedules/${availableScheduleId}/hold`, null, getHeaders(accessToken)) const holdRes = http.post(`${BASE_URL}/schedules/${availableScheduleId}/hold`, null, getHeaders(accessToken))
const body = JSON.parse(holdRes)
if (check(holdRes, {'일정 점유 성공': (r) => r.status === 200})) { if (check(holdRes, {'일정 점유 성공': (r) => r.status === 200})) {
const themeInfoRes = http.get(`${BASE_URL}/themes/${selectedThemeId}`) const themeInfoRes = http.get(`${BASE_URL}/themes/${selectedThemeId}`)
if (themeInfoRes.status !== 200) {
throw new Error("테마 상세 조회 실패")
}
selectedThemeInfo = parseIdToString(themeInfoRes).data selectedThemeInfo = parseIdToString(themeInfoRes).data
isScheduleHeld = true isScheduleHeld = true
} else {
const errorCode = body.code
const errorMessage = body.message
console.log(`일정 점유 실패: code=${errorCode}, message=${errorMessage}`)
} }
}) })
if (!isScheduleHeld) { if (!isScheduleHeld || !selectedThemeInfo) {
console.log("일정 점유 실패")
return return
} }
let isPendingReservationCreated = false let isPendingReservationCreated = false
group(`예약 정보 입력 페이지`, function () { group(`예약 정보 입력 페이지`, function () {
let userName, userContact let userName, userContact
group(`회원 연락처 조회`, function () { group(`회원 연락처 조회`, function () {
@ -210,14 +214,12 @@ export default function (data) {
}) })
if (!isPendingReservationCreated) { if (!isPendingReservationCreated) {
console.log("회원의 예약 정보 입력 중 페이지 이탈")
return; return;
} }
group(`결제 및 예약 확정`, function () { group(`결제 및 예약 확정`, function () {
// 20%의 유저는 결제 화면에서 나감 => 배치의 자동 만료 처리 테스트 // 20%의 유저는 결제 화면에서 나감 => 배치의 자동 만료 처리 테스트
if (Math.random() <= 0.2) { if (Math.random() <= 0.2) {
console.log("결제 페이지에서의 이탈")
return return
} }