CSIT-174: Include cgroup support packages on hardware SUT and TG hosts
[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_testbed1-X710-X520.yaml \
19             topologies/available/lf_testbed2-X710-X520.yaml \
20             topologies/available/lf_testbed3-X710-X520.yaml"
21
22 VPP_STABLE_VER="16.09-rc0~85-gc71c426~b252_amd64"
23 VPP_REPO_URL="https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.trusty.main/io/fd/vpp/"
24
25 # Reservation dir
26 RESERVATION_DIR="/tmp/reservation_dir"
27 INSTALLATION_DIR="/tmp/install_dir"
28
29 PYBOT_ARGS="-W 150 --noncritical PERFTEST"
30
31 ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)
32
33 # If we run this script from CSIT jobs we want to use stable vpp version
34 if [[ ${JOB_NAME} == csit-* ]] ;
35 then
36     mkdir vpp_download
37     cd vpp_download
38     #download vpp build from nexus and set VPP_DEBS variable
39     wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}.deb" || exit
40     wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}.deb" || exit
41     wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}.deb" || exit
42     wget -q "${VPP_REPO_URL}/vpp-dpdk-dev/${VPP_STABLE_VER}/vpp-dpdk-dev-${VPP_STABLE_VER}.deb" || exit
43     wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${VPP_STABLE_VER}/vpp-dpdk-dkms-${VPP_STABLE_VER}.deb" || exit
44     wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}.deb" || exit
45     VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
46     cd ..
47
48 # If we run this script from vpp project we want to use local build
49 elif [[ ${JOB_NAME} == vpp-* ]] ;
50 then
51     #use local packages provided as argument list
52     # Jenkins VPP deb paths (convert to full path)
53     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
54 else
55     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
56     exit 1
57 fi
58
59 CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
60 WORKING_TOPOLOGY=""
61 export PYTHONPATH=${CUR_DIR}
62
63 sudo apt-get -y update
64 sudo apt-get -y install libpython2.7-dev python-virtualenv
65
66 virtualenv --system-site-packages env
67 . env/bin/activate
68
69 echo pip install
70 pip install -r requirements.txt
71
72 # We iterate over available topologies and wait until we reserve topology
73 while :; do
74     for TOPOLOGY in ${TOPOLOGIES};
75     do
76         python ${CUR_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
77         if [ $? -eq 0 ]; then
78             WORKING_TOPOLOGY=${TOPOLOGY}
79             echo "Reserved: ${WORKING_TOPOLOGY}"
80             break
81         fi
82     done
83
84     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
85         # Exit the infinite while loop if we made a reservation
86         break
87     fi
88
89     # Wait ~3minutes before next try
90     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
91     echo "Sleeping ${SLEEP_TIME}"
92     sleep ${SLEEP_TIME}
93 done
94
95 function cancel_all {
96     python ${CUR_DIR}/resources/tools/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
97     python ${CUR_DIR}/resources/tools/topo_reservation.py -c -t $1
98 }
99
100 # On script exit we cancel the reservation and installation and delete all vpp
101 # packages
102 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
103
104 python ${CUR_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
105                                                        -d ${INSTALLATION_DIR} \
106                                                        -p ${VPP_DEBS}
107 if [ $? -eq 0 ]; then
108     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
109 else
110     echo "Failed to copy vpp deb files to DUTs"
111     exit 1
112 fi
113
114 case "$TEST_TAG" in
115     # run specific performance tests based on jenkins job type variable
116     PERFTEST_LONG )
117         pybot ${PYBOT_ARGS} \
118               -L TRACE \
119               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
120               -i perftest_long \
121               tests/
122         RETURN_STATUS=$(echo $?)
123         ;;
124     PERFTEST_SHORT )
125         pybot ${PYBOT_ARGS} \
126               -L TRACE \
127               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
128               -i perftest_short \
129               tests/
130         RETURN_STATUS=$(echo $?)
131         ;;
132     PERFTEST_LONG_BRIDGE )
133         pybot ${PYBOT_ARGS} \
134               -L TRACE \
135               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
136               -s "performance.Long_Bridge_Domain*" \
137               tests/
138         RETURN_STATUS=$(echo $?)
139         ;;
140     PERFTEST_LONG_IPV4 )
141         pybot ${PYBOT_ARGS} \
142               -L TRACE \
143               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
144               -s "performance.Long_IPv4*" \
145               tests/
146         RETURN_STATUS=$(echo $?)
147         ;;
148     PERFTEST_LONG_IPV6 )
149         pybot ${PYBOT_ARGS} \
150               -L TRACE \
151               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
152               -s "performance.Long_IPv6*" \
153               tests/
154         RETURN_STATUS=$(echo $?)
155         ;;
156     PERFTEST_LONG_XCONNECT )
157         pybot ${PYBOT_ARGS} \
158               -L TRACE \
159               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
160               -s "performance.Long_Xconnect*" \
161               tests/
162         RETURN_STATUS=$(echo $?)
163         ;;
164     PERFTEST_LONG_XCONNECT_DOT1Q )
165         pybot ${PYBOT_ARGS} \
166               -L TRACE \
167               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
168               -s "performance.Long_Xconnect_Dot1q*" \
169         RETURN_STATUS=$(echo $?)
170         ;;
171     PERFTEST_NDR )
172         pybot ${PYBOT_ARGS} \
173               -L TRACE \
174               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
175               -s performance -i NDR \
176               tests/
177         RETURN_STATUS=$(echo $?)
178         ;;
179     PERFTEST_PDR )
180         pybot ${PYBOT_ARGS} \
181               -L TRACE \
182               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
183               -s performance -i PDR \
184               tests/
185         RETURN_STATUS=$(echo $?)
186         ;;
187     * )
188         # run full performance test suite and exit on fail
189         pybot ${PYBOT_ARGS} \
190               -L TRACE \
191               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
192               -s performance \
193               tests/
194         RETURN_STATUS=$(echo $?)
195 esac
196
197 # Pybot output post-processing
198 echo Post-processing test data...
199
200 python ${CUR_DIR}/resources/tools/robot_output_parser.py \
201        -i ${CUR_DIR}/output.xml \
202        -o ${CUR_DIR}/output_perf_data.xml \
203        -v ${VPP_STABLE_VER}
204 if [ ! $? -eq 0 ]; then
205     echo "Parsing ${CUR_DIR}/output.xml failed"
206 fi
207
208 # Archive artifacts
209 mkdir archive
210 for i in ${ARCHIVE_ARTIFACTS[@]}; do
211     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
212 done
213
214 echo Post-processing finished.
215
216 exit ${RETURN_STATUS}