Merge "need a testplan file for Li-redesign cbench test"
[integration/test.git] / test / tools / odl-mdsal-clustering-tests / clustering-performance-test / multi-blaster.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 # Init our own program name
9 program_name=$0
10
11 # Command to invoke
12 CMD="./flow_config_blaster.py"
13
14 # Default number of $CMD instances
15 instances=1
16
17 # Default parameters for $CMD
18 no_delete=false
19 auth=false
20 threads=1
21 flows=1000
22 cycles=1
23 odl_host=127.0.0.1
24 odl_port=8181
25
26 function usage {
27     echo "usage: $program_name [-h?an] [-i instances] [-c cycles] [-f flows] [-t threads] [-o odl_host] [-p odl_port]"
28     echo "      -h|?          print this message"
29     echo "      -a            use default authentication ('admin/admin')"
30     echo "      -n            use the 'no-delete' flag in '$CMD'"
31     echo "      -i instances  number of '$CMD' instances to spawn"
32     echo "      -c cycles     number of cycles"
33     echo "      -f flows      number of flows"
34     echo "      -o odl_host   IP Address of the ODL controller"
35     echo "      -p odl_port   RESTCONF port in the ODL controller"
36     echo "      -t threads    number of threads"
37     echo "Optional flags/arguments [acfnopt] are passed to '$CMD'."
38 }
39
40 # Initialize our own variables:
41
42
43 while getopts "h?ac:f:i:no:p:t:" opt; do
44     case "$opt" in
45     h|\?)
46         usage
47         exit 1
48         ;;
49     a)  auth=true
50         ;;
51     c)  cycles=$OPTARG
52         ;;
53     f)  flows=$OPTARG
54         ;;
55     i)  instances=$OPTARG
56         ;;
57     n)  no_delete=true
58         ;;
59     o)  odl_host=$OPTARG
60         ;;
61     p)  odl_port=$OPTARG
62         ;;
63     t)  threads=$OPTARG
64         ;;
65     esac
66 done
67
68 echo "*** Creating $instances instance(s) of '$CMD' ***"
69 echo ""
70
71 let "flows_per_instance=$cycles * $flows * $threads"
72 i=0
73
74 START_TIME=$SECONDS
75 while [  $i -lt $instances ]; do
76     let "startflow=$flows_per_instance * $i"
77
78     CMD_STRING=$(printf '%s --cycles %s --flows %s --threads %s ' $CMD $cycles $flows $threads)
79     CMD_STRING+=$(printf ' --host %s --port %s --startflow %s' $odl_host $odl_port $startflow)
80     if [ "$auth" = true ] ; then
81         CMD_STRING+=' --auth'
82     fi
83     if [ "$no_delete" = true ] ; then
84         CMD_STRING+=' --no-delete'
85     fi
86
87     echo "Starting instance $i: '$CMD_STRING'"
88     let i=$i+1
89     $CMD_STRING &
90 done
91
92 wait
93 ELAPSED_TIME=$(($SECONDS - $START_TIME))
94
95 echo "Done."
96
97 if [ "$ELAPSED_TIME" -gt 0 ] ; then
98     let "rate=($flows_per_instance * $instances)/$ELAPSED_TIME"
99     echo "Measured rate: $rate"
100     echo "Measured time: $ELAPSED_TIME"
101 fi