install-eg.sh: LDAP config
[sitka/sitka-tools.git] / apachebench_eg / eg_ab.bash
1 #!/bin/bash
2 # content-type header
3 MYCONTENTTYPE="Content-type: text/plain"
4
5 TESTNAMES=`ls *.txt`
6 TESTFOLDER=`pwd`
7
8 TIMEOUT=9999
9 NUM_TRIES=20
10 NUM_CONCURRENT=2
11
12 usage()
13 {
14 cat << EOF
15 usage: $0 options
16
17 This script run the test1 or test2 over a machine.
18
19 OPTIONS:
20    -h      show this message
21    -s      server hostname *REQUIRED
22    -o      output folder name *REQUIRED
23    -t      data containing POST data as txt files [default is pwd]
24    -n      number of requests [50]
25    -c      number concurrent requests [2]
26    -g      include gnuplot output
27    -e      include CSV output
28 EOF
29 }
30
31
32
33 while getopts "hs:n:c:o:ge" opt; do
34   case $opt in
35     h) usage; exit 1;;
36     s) GATEWAY="http://$OPTARG/osrf-gateway-v1";;
37     t) TESTFOLDER=$OPTARG; TESTNAMES=`ls $TESTFOLDER *.txt`;;
38     s) GATEWAY="http://$OPTARG/osrf-gateway-v1";;
39     n) NUM_TRIES=$OPTARG;;
40     c) NUM_CONCURRENT=$OPTARG;;
41     o) OUTPUTFOLDER=$OPTARG;;
42     g) GNUPLOT_OUTPUT=1;;
43     e) CSV_OUTPUT=1;;
44   esac
45 done
46
47 if [ -z $GATEWAY ] || [ -z $OUTPUTFOLDER ]
48 then
49      usage
50      exit 1
51 fi
52
53
54 mkdir -p $OUTPUTFOLDER
55 pushd $OUTPUTFOLDER
56
57 for MYTEST in $TESTNAMES
58 do
59     echo "Running test $MYTEST"
60     if [ ! -z $GNUPLOT_OUTPUT ]
61     then
62         GNUPLOT="-g $MYTEST-gnuplot.tsv"
63     fi
64     if [ ! -z $CSV_OUTPUT ]
65     then
66         CSVOUT="-e $MYTEST.csv"
67     fi
68     ab -t $TIMEOUT -n $NUM_TRIES -c $NUM_CONCURRENT -p $TESTFOLDER/$MYTEST $GNUPLOT $CSVOUT -T "$MYCONTENTTYPE" "$GATEWAY" > $MYTEST-report.txt
69 done
70 popd