From 3d55b8a8752f11421c48b15334c72673ae969de8 Mon Sep 17 00:00:00 2001 From: junha-ahn Date: Sun, 19 Nov 2023 19:14:34 +0900 Subject: [PATCH] chore: edit performanceTest sciprt --- src/performanceTest/scripts/lib/request.js | 3 ++- .../scripts/spikeTest/health_spikeTest.js | 3 ++- .../scripts/spikeTest/queue_spikeTest.js | 12 +++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/performanceTest/scripts/lib/request.js b/src/performanceTest/scripts/lib/request.js index ff86043..a809720 100644 --- a/src/performanceTest/scripts/lib/request.js +++ b/src/performanceTest/scripts/lib/request.js @@ -1,6 +1,7 @@ import http from "k6/http"; import { sleep } from "k6"; import config from "./config.js"; +import { randomInt } from "./helpers.js"; function parseQuery(query) { if (query == null) { @@ -27,7 +28,7 @@ export default class Request { } afterHook() { - sleep(this.SLEEP) + sleep(randomInt(this.SLEEP, this.SLEEP + 10)) } setToken(token) { diff --git a/src/performanceTest/scripts/spikeTest/health_spikeTest.js b/src/performanceTest/scripts/spikeTest/health_spikeTest.js index a35792e..6948373 100644 --- a/src/performanceTest/scripts/spikeTest/health_spikeTest.js +++ b/src/performanceTest/scripts/spikeTest/health_spikeTest.js @@ -1,4 +1,4 @@ -import { check } from "k6"; +import { check, sleep } from "k6"; import Request from "../lib/request.js"; import { encode } from "../lib/jwt.js"; import hooks from "../lib/hooks.js"; @@ -43,6 +43,7 @@ export default function () { const ID = randomInt(1, 1000000) req.setToken(encode(ID)) + sleep(randomInt(0, 10)) for (let i = 0; i < 10; i++) { check(req.helthCheck(), {"Success Health": isSuccess}); } diff --git a/src/performanceTest/scripts/spikeTest/queue_spikeTest.js b/src/performanceTest/scripts/spikeTest/queue_spikeTest.js index 4a34ebf..b6da5f3 100644 --- a/src/performanceTest/scripts/spikeTest/queue_spikeTest.js +++ b/src/performanceTest/scripts/spikeTest/queue_spikeTest.js @@ -1,4 +1,5 @@ -import { check } from "k6"; +import { check, sleep } from "k6"; +import exec from 'k6/execution'; import Request from "../lib/request.js"; import { encode } from "../lib/jwt.js"; import hooks from "../lib/hooks.js"; @@ -24,9 +25,9 @@ export const options = { scenarios: { contacts: { executor: 'per-vu-iterations', - vus: 1000, + vus: 2000, iterations: 1, - maxDuration: '1m', + maxDuration: '2m', }, }, @@ -48,9 +49,10 @@ export default function () { page: 0, sort: "id,asc" } - for (let i = 0; i < 13; i++) { + sleep(randomInt(0, 10)) + for (let i = 0; i < 5; i++) { check(req.getEvents(query), {"Success Get Events": isSuccess}); - query.page = query.page + randomInt(1, 10) + query.page = query.page + 3 } const eventId = 98 // maxAttendees = 191