Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions scripts/stress.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
#!/bin/bash

thisdir=`dirname "$0"`
thisdir=$(dirname "$0")

WRK_SETTINGS="--timeout 2s --threads 2 --connections 10 --duration 30s --rate 200"
JVM_PARAMS="-XX:ActiveProcessorCount=8 -Xms512m -Xmx512m"
WAIT_SERVER=${WAIT_SERVER:-true}

# if no jar is provided as argument, exit and complain
if [ "$#" -eq 0 ]; then
echo "Usage: $0 <path-to-jar>"
exit 1
fi

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

set -euo pipefail

${thisdir}/infra.sh -s
java -XX:ActiveProcessorCount=8 -Xms512m -Xmx512m -jar $1 &
jbang wrk2@hyperfoil -t2 -c100 -d30s -R 200 --latency http://localhost:8080/fruits
scripts/infra.sh -d
kill $(lsof -t -i:8080) &>/dev/null
java ${JVM_PARAMS} -jar $1 &

if [ "$WAIT_SERVER" = "true" ]; then
echo "Waiting for server to be ready..."
# wait until any HTTP response is received (connect succeeds)
until curl -sS http://localhost:8080 >/dev/null 2>&1; do
sleep 0.5
done
fi

echo "-----------------------------------------"
echo "Starting wrk2"
echo "-----------------------------------------"

jbang wrk2@hyperfoil ${WRK_SETTINGS} http://localhost:8080/fruits

echo "-----------------------------------------"
echo "Stopped wrk2"
echo "-----------------------------------------"

# Kill the Java process (listening on 8080)
kill -TERM $(lsof -t -i:8080) &>/dev/null || true
${thisdir}/infra.sh -d