diff --git a/stress-test/cleanup.sh b/stress-test/cleanup.sh index f914309..4203946 100644 --- a/stress-test/cleanup.sh +++ b/stress-test/cleanup.sh @@ -1,7 +1,7 @@ #!/bin/bash # Endpoint and resource -url="localhost:4000/api/stress-test" +url="172.17.48.1:4000/api/stress-test" # Send DELETE request response=$(curl -s -X DELETE "$url" -w "%{http_code}") diff --git a/stress-test/docker-compose.stress-k6-only.yml b/stress-test/docker-compose.stress-k6-only.yml index 7cec816..7e7c61e 100644 --- a/stress-test/docker-compose.stress-k6-only.yml +++ b/stress-test/docker-compose.stress-k6-only.yml @@ -14,6 +14,9 @@ services: -e LOCKTYPE=${LOCKTYPE} -e BACKOFF=${BACKOFF} -e RETRY=${RETRY} + -e WAITTIME=${WAITTIME} + -e LEASETIME=${LEASETIME} + /scripts/stress.js extra_hosts: - "host.docker.internal:host-gateway" diff --git a/stress-test/k6-scripts/stress.js b/stress-test/k6-scripts/stress.js index 22af8e0..c90ef7b 100644 --- a/stress-test/k6-scripts/stress.js +++ b/stress-test/k6-scripts/stress.js @@ -90,7 +90,7 @@ export default function ({buyerEmailList, ticketingId}) { // TODO: 락 방법론 마다 분리된 EP 잘 찔러보기 - purchase(ticketingId, 1, email); + purchase(ticketingId, 1, email, setupVar.lockType); } function createUsers(users) { @@ -131,6 +131,9 @@ function purchase(ticketingId, count, buyerEmail, lockType) { case 'o-lock' : Object.assign(postBody, oLockPostBody()); break; + case 'd-lock' : + Object.assign(postBody, dLockPostBody()); + break; case 'p-lock': break; } @@ -163,6 +166,13 @@ function oLockPostBody() { } } +function dLockPostBody() { + return { + waitTime: setupVar.waitTime, + leaseTime: setupVar.leaseTime + } +} + function pLockPostBody() { return {} } diff --git a/stress-test/run.sh b/stress-test/run.sh index 6a47acf..e4068e0 100644 --- a/stress-test/run.sh +++ b/stress-test/run.sh @@ -13,8 +13,6 @@ for vsr in "${vsrs[@]}"; do for ((i = 1; i <= $1; i++)); do # sh ./run_plock.sh ${vsr} ${ticket} ${i} sh ./run_olock.sh ${vsr} ${ticket} ${i} - sleep 1 - sh ./cleanup.sh done done done \ No newline at end of file diff --git a/stress-test/run_dlock.sh b/stress-test/run_dlock.sh index e69de29..4edae29 100644 --- a/stress-test/run_dlock.sh +++ b/stress-test/run_dlock.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# ${1} : VSR +# ${2} : TICKETS +# ${3} : ITERATION +# ${4} : WAITTIME +# ${5} : LEASETIME + +declare -a waittimes=(100 300) +declare -a leasetimes=(50 100) + +for waittime in "${waittimes[@]}"; do + for leasetime in "${leasetimes[@]}"; do + + echo "Run with VSR:${1} TICKETS:${2} ITERATION:${3} WAITTIME:${waittime} LEASETIME: ${leasetime}" + + VSR=${1} + TICKETS=${2} + ITERATION=${3} + LOCKTYPE="d-lock" + WAITTIME=${waittime} + LEASETIME=${leasetime} + + export VSR + export TICKETS + export ITERATION + export LOCKTYPE + export WAITTIME + export LEASETIME + + docker compose -f docker-compose.stress-k6-only.yml up + + sleep 1 + sh ./cleanup.sh + done +done diff --git a/stress-test/run_olock.sh b/stress-test/run_olock.sh index 0c108e6..1d4e421 100644 --- a/stress-test/run_olock.sh +++ b/stress-test/run_olock.sh @@ -5,20 +5,35 @@ # ${4} : BACKOFF # ${5} : RETRY -echo "Run with VSR:${1} TICKETS:${2} ITERATION:${3} BACKOFF:${4} RETRY: ${5}" - -VSR=${1} -TICKETS=${2} -ITERATION=${3} -LOCKTYPE="o-lock" -BACKOFF=${4} -RETRY=${5} - -export VSR -export TICKETS -export ITERATION -export LOCKTYPE -export BACKOFF -export RETRY - -docker compose -f docker-compose.stress-k6-only.yml up +declare -a backoffs=(100 300) +declare -a retries=(30 60) + + +for backoff in "${backoffs[@]}"; do + for retry in "${retries[@]}"; do + + echo "Run with VSR:${1} TICKETS:${2} ITERATION:${3} BACKOFF:${backoff} RETRY: ${retry}" + + VSR=${1} + TICKETS=${2} + ITERATION=${3} + LOCKTYPE="o-lock" + BACKOFF=${backoff} + RETRY=${retry} + + export VSR + export TICKETS + export ITERATION + export LOCKTYPE + export BACKOFF + export RETRY + + docker compose -f docker-compose.stress-k6-only.yml up + + sleep 1 + sh ./cleanup.sh + done +done + + + diff --git a/stress-test/run_plock.sh b/stress-test/run_plock.sh index 2915ef7..66bf3ab 100644 --- a/stress-test/run_plock.sh +++ b/stress-test/run_plock.sh @@ -17,3 +17,5 @@ export LOCKTYPE docker compose -f docker-compose.stress-k6-only.yml up +sleep 1 +sh ./cleanup.sh