-
Notifications
You must be signed in to change notification settings - Fork 2
/
abtest.sh
executable file
·49 lines (39 loc) · 1.23 KB
/
abtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#
# test httpServer using Apache Bench (ab)
# https://diamantidis.github.io/2020/07/15/load-testing-with-apache-bench
#
concurrentClients=10
numberRequests=200
ipaddress="localhost"
port=3000
path='transcript?speech=..%2Faudio%2F2830-3980-0043.wav'
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
scriptpath="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
bodyfile=$scriptpath/body.json
# body.json contains the JSON you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
# -l Accept variable document length (use this for dynamic pages)
# https://stackoverflow.com/questions/579450/load-testing-with-ab-fake-failed-requests-length
# -r: flag to not exit on socket receive errors
# -k: Use HTTP KeepAlive feature
abcommand="ab \
-c $concurrentClients \
-n $numberRequests \
-l \
-k \
-r \
'http://$ipaddress:$port/$path'"
echo
echo "test httpServer using apache bench"
echo " $concurrentClients concurrent clients"
echo " $numberRequests requests to run"
echo
echo "full ab command"
echo " $abcommand"
echo
eval $abcommand