Update links with source data for rls report
[csit.git] / bootstrap-verify-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 # Space separated list of available testbeds, described by topology files
18 TOPOLOGIES="topologies/available/lf_testbed1.yaml \
19             topologies/available/lf_testbed2.yaml \
20             topologies/available/lf_testbed3.yaml"
21
22 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23
24 # Reservation dir
25 RESERVATION_DIR="/tmp/reservation_dir"
26 INSTALLATION_DIR="/tmp/install_dir"
27
28 PYBOT_ARGS="-W 150 -L TRACE"
29
30 ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)
31
32 # If we run this script from CSIT jobs we want to use stable vpp version
33 if [[ ${JOB_NAME} == csit-* ]] ;
34 then
35     mkdir vpp_download
36     cd vpp_download
37
38     if [[ ${TEST_TAG} == *NIGHTLY ]] || \
39        [[ ${TEST_TAG} == *DAILY ]] || \
40        [[ ${TEST_TAG} == *WEEKLY ]];
41     then
42         # Download the latest VPP build .deb install packages
43         echo Downloading VPP packages...
44         bash ${SCRIPT_DIR}/resources/tools/download_install_vpp_pkgs.sh --skip-install
45
46         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
47         # Take vpp package and get the vpp version
48         VPP_STABLE_VER="$( expr match $(ls *.deb | head -n 1) 'vpp-\(.*\)-deb.deb' )"
49     else
50         DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)_amd64
51         VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL_UBUNTU)
52         VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU)
53         VPP_CLASSIFIER="-deb"
54         # Download vpp build from nexus and set VPP_DEBS variable
55         wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
56         wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
57         wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
58         wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
59         wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
60         wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
61         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
62     fi
63
64     cd ..
65
66 # If we run this script from vpp project we want to use local build
67 elif [[ ${JOB_NAME} == vpp-* ]] ;
68 then
69     # Use local packages provided as argument list
70     # Jenkins VPP deb paths (convert to full path)
71     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
72     # Take vpp package and get the vpp version
73     VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )"
74     # Download DPDK parts not included in dpdk plugin of vpp build
75     DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)_amd64
76     VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL_UBUNTU)
77     VPP_CLASSIFIER="-deb"
78     wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
79     VPP_DEBS+=($( readlink -f vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb ))
80 else
81     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
82     exit 1
83 fi
84
85 WORKING_TOPOLOGY=""
86 export PYTHONPATH=${SCRIPT_DIR}
87
88 sudo apt-get -y update
89 sudo apt-get -y install libpython2.7-dev python-virtualenv
90
91 virtualenv --system-site-packages env
92 . env/bin/activate
93
94 echo pip install
95 pip install -r requirements.txt
96
97 # We iterate over available topologies and wait until we reserve topology
98 while :; do
99     for TOPOLOGY in ${TOPOLOGIES};
100     do
101         python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
102         if [ $? -eq 0 ]; then
103             WORKING_TOPOLOGY=${TOPOLOGY}
104             echo "Reserved: ${WORKING_TOPOLOGY}"
105             break
106         fi
107     done
108
109     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
110         # Exit the infinite while loop if we made a reservation
111         break
112     fi
113
114     # Wait ~3minutes before next try
115     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
116     echo "Sleeping ${SLEEP_TIME}"
117     sleep ${SLEEP_TIME}
118 done
119
120 function cancel_all {
121     python ${SCRIPT_DIR}/resources/tools/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
122     python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -c -t $1
123 }
124
125 # On script exit we cancel the reservation and installation and delete all vpp
126 # packages
127 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
128
129 python ${SCRIPT_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
130                                                        -d ${INSTALLATION_DIR} \
131                                                        -p ${VPP_DEBS}
132 if [ $? -eq 0 ]; then
133     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
134 else
135     echo "Failed to copy vpp deb files to DUTs"
136     exit 1
137 fi
138
139 case "$TEST_TAG" in
140     # run specific performance tests based on jenkins job type variable
141     PERFTEST_DAILY )
142         pybot ${PYBOT_ARGS} \
143               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
144               -s "tests.perf" \
145               --include ndrdiscANDnic_intel-x520-da2AND1t1cORndrdiscANDnic_intel-x520-da2AND2t2c \
146               tests/
147         RETURN_STATUS=$(echo $?)
148         ;;
149     PERFTEST_SEMI_WEEKLY )
150         pybot ${PYBOT_ARGS} \
151               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
152               -s "tests.perf" \
153               --include ndrdiscANDnic_intel-x710AND1t1cORndrdiscANDnic_intel-x710AND2t2cORndrdiscANDnic_intel-xl710AND1t1cORndrdiscANDnic_intel-xl710AND2t2c \
154               tests/
155         RETURN_STATUS=$(echo $?)
156         ;;
157     VERIFY-PERF-NDRDISC )
158         pybot ${PYBOT_ARGS} \
159               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
160               -s "tests.perf" \
161               --include ndrdiscAND1t1cORndrdiscAND2t2c \
162               tests/
163         RETURN_STATUS=$(echo $?)
164         ;;
165     VERIFY-PERF-PDRDISC )
166         pybot ${PYBOT_ARGS} \
167               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
168               -s "tests.perf" \
169               --include pdrdiscAND1t1cORpdrdiscAND2t2c \
170               tests/
171         RETURN_STATUS=$(echo $?)
172         ;;
173     VERIFY-PERF-NDRCHK )
174         pybot ${PYBOT_ARGS} \
175               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
176               -s "tests.perf" \
177               --include ndrchkAND1t1cORndrchkAND2t2c \
178               tests/
179         RETURN_STATUS=$(echo $?)
180         ;;
181     PERFTEST_NDRCHK_DAILY )
182         pybot ${PYBOT_ARGS} \
183               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
184               -s "tests.perf" \
185               --include ndrchkAND1t1cORndrchkAND2t2c \
186               tests/
187         RETURN_STATUS=$(echo $?)
188         ;;
189     VERIFY-PERF-IP4 )
190         pybot ${PYBOT_ARGS} \
191               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
192               -s "tests.perf" \
193               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip4baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
194               tests/
195         RETURN_STATUS=$(echo $?)
196         ;;
197     VERIFY-PERF-IP6 )
198         pybot ${PYBOT_ARGS} \
199               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
200               -s "tests.perf" \
201               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip6baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
202               tests/
203         RETURN_STATUS=$(echo $?)
204         ;;
205     VERIFY-PERF-L2 )
206         pybot ${PYBOT_ARGS} \
207               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
208               -s "tests.perf" \
209               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrdiscANDnic_intel-x520-da2AND1t1cANDl2bdbase \
210               tests/
211         RETURN_STATUS=$(echo $?)
212         ;;
213     VERIFY-PERF-LISP )
214         pybot ${PYBOT_ARGS} \
215               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
216               -s "tests.perf" \
217               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDlisp \
218               tests/
219         RETURN_STATUS=$(echo $?)
220         ;;
221     VERIFY-PERF-VXLAN )
222         pybot ${PYBOT_ARGS} \
223               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
224               -s "tests.perf" \
225               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvxlan \
226               tests/
227         RETURN_STATUS=$(echo $?)
228         ;;
229     VERIFY-PERF-VHOST )
230         pybot ${PYBOT_ARGS} \
231               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
232               -s "tests.perf" \
233               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
234               tests/
235         RETURN_STATUS=$(echo $?)
236         ;;
237     VPP-VERIFY-PERF-IP4 )
238         pybot ${PYBOT_ARGS} \
239               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
240               -s "tests.perf" \
241               --include ndrchkANDnic_intel-x520-da2AND1t1cANDip4baseORndrchkANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
242               tests/
243         RETURN_STATUS=$(echo $?)
244         ;;
245     VPP-VERIFY-PERF-IP6 )
246         pybot ${PYBOT_ARGS} \
247               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
248               -s "tests.perf" \
249               --include ndrchkANDnic_intel-x520-da2AND1t1cANDip6baseORndrchkANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
250               tests/
251         RETURN_STATUS=$(echo $?)
252         ;;
253     VPP-VERIFY-PERF-L2 )
254         pybot ${PYBOT_ARGS} \
255               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
256               -s "tests.perf" \
257               --include ndrchkANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrchkANDnic_intel-x520-da2AND1t1cANDl2bdbase \
258               tests/
259         RETURN_STATUS=$(echo $?)
260         ;;
261     VPP-VERIFY-PERF-LISP )
262         pybot ${PYBOT_ARGS} \
263               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
264               -s "tests.perf" \
265               --include ndrchkANDnic_intel-x520-da2AND1t1cANDlisp \
266               tests/
267         RETURN_STATUS=$(echo $?)
268         ;;
269     VPP-VERIFY-PERF-VXLAN )
270         pybot ${PYBOT_ARGS} \
271               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
272               -s "tests.perf" \
273               --include ndrchkANDnic_intel-x520-da2AND1t1cANDvxlan \
274               tests/
275         RETURN_STATUS=$(echo $?)
276         ;;
277     VPP-VERIFY-PERF-VHOST )
278         pybot ${PYBOT_ARGS} \
279               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
280               -s "tests.perf" \
281               --include ndrchkANDnic_intel-x520-da2AND1t1cANDvhost \
282               tests/
283         RETURN_STATUS=$(echo $?)
284         ;;
285     PERFTEST_LONG )
286         pybot ${PYBOT_ARGS} \
287               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
288               -s "tests.perf" \
289               --exclude SKIP_PATCH \
290               -i NDRPDRDISC \
291               tests/
292         RETURN_STATUS=$(echo $?)
293         ;;
294     PERFTEST_SHORT )
295         pybot ${PYBOT_ARGS} \
296               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
297               -s "tests.perf" \
298               -i NDRCHK \
299               tests/
300         RETURN_STATUS=$(echo $?)
301         ;;
302     PERFTEST_NIGHTLY )
303         #run all available tests
304         pybot ${PYBOT_ARGS} \
305               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
306               -s "tests.perf" \
307               tests/
308         RETURN_STATUS=$(echo $?)
309         ;;
310     * )
311         # run full performance test suite and exit on fail
312         pybot ${PYBOT_ARGS} \
313               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
314               -s "tests.perf" \
315               tests/
316         RETURN_STATUS=$(echo $?)
317 esac
318
319 # Pybot output post-processing
320 echo Post-processing test data...
321
322 python ${SCRIPT_DIR}/resources/tools/robot_output_parser.py \
323        -i ${SCRIPT_DIR}/output.xml \
324        -o ${SCRIPT_DIR}/output_perf_data.xml \
325        -v ${VPP_STABLE_VER}
326 if [ ! $? -eq 0 ]; then
327     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
328 fi
329
330 # Archive artifacts
331 mkdir archive
332 for i in ${ARCHIVE_ARTIFACTS[@]}; do
333     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
334 done
335
336 echo Post-processing finished.
337
338 exit ${RETURN_STATUS}