Skip to content

Instantly share code, notes, and snippets.

@MathiasRenner
Last active November 18, 2016 10:14
Show Gist options
  • Save MathiasRenner/cac9361919c9d2f7535a35de222aa6a1 to your computer and use it in GitHub Desktop.
Save MathiasRenner/cac9361919c9d2f7535a35de222aa6a1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Copyright by Martin Jensen and Kaspar Nissen, http://kubecloud.io/files/kubecloud.pdf
# Adapt the target HOST parameter in line 18.
for i in "$@"
do
case $i in
-h=*|--host=*)
HOST="${i#*=}"
;;
*)
# unknown option
;;
esac
done
HOST="192.168.0.21"
if [ -z "$HOST" ]
then
echo "One argument required. Examples:"
else
rates=(100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000)
requests=10000
duration=5s
filename="replicas_1"
echo
echo
echo SETUP DONE
echo STARTING TEST
NOW=$(date "+%y-%m-%d_%H-%M-%S")
DIR=${filename}_${NOW}
mkdir $DIR
for j in $(seq 0 2); do
echo ITERATION ${j}
for i in $(seq 0 `expr ${#rates[@]} - 1`); do
current_rate=${rates[$i]}
current_duration=`echo "($requests + $current_rate-1)/$current_rate" | bc`
echo
echo Starting test with duration: $current_duration seconds and rate: $current_rate req/sec
echo "GET http://"$HOST"" | vegeta attack -rate="$current_rate" -duration="${current_duration}s" | tee $DIR/rate_${rates[$i]}-${j}.bin | vegeta report
done
echo ITERATION ${j}: Done - sleeping 20 s
sleep 20s
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment