Skip to content

Commit 0061dcd

Browse files
committed
Add more parameters and wait for server availability
1 parent 41601ec commit 0061dcd

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

scripts/stress.sh

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
#!/bin/bash
22

3-
thisdir=`dirname "$0"`
3+
thisdir=$(dirname "$0")
4+
5+
WRK_SETTINGS="--timeout 2s --threads 2 --connections 10 --duration 30s --rate 10000"
6+
JVM_PARAMS="-XX:ActiveProcessorCount=8 -Xms512m -Xmx512m"
7+
WAIT_SERVER=${WAIT_SERVER:-true}
8+
9+
# if no jar is provided as argument, exit and complain
10+
if [ "$#" -eq 0 ]; then
11+
echo "Usage: $0 <path-to-jar>"
12+
exit 1
13+
fi
414

515
# make sure the port is clear before enabling halting-on-error
6-
kill $(lsof -t -i:8080) &>/dev/null
16+
kill $(lsof -t -i:8080) &>/dev/null || true
717

818
set -euo pipefail
919

1020
${thisdir}/infra.sh -s
11-
java -XX:ActiveProcessorCount=8 -Xms512m -Xmx512m -jar $1 &
12-
jbang wrk2@hyperfoil -t2 -c100 -d30s -R 200 --latency http://localhost:8080/fruits
13-
scripts/infra.sh -d
14-
kill $(lsof -t -i:8080) &>/dev/null
21+
java ${JVM_PARAMS} -jar $1 &
22+
23+
if [ "$WAIT_SERVER" = "true" ]; then
24+
# wait until any HTTP response is received (connect succeeds)
25+
until curl -sS http://localhost:8080 >/dev/null 2>&1; do
26+
sleep 0.5
27+
done
28+
fi
29+
30+
echo "-----------------------------------------"
31+
echo "Starting wrk2"
32+
echo "-----------------------------------------"
33+
34+
jbang wrk2@hyperfoil ${WRK_SETTINGS} http://localhost:8080/fruits
35+
36+
echo "-----------------------------------------"
37+
echo "Stopped wrk2"
38+
echo "-----------------------------------------"
39+
40+
# Kill the Java process (listening on 8080)
41+
kill -TERM $(lsof -t -i:8080) &>/dev/null || true
42+
${thisdir}/infra.sh -d

0 commit comments

Comments
 (0)