#!/bin/bash # content-type header MYCONTENTTYPE="Content-type: text/plain" TESTNAMES=`ls *.txt` TESTFOLDER=`pwd` TIMEOUT=9999 NUM_TRIES=20 NUM_CONCURRENT=2 usage() { cat << EOF usage: $0 options This script run the test1 or test2 over a machine. OPTIONS: -h show this message -s server hostname *REQUIRED -o output folder name *REQUIRED -t data containing POST data as txt files [default is pwd] -n number of requests [50] -c number concurrent requests [2] -g include gnuplot output -e include CSV output EOF } while getopts "hs:n:c:o:ge" opt; do case $opt in h) usage; exit 1;; s) GATEWAY="http://$OPTARG/osrf-gateway-v1";; t) TESTFOLDER=$OPTARG; TESTNAMES=`ls $TESTFOLDER *.txt`;; s) GATEWAY="http://$OPTARG/osrf-gateway-v1";; n) NUM_TRIES=$OPTARG;; c) NUM_CONCURRENT=$OPTARG;; o) OUTPUTFOLDER=$OPTARG;; g) GNUPLOT_OUTPUT=1;; e) CSV_OUTPUT=1;; esac done if [ -z $GATEWAY ] || [ -z $OUTPUTFOLDER ] then usage exit 1 fi mkdir -p $OUTPUTFOLDER pushd $OUTPUTFOLDER for MYTEST in $TESTNAMES do echo "Running test $MYTEST" if [ ! -z $GNUPLOT_OUTPUT ] then GNUPLOT="-g $MYTEST-gnuplot.tsv" fi if [ ! -z $CSV_OUTPUT ] then CSVOUT="-e $MYTEST.csv" fi ab -t $TIMEOUT -n $NUM_TRIES -c $NUM_CONCURRENT -p $TESTFOLDER/$MYTEST $GNUPLOT $CSVOUT -T "$MYCONTENTTYPE" "$GATEWAY" > $MYTEST-report.txt done popd