Merge "Replaced the multi-blaster skeleton with real functionality. multi-blaster...
[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 CMD="./flow_config_blaster.py"
9 programname=$0
10
11 function usage {
12     echo "usage: $programname [-h?an] [-i instances] [-c cycles] [-f flows] [- threads]"
13     echo "      -h|?          print this message"
14     echo "      -a            use default authentication ('admin/admin')"
15     echo "      -n            use the 'no-delete' flag in '$CMD'"
16     echo "      -i instances  number of '$CMD' instances to spawn"
17     echo "      -c cycles     number of cycles in '$CMD'"
18     echo "      -f flows      number of flows in '$CMD'"
19     echo "      -t threads    number of threads in '$CMD'"
20 }
21
22 # Initialize our own variables:
23
24 instances=1
25 no_delete=false
26 auth=false
27 threads=1
28 flows=1000
29 cycles=1
30
31 while getopts "h?ac:f:i:nt:" opt; do
32     case "$opt" in
33     h|\?)
34         usage
35         exit 1
36         ;;
37     a)  auth=true
38         ;;
39     c)  cycles=$OPTARG
40         ;;
41     f)  flows=$OPTARG
42         ;;
43     i)  instances=$OPTARG
44         ;;
45     n)  no_delete=true
46         ;;
47     t)  threads=$OPTARG
48         ;;
49     esac
50 done
51
52 echo "Running $instances instance(s), parameters:\n  flows='flows', threads=$threads, cycles=$cycles, \
53 no-delete='$no_delete', auth='$auth'"
54
55
56 let "flows_per_instance=$cycles * $flows * $threads"
57
58 printf "FPI: %d\n" $flows_per_instance
59
60 i=0
61 START_TIME=$SECONDS
62 while [  $i -lt $instances ]; do
63     let "startflow=$flows_per_instance * $i"
64
65     CMD_STRING=$(printf '%s --cycles %s --flows %s --threads %s --startflow %s' $CMD $cycles $flows $threads $startflow)
66     if [ "$auth" = true ] ; then
67         CMD_STRING+=' --auth'
68     fi
69     if [ "$no_delete" = true ] ; then
70         CMD_STRING+=' --no-delete'
71     fi
72
73     echo "Starting instance $i: '$CMD_STRING'"
74     let i=$i+1
75     $CMD_STRING &
76 done
77
78 wait
79 ELAPSED_TIME=$(($SECONDS - $START_TIME))
80
81 let "rate=($flows_per_instance * $instances)/$ELAPSED_TIME"
82 echo "Done."
83 echo "Measured rate: $rate"
84 echo "Measured time: $ELAPSED_TIME"
85
86 # End of file