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