report: test methodology updated with new bits and bites in 18.10.
[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 JOB_ARCHIVE_ARTIFACTS=(log.html output.xml report.html honeycomb.log)
35 LOG_ARCHIVE_ARTIFACTS=(log.html output.xml report.html honeycomb.log)
36 JOB_ARCHIVE_DIR="archive"
37 LOG_ARCHIVE_DIR="$WORKSPACE/archives"
38 mkdir -p ${JOB_ARCHIVE_DIR}
39 mkdir -p ${LOG_ARCHIVE_DIR}
40
41 WORKING_TOPOLOGY=""
42 export PYTHONPATH=${SCRIPT_DIR}
43
44 sudo apt-get -y update
45 sudo apt-get -y install libpython2.7-dev python-virtualenv
46
47 virtualenv --system-site-packages env
48 . env/bin/activate
49
50 echo pip install
51 pip install -r requirements.txt
52
53 # We iterate over available topologies and wait until we reserve topology
54 while :; do
55     for TOPOLOGY in ${TOPOLOGIES};
56     do
57         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
58         if [ $? -eq 0 ]; then
59             WORKING_TOPOLOGY=${TOPOLOGY}
60             echo "Reserved: ${WORKING_TOPOLOGY}"
61             break
62         fi
63     done
64
65     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
66         # Exit the infinite while loop if we made a reservation
67         break
68     fi
69
70     # Wait ~3minutes before next try
71     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
72     echo "Sleeping ${SLEEP_TIME}"
73     sleep ${SLEEP_TIME}
74 done
75
76 function cancel_all {
77     python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1 -hc True
78     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
79 }
80
81 # On script exit we cancel the reservation and installation and delete all vpp
82 # packages
83 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
84
85 # Download VPP and HC packages from the current branch
86 echo Downloading packages...
87 bash ${SCRIPT_DIR}/resources/tools/scripts/download_hc_pkgs.sh ${STREAM} 'ubuntu1604'
88
89 if [ "${OS}" == "centos7" ]; then
90     VPP_PKGS=(*.rpm)
91 else
92     VPP_PKGS=(*.deb)
93 fi
94 echo ${VPP_PKGS[@]}
95
96 # Install packages
97 python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -t ${WORKING_TOPOLOGY} \
98                                                        -d ${INSTALLATION_DIR} \
99                                                        -p ${VPP_PKGS[@]} \
100                                                        -hc True
101 if [ $? -eq 0 ]; then
102     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
103 else
104     echo "Failed to copy vpp deb files to DUTs"
105     exit 1
106 fi
107
108 # run full performance test suite and exit on fail
109         pybot ${PYBOT_ARGS} \
110               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
111               -s "tests.honeycomb.perf" \
112               --variable install_dir:${INSTALLATION_DIR} \
113               tests/
114         RETURN_STATUS=$(echo $?)
115
116 # Archive JOB artifacts in jenkins
117 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
118     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
119 done
120 # Archive JOB artifacts to logs.fd.io
121 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
122     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
123 done
124
125 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.