Skip to content

Commit

Permalink
dlock script
Browse files Browse the repository at this point in the history
  • Loading branch information
claycat committed Apr 23, 2024
1 parent 589afc2 commit 2ac4de0
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 21 deletions.
2 changes: 1 addition & 1 deletion stress-test/cleanup.sh
Original file line number Diff line number Diff line change
@@ -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}")
Expand Down
3 changes: 3 additions & 0 deletions stress-test/docker-compose.stress-k6-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 11 additions & 1 deletion stress-test/k6-scripts/stress.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function ({buyerEmailList, ticketingId}) {


// TODO: 락 방법론 마다 분리된 EP 잘 찔러보기
purchase(ticketingId, 1, email);
purchase(ticketingId, 1, email, setupVar.lockType);
}

function createUsers(users) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -163,6 +166,13 @@ function oLockPostBody() {
}
}

function dLockPostBody() {
return {
waitTime: setupVar.waitTime,
leaseTime: setupVar.leaseTime
}
}

function pLockPostBody() {
return {}
}
Expand Down
2 changes: 0 additions & 2 deletions stress-test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
35 changes: 35 additions & 0 deletions stress-test/run_dlock.sh
Original file line number Diff line number Diff line change
@@ -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
49 changes: 32 additions & 17 deletions stress-test/run_olock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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



2 changes: 2 additions & 0 deletions stress-test/run_plock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export LOCKTYPE

docker compose -f docker-compose.stress-k6-only.yml up

sleep 1
sh ./cleanup.sh

0 comments on commit 2ac4de0

Please sign in to comment.