CSIT-806 Container Orchestration in CSIT - Low Level Design
[csit.git] / bootstrap-hc2vpp-perf.sh
1 #!/bin/bash
2 # Copyright (c) 2017 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 STREAM=$1
18 OS=$2
19 ODL=$3
20
21 # Space separated list of available testbeds, described by topology files
22 TOPOLOGIES="topologies/available/lf_testbed1.yaml \
23             topologies/available/lf_testbed2.yaml \
24             topologies/available/lf_testbed3.yaml"
25
26 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
27
28 # Reservation dir
29 RESERVATION_DIR="/tmp/reservation_dir"
30 INSTALLATION_DIR="/tmp/install_dir"
31
32 PYBOT_ARGS="-W 150 -L TRACE"
33
34 ARCHIVE_ARTIFACTS=(log.html output.xml report.html honeycomb.log)
35
36 WORKING_TOPOLOGY=""
37 export PYTHONPATH=${SCRIPT_DIR}
38
39 sudo apt-get -y update
40 sudo apt-get -y install libpython2.7-dev python-virtualenv
41
42 virtualenv --system-site-packages env
43 . env/bin/activate
44
45 echo pip install
46 pip install -r requirements.txt
47
48 # We iterate over available topologies and wait until we reserve topology
49 while :; do
50     for TOPOLOGY in ${TOPOLOGIES};
51     do
52         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
53         if [ $? -eq 0 ]; then
54             WORKING_TOPOLOGY=${TOPOLOGY}
55             echo "Reserved: ${WORKING_TOPOLOGY}"
56             break
57         fi
58     done
59
60     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
61         # Exit the infinite while loop if we made a reservation
62         break
63     fi
64
65     # Wait ~3minutes before next try
66     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
67     echo "Sleeping ${SLEEP_TIME}"
68     sleep ${SLEEP_TIME}
69 done
70
71 function cancel_all {
72     python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1 -hc True
73     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
74 }
75
76 # On script exit we cancel the reservation and installation and delete all vpp
77 # packages
78 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
79
80 # Download VPP and HC packages from the current branch
81 echo Downloading packages...
82 bash ${SCRIPT_DIR}/resources/tools/scripts/download_hc_pkgs.sh ${STREAM} 'ubuntu1604'
83
84 if [ "${OS}" == "centos7" ]; then
85     VPP_PKGS=(*.rpm)
86 else
87     VPP_PKGS=(*.deb)
88 fi
89 echo ${VPP_PKGS[@]}
90
91 # Install packages
92 python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -t ${WORKING_TOPOLOGY} \
93                                                        -d ${INSTALLATION_DIR} \
94                                                        -p ${VPP_PKGS[@]} \
95                                                        -hc True
96 if [ $? -eq 0 ]; then
97     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
98 else
99     echo "Failed to copy vpp deb files to DUTs"
100     exit 1
101 fi
102
103 # run full performance test suite and exit on fail
104         pybot ${PYBOT_ARGS} \
105               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
106               -s "tests.vpp.perf.honeycomb" \
107               --variable install_dir:${INSTALLATION_DIR} \
108               tests/
109         RETURN_STATUS=$(echo $?)
110
111 # Archive artifacts
112 mkdir archive
113 for i in ${ARCHIVE_ARTIFACTS[@]}; do
114     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
115 done
116
117 exit ${RETURN_STATUS}

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.