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