[#61] 커넥션 고갈 해결을 위한 로그인 이력 저장 비동기 처리 #62

Merged
pricelees merged 9 commits from refactor/#61 into main 2025-10-14 00:28:45 +00:00
2 changed files with 25 additions and 13 deletions
Showing only changes of commit 4ec1e0c813 - Show all commits

View File

@ -31,7 +31,7 @@ export function maxIterations() {
} }
export function fetchUsers() { export function fetchUsers() {
const userCount = Math.round(maxIterations() * 1.2) const userCount = Math.round(maxIterations() * 0.5)
const userAccountRes = http.get(`${BASE_URL}/tests/users?count=${userCount}`) const userAccountRes = http.get(`${BASE_URL}/tests/users?count=${userCount}`)
if (userAccountRes.status !== 200) { if (userAccountRes.status !== 200) {

View File

@ -17,15 +17,17 @@ export const options = {
executor: 'ramping-vus', executor: 'ramping-vus',
startVUs: 0, startVUs: 0,
stages: [ stages: [
{ duration: '1m', target: 5 }, { duration: '1m', target: 100 },
{ duration: '1m', target: 10 }, { duration: '1m', target: 200 },
{ duration: '1m', target: 15 }, { duration: '1m', target: 300 },
{ duration: '1m', target: 20 }, { duration: '1m', target: 300 },
{ duration: '1m', target: 25 }, { duration: '1m', target: 400 },
{ duration: '1m', target: 30 }, { duration: '1m', target: 500 },
{ duration: '1m', target: 35 }, { duration: '2m', target: 500 },
{ duration: '1m', target: 40 }, { duration: '1m', target: 600 },
{ duration: '1m', target: 0 }, { duration: '1m', target: 800 },
{ duration: '1m', target: 1000 },
{ duration: '3m', target: 0 },
] ]
} }
}, },
@ -88,7 +90,7 @@ export default function (data) {
console.log(`로그인 실패: token=${accessToken}`) console.log(`로그인 실패: token=${accessToken}`)
return return
} }
const targetDate = randomDayBetween(1, 6) const targetDate = randomDayBetween(1, 4)
let availableScheduleId, selectedThemeId, selectedThemeInfo, reservationId, totalAmount let availableScheduleId, selectedThemeId, selectedThemeInfo, reservationId, totalAmount
@ -101,9 +103,11 @@ export default function (data) {
if (!schedules || schedules.length === 0) { if (!schedules || schedules.length === 0) {
console.log("일정 없음. 1회 재시도") console.log("일정 없음. 1회 재시도")
const storeId = randomItem(stores).storeId const storeId = randomItem(stores).storeId
const targetDate = randomDayBetween(0, 6) 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}`)
schedules = parseIdToString(res).data.schedules if (check(res, { '일정 조회 성공': (r) => r.status === 200 })) {
schedules = parseIdToString(res).data.schedules
}
} }
if (schedules && schedules.length > 0) { if (schedules && schedules.length > 0) {
@ -134,6 +138,8 @@ export default function (data) {
return; return;
} }
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))
@ -143,9 +149,15 @@ export default function (data) {
throw new Error("테마 상세 조회 실패") throw new Error("테마 상세 조회 실패")
} }
selectedThemeInfo = parseIdToString(themeInfoRes).data selectedThemeInfo = parseIdToString(themeInfoRes).data
isScheduleHeld = true
} }
}) })
if (!isScheduleHeld) {
console.log("일정 점유 실패")
return
}
let isPendingReservationCreated = false let isPendingReservationCreated = false
group(`예약 정보 입력 페이지`, function () { group(`예약 정보 입력 페이지`, function () {