generated from pricelees/issue-pr-template
[#61] 커넥션 고갈 해결을 위한 로그인 이력 저장 비동기 처리 #62
@ -95,42 +95,46 @@ 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 res = http.get(`${BASE_URL}/stores/${storeId}/schedules?date=${targetDate}`)
|
||||||
const storeId = randomItem(stores).storeId
|
const result = check(res, {'일정 조회 성공': (r) => r.status === 200})
|
||||||
const targetDate = randomDayBetween(1, 4)
|
if (result !== true) {
|
||||||
const res = http.get(`${BASE_URL}/stores/${storeId}/schedules?date=${targetDate}`)
|
continue
|
||||||
if (check(res, { '일정 조회 성공': (r) => r.status === 200 })) {
|
|
||||||
schedules = parseIdToString(res).data.schedules
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
schedules = parseIdToString(res).data.schedules
|
||||||
if (schedules && schedules.length > 0) {
|
if (schedules && schedules.length > 0) {
|
||||||
group(`일부 테마는 상세 조회`, function () {
|
break
|
||||||
const themesByStoreAndDate = schedules.map(s => s.theme)
|
|
||||||
if (!themesByStoreAndDate && themesByStoreAndDate.length <= 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const randomThemesForFetchDetail = extractRandomThemeForFetchDetail(themesByStoreAndDate)
|
|
||||||
|
|
||||||
randomThemesForFetchDetail.forEach(id => {
|
|
||||||
http.get(`${BASE_URL}/themes/${id}`)
|
|
||||||
sleep(10)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
const availableSchedules = schedules.filter((s) => s.schedule.status === 'AVAILABLE')
|
|
||||||
if (availableSchedules.length > 0) {
|
|
||||||
const availableSchedule = randomItem(availableSchedules)
|
|
||||||
availableScheduleId = availableSchedule.schedule.id
|
|
||||||
selectedThemeId = availableSchedule.theme.id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
searchTrial++
|
||||||
|
sleep(10)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (schedules.length <= 0) {
|
||||||
|
console.log(`5회 시도에도 일정 조회 실패`)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
group(`일부 테마는 상세 조회`, function () {
|
||||||
|
const themesByStoreAndDate = schedules.map(s => s.theme)
|
||||||
|
if (!themesByStoreAndDate && themesByStoreAndDate.length <= 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const randomThemesForFetchDetail = extractRandomThemeForFetchDetail(themesByStoreAndDate)
|
||||||
|
|
||||||
|
randomThemesForFetchDetail.forEach(id => {
|
||||||
|
http.get(`${BASE_URL}/themes/${id}`)
|
||||||
|
sleep(10)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const availableSchedules = schedules.filter((s) => s.schedule.status === 'AVAILABLE')
|
||||||
|
if (availableSchedules.length > 0) {
|
||||||
|
const availableSchedule = randomItem(availableSchedules)
|
||||||
|
availableScheduleId = availableSchedule.schedule.id
|
||||||
|
selectedThemeId = availableSchedule.theme.id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -139,33 +143,33 @@ 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 () {
|
||||||
const userContactRes = http.get(`${BASE_URL}/users/contact`, getHeaders(accessToken))
|
const userContactRes = http.get(`${BASE_URL}/users/contact`, getHeaders(accessToken))
|
||||||
|
|
||||||
if (!check(userContactRes, { '회원 연락처 조회 성공': (r) => r.status === 200 })) {
|
if (!check(userContactRes, {'회원 연락처 조회 성공': (r) => r.status === 200})) {
|
||||||
throw new Error("회원 연락처 조회 과정에서 예외 발생")
|
throw new Error("회원 연락처 조회 과정에서 예외 발생")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +238,7 @@ export default function (data) {
|
|||||||
sleep(30)
|
sleep(30)
|
||||||
const confirmOrderRes = http.post(`${BASE_URL}/orders/${reservationId}/confirm`, payload, getHeaders(accessToken))
|
const confirmOrderRes = http.post(`${BASE_URL}/orders/${reservationId}/confirm`, payload, getHeaders(accessToken))
|
||||||
|
|
||||||
if (check(confirmOrderRes, { '예약 확정 성공': (r) => r.status === 200 })) {
|
if (check(confirmOrderRes, {'예약 확정 성공': (r) => r.status === 200})) {
|
||||||
isConfirmed = true
|
isConfirmed = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -253,7 +255,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("예약 확정 성공")
|
console.log("예약 확정 성공")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user