Step 2: Move test folder to root
[integration/test.git] / tools / odl-mdsal-clustering-tests / clustering-performance-test / shard_multi_test.sh
1 #!/bin/bash
2
3 # author__ = "Jan Medved"
4 # copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
5 # license__ = "New-style BSD"
6 # email__ = "jmedved@cisco.com"
7
8 # Command to invoke
9 CMD="./shard_perf_test.py"
10
11 # Default number od $CMD instances to start
12 instances=1
13
14 # Default parameters for $CMD
15 resource="both"
16 auth=false
17 threads=1
18 requests=1000
19 odl_host=127.0.0.1
20 odl_port=8181
21
22 function usage {
23     echo "usage: $programname [-h?an] [-i instances] [-c cycles] [-f flows] [-t threads] [-o odl_host] [-p odl_port]"
24     echo "      -h|?          print this message"
25     echo "      -a            use default authentication ('admin/admin')"
26     echo "      -n            use the 'no-delete' flag in '$CMD'"
27     echo "      -i instances  number of '$CMD' instances to spawn"
28     echo "      -c cycles     number of cycles"
29     echo "      -f flows      number of flows"
30     echo "      -o odl_host   IP Address of the ODL controller"
31     echo "      -p odl_port   RESTCONF port in the ODL controller"
32     echo "      -t threads    number of threads"
33     echo "Optional flags/arguments [acfnopt] are passed to '$CMD'."
34 }
35
36
37 while getopts "h?ai:n:o:p:r:t:" opt; do
38     case "$opt" in
39     h|\?)
40         usage
41         exit 1
42         ;;
43     a)  auth=true
44         ;;
45     i)  instances=$OPTARG
46         ;;
47     n)  requests=$OPTARG
48         ;;
49     r)  resource=$OPTARG
50         ;;
51     o)  odl_host=$OPTARG
52         ;;
53     p)  odl_port=$OPTARG
54         ;;
55     t)  threads=$OPTARG
56         ;;
57     esac
58 done
59
60
61 echo "*** Creating $instances instance(s) of '$CMD' ***"
62
63 i=0
64 START_TIME=$SECONDS
65
66 while [  $i -lt $instances ]; do
67     CMD_STRING=$(printf '%s --resource %s --requests %s --threads %s' $CMD $resource $requests $threads)
68     CMD_STRING+=$(printf ' --host %s --port %s' $odl_host $odl_port)
69     if [ "$auth" = true ] ; then
70         CMD_STRING+=' --auth'
71     fi
72     echo "Starting instance $i: '$CMD_STRING'"
73     $CMD_STRING &
74
75     let i=$i+1
76 done
77
78 wait
79 ELAPSED_TIME=$(($SECONDS - $START_TIME))
80
81 echo "Done."
82
83 if [ "$ELAPSED_TIME" -gt 0 ] ; then
84     let "rate=(threads * $requests * $instances)/$ELAPSED_TIME"
85     echo "Measured rate: $rate"
86     echo "Measured time: $ELAPSED_TIME"
87 fi