Include tags to CSIT performance boostrap script
[csit.git] / bootstrap-hw-tb2.sh
1 #!/bin/bash
2 # Copyright (c) 2016 Cisco and/or its affiliates.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 set -x
16
17 # space separated list of available testbeds, described by topology files
18 TOPOLOGIES="topologies/available/lf_testbed2-710-520.yaml"
19
20 CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21 WORKING_TOPOLOGY=""
22 export PYTHONPATH=${CUR_DIR}
23
24 sudo apt-get -y update
25 sudo apt-get -y install libpython2.7-dev python-virtualenv
26
27 virtualenv env
28 . env/bin/activate
29
30 echo pip install
31 pip install -r requirements.txt
32
33 # we iterate over available topologies and wait until we reserve topology
34 while :; do
35     for TOPOLOGY in ${TOPOLOGIES};
36     do
37         python ${CUR_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
38         if [ $? -eq 0 ]; then
39             WORKING_TOPOLOGY=${TOPOLOGY}
40             echo "Reserved: ${WORKING_TOPOLOGY}"
41             break
42         fi
43     done
44
45     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
46         # exit the infinite while loop if we made a reservation
47         break
48     fi
49
50     # wait 10 - 30 sec. before next try
51     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 10 ]s
52     echo "Sleeping ${SLEEP_TIME}"
53     sleep ${SLEEP_TIME}
54 done
55
56 function cancel_reservation {
57     python ${CUR_DIR}/resources/tools/topo_reservation.py -c -t $1
58 }
59
60 # on script exit we cancel the reservation
61 trap "cancel_reservation ${WORKING_TOPOLOGY}" EXIT
62
63 case "$TEST_TAG" in
64     # run specific performance tests based on jenkins job type variable
65     PERFTEST_LONG )
66         pybot -L TRACE \
67               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
68               -i perftest_long \
69               tests/
70         ;;
71     PERFTEST_SHORT )
72         pybot -L TRACE \
73               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
74               -i perftest_short \
75               tests/
76         ;;
77     PERFTEST_LONG_BRIDGE )
78         pybot -L TRACE \
79               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
80               -s performance.long_bridge_domain \
81               tests/
82         ;;
83     PERFTEST_LONG_IPV4 )
84         pybot -L TRACE \
85               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
86               -s performance.long_ipv4 \
87               tests/
88         ;;
89     PERFTEST_LONG_XCONNECT )
90         pybot -L TRACE \
91               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
92               -s performance.long_xconnect \
93               tests/
94         ;;
95     * )
96         # run full performance test suite
97         pybot -L TRACE \
98               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
99               -s performance \
100               tests/
101 esac
102