Bridge domain tests and user keywords refactor.
[csit.git] / bootstrap-verify-perf.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 # Reservation dir
21 RESERVATION_DIR="/tmp/reservation_dir"
22 INSTALLATION_DIR="/tmp/install_dir"
23
24 # Jenkins VPP deb paths (convert to full path)
25 VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
26
27 CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28 WORKING_TOPOLOGY=""
29 export PYTHONPATH=${CUR_DIR}
30
31 sudo apt-get -y update
32 sudo apt-get -y install libpython2.7-dev python-virtualenv
33
34 virtualenv env
35 . env/bin/activate
36
37 echo pip install
38 pip install -r requirements.txt
39
40 # We iterate over available topologies and wait until we reserve topology
41 while :; do
42     for TOPOLOGY in ${TOPOLOGIES};
43     do
44         python ${CUR_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
45         if [ $? -eq 0 ]; then
46             WORKING_TOPOLOGY=${TOPOLOGY}
47             echo "Reserved: ${WORKING_TOPOLOGY}"
48             break
49         fi
50     done
51
52     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
53         # Exit the infinite while loop if we made a reservation
54         break
55     fi
56
57     # Wait 10 - 30 sec. before next try
58     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 10 ]s
59     echo "Sleeping ${SLEEP_TIME}"
60     sleep ${SLEEP_TIME}
61 done
62
63 function cancel_all {
64     python ${CUR_DIR}/resources/tools/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
65     python ${CUR_DIR}/resources/tools/topo_reservation.py -c -t $1
66 }
67
68 # On script exit we cancel the reservation and installation and delete all vpp
69 # packages
70 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
71
72 python ${CUR_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
73                                                        -d ${INSTALLATION_DIR} \
74                                                        -p ${VPP_DEBS}
75 if [ $? -eq 0 ]; then
76     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
77 else
78     echo "Failed to copy vpp deb files to DUTs"
79     exit 1
80 fi
81
82 if [ ! -z "$TEST_TAG" ]; then
83 # run specific performance tests by tag if variable is set
84     pybot -L TRACE \
85         -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
86         -i "${TEST_TAG,,}" tests/
87 else
88 # run full performance test suite
89     pybot -L TRACE \
90         -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
91         -s performance tests/
92 fi