Step 2: Move test folder to root
[integration/test.git] / 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 host=127.0.0.1
24 port=8181
25 fpr=1
26
27 function usage {
28     echo "usage: $program_name [-h?an] [-i instances] [-c cycles] [-f flows] [-t threads] [-o odl_host] [-p odl_port]"
29     echo "      -h|?          print this message"
30     echo "      -a            use default authentication ('admin/admin')"
31     echo "      -b batchsize  # offlows per RESTCONF add-flow request"
32     echo "      -n            use the 'no-delete' flag in '$CMD'"
33     echo "      -i instances  number of '$CMD' instances to spawn"
34     echo "      -c cycles     number of cycles"
35     echo "      -f flows      number of flows"
36     echo "      -h host       IP Address of the ODL controller"
37     echo "      -p port       RESTCONF port in the ODL controller"
38     echo "      -t threads    number of threads"
39     echo "Optional flags/arguments [acfnopt] are passed to '$CMD'."
40 }
41
42 # Initialize our own variables:
43
44
45 while getopts "h?ab:c:f:i:no:p:t:" opt; do
46     case "$opt" in
47     h|\?)
48         usage
49         exit 1
50         ;;
51     a)  auth=true
52         ;;
53     b)  fpr=$OPTARG
54         ;;
55     c)  cycles=$OPTARG
56         ;;
57     f)  flows=$OPTARG
58         ;;
59     i)  instances=$OPTARG
60         ;;
61     n)  no_delete=true
62         ;;
63     h)  host=$OPTARG
64         ;;
65     p)  port=$OPTARG
66         ;;
67     t)  threads=$OPTARG
68         ;;
69     esac
70 done
71
72 echo "*** Creating $instances instance(s) of '$CMD' ***"
73 echo ""
74
75 let "flows_per_instance=$cycles * $flows * $threads"
76 i=0
77
78 START_TIME=$SECONDS
79 while [  $i -lt $instances ]; do
80     let "startflow=$flows_per_instance * $i"
81
82     CMD_STRING=$(printf '%s --cycles %s --flows %s --threads %s ' $CMD $cycles $flows $threads)
83     CMD_STRING+=$(printf ' --host %s --port %s --startflow %s --fpr %s' $host $port $startflow $fpr)
84     if [ "$auth" = true ] ; then
85         CMD_STRING+=' --auth'
86     fi
87     if [ "$no_delete" = true ] ; then
88         CMD_STRING+=' --no-delete'
89     fi
90
91     echo "Starting instance $i: '$CMD_STRING'"
92     let i=$i+1
93     $CMD_STRING &
94 done
95
96 wait
97 ELAPSED_TIME=$(($SECONDS - $START_TIME))
98
99 echo "Done."
100
101 if [ "$ELAPSED_TIME" -gt 0 ] ; then
102     let "rate=($flows_per_instance * $instances)/$ELAPSED_TIME"
103     echo "Measured rate: $rate"
104     echo "Measured time: $ELAPSED_TIME"
105 fi