Created
October 25, 2020 20:26
-
-
Save tsmx/d40bb7770786055603d1a175496f359f to your computer and use it in GitHub Desktop.
A simple automation script for Apache Benchmark with bearer token authentication. Running multiple scenarios of requests/concurrency.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# set URL to test here | |
url=YOUR_URL_HERE | |
# set test iterations here: requests|concurrent | |
declare -a iterations=("1|1" "10|10" "100|20" "100|100" "1000|50" "1000|100") | |
# first argument is the bearer token | |
if [ -z "$1" ] | |
then | |
echo "No Bearer token supplied" | |
exit -1 | |
fi | |
token=$1 | |
function get_perf_stats { | |
echo "$1/$2" | |
ab -H "Authorization: Bearer $token" -n $1 -c $2 -d -S -q $url | grep "\[ms\] (mean)" | |
echo "" | |
} | |
for val in ${iterations[@]}; do | |
requests=$(echo $val | cut -d '|' -f 1) | |
concurrent=$(echo $val | cut -d '|' -f 2) | |
get_perf_stats $requests $concurrent | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment