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