Update of VPP_STABLE_VER and DPDK_STABLE_VER files
[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 -xo pipefail
16
17 # Space separated list of available testbeds, described by topology files
18 TOPOLOGIES="topologies/available/lf_3n_hsw_testbed1.yaml \
19             topologies/available/lf_3n_hsw_testbed2.yaml \
20             topologies/available/lf_3n_hsw_testbed3.yaml"
21
22 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23 export PYTHONPATH=${SCRIPT_DIR}
24 export DEBIAN_FRONTEND=noninteractive
25
26 # Reservation dir
27 RESERVATION_DIR="/tmp/reservation_dir"
28 INSTALLATION_DIR="/tmp/install_dir"
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     if [[ ${TEST_TAG} == *DAILY ]] || \
41        [[ ${TEST_TAG} == *WEEKLY ]];
42     then
43         echo Downloading latest VPP packages from NEXUS...
44         bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh \
45             --skip-install
46     else
47         echo Downloading VPP packages of specific version from NEXUS...
48         DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)
49         VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU)
50         #Temporary if arch will not be removed from VPP_STABLE_VER_UBUNTU
51         #VPP_STABLE_VER=${VPP_STABLE_VER%_amd64}
52         bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh \
53             --skip-install --vpp ${VPP_STABLE_VER} --dkms ${DPDK_STABLE_VER}
54     fi
55     # Jenkins VPP deb paths (convert to full path)
56     VPP_DEBS="$( readlink -f vpp*.deb | tr '\n' ' ' )"
57
58 # If we run this script from vpp project we want to use local build
59 elif [[ ${JOB_NAME} == vpp-* ]] ;
60 then
61     # Use local packages provided as argument list
62     # Jenkins VPP deb paths (convert to full path)
63     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
64 else
65     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
66     exit 1
67 fi
68
69 WORKING_TOPOLOGY=""
70
71 sudo apt-get -y update
72 sudo apt-get -y install libpython2.7-dev python-virtualenv
73
74 virtualenv --system-site-packages env
75 . env/bin/activate
76
77 echo pip install
78 pip install -r requirements.txt
79
80 # We iterate over available topologies and wait until we reserve topology
81 while :; do
82     for TOPOLOGY in ${TOPOLOGIES};
83     do
84         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
85         if [ $? -eq 0 ]; then
86             WORKING_TOPOLOGY=${TOPOLOGY}
87             echo "Reserved: ${WORKING_TOPOLOGY}"
88             break
89         fi
90     done
91
92     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
93         # Exit the infinite while loop if we made a reservation
94         break
95     fi
96
97     # Wait ~3minutes before next try
98     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
99     echo "Sleeping ${SLEEP_TIME}"
100     sleep ${SLEEP_TIME}
101 done
102
103 function cancel_all {
104     python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
105     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
106 }
107
108 # On script exit we cancel the reservation and installation and delete all vpp
109 # packages
110 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
111
112 python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py \
113     -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -p ${VPP_DEBS}
114 if [ $? -eq 0 ]; then
115     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
116 else
117     echo "Failed to copy vpp deb files to DUTs"
118     exit 1
119 fi
120
121 # Based on job we will identify DUT
122 if [[ ${JOB_NAME} == *hc2vpp* ]] ;
123 then
124     DUT="hc2vpp"
125 elif [[ ${JOB_NAME} == *vpp* ]] ;
126 then
127     DUT="vpp"
128 elif [[ ${JOB_NAME} == *ligato* ]] ;
129 then
130     DUT="kubernetes"
131 elif [[ ${JOB_NAME} == *dpdk* ]] ;
132 then
133     DUT="dpdk"
134 else
135     echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
136     exit 1
137 fi
138
139 PYBOT_ARGS="--consolewidth 120 --loglevel TRACE --variable TOPOLOGY_PATH:${WORKING_TOPOLOGY} --suite tests.${DUT}.perf"
140
141 case "$TEST_TAG" in
142     # select specific performance tests based on jenkins job type variable
143     PERFTEST_DAILY )
144         TAGS=('ndrdiscANDnic_intel-x520-da2AND1t1c'
145               'ndrdiscANDnic_intel-x520-da2AND2t2c'
146               'ndrpdrANDnic_intel-x520-da2AND1t1c'
147               'ndrpdrANDnic_intel-x520-da2AND2t2c'
148               'ndrdiscAND1t1cANDipsec'
149               'ndrdiscAND2t2cANDipsec')
150         ;;
151     PERFTEST_SEMI_WEEKLY )
152         TAGS=('ndrdiscANDnic_intel-x710AND1t1c'
153               'ndrdiscANDnic_intel-x710AND2t2c'
154               'ndrdiscANDnic_intel-xl710AND1t1c'
155               'ndrdiscANDnic_intel-xl710AND2t2c')
156         ;;
157     PERFTEST_MRR_DAILY )
158        TAGS=('mrrAND64bAND1t1c'
159              'mrrAND64bAND2t2c'
160              'mrrAND64bAND4t4c'
161              'mrrAND78bAND1t1c'
162              'mrrAND78bAND2t2c'
163              'mrrAND78bAND4t4c'
164              'mrrANDimixAND1t1cANDvhost'
165              'mrrANDimixAND2t2cANDvhost'
166              'mrrANDimixAND4t4cANDvhost'
167              'mrrANDimixAND1t1cANDmemif'
168              'mrrANDimixAND2t2cANDmemif'
169              'mrrANDimixAND4t4cANDmemif')
170         ;;
171     VERIFY-PERF-NDRDISC )
172         TAGS=('ndrdiscAND1t1c'
173               'ndrdiscAND2t2c')
174         ;;
175     VERIFY-PERF-PDRDISC )
176         TAGS=('pdrdiscAND1t1c'
177               'pdrdiscAND2t2c')
178         ;;
179     VERIFY-PERF-MRR )
180         TAGS=('mrrAND1t1c'
181               'mrrAND2t2c')
182         ;;
183     VERIFY-PERF-IP4 )
184         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip4base'
185               'mrrANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m')
186         ;;
187     VERIFY-PERF-IP6 )
188         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip6base'
189               'mrrANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m')
190         ;;
191     VERIFY-PERF-L2 )
192         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDl2xcbase'
193               'mrrANDnic_intel-x520-da2AND1t1cANDl2bdbase'
194               '!lbond_dpdk')
195         ;;
196     VERIFY-PERF-LISP )
197         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDlisp')
198         ;;
199     VERIFY-PERF-VXLAN )
200         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDvxlan')
201         ;;
202     VERIFY-PERF-VHOST )
203         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDvhost'
204               '!lbond_dpdk')
205         ;;
206     VERIFY-PERF-MEMIF )
207         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif'
208               'pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif'
209               'mrrANDnic_intel-x520-da2AND1t1cANDmemif'
210               'mrrANDnic_intel-x520-da2AND2t2cANDmemif')
211         ;;
212     VERIFY-PERF-IPSECHW )
213         TAGS=('pdrdiscANDnic_intel-xl710AND1t1cANDipsechw'
214               'pdrdiscANDnic_intel-xl710AND2t2cANDipsechw'
215               'mrrANDnic_intel-xl710AND1t1cANDipsechw'
216               'mrrANDnic_intel-xl710AND2t2cANDipsechw')
217         ;;
218     VERIFY-PERF-SRV6 )
219         TAGS=('mrrANDsrv6AND1t1c'
220               'mrrANDsrv6AND2t2c')
221         ;;
222     VPP-VERIFY-PERF-IP4 )
223         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip4base'
224               'mrrANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m')
225         ;;
226     VPP-VERIFY-PERF-IP6 )
227         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip6base'
228               'mrrANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m')
229         ;;
230     VPP-VERIFY-PERF-L2 )
231         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDl2xcbase'
232               'mrrANDnic_intel-x520-da2AND1t1cANDl2bdbase'
233               'mrrANDnic_intel-x520-da2AND1t1cANDdot1q'
234               '!lbond_dpdk')
235         ;;
236     VPP-VERIFY-PERF-LISP )
237         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDlisp')
238         ;;
239     VPP-VERIFY-PERF-VXLAN )
240         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDvxlan')
241         ;;
242     VPP-VERIFY-PERF-VHOST )
243         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDvhost'
244               '!lbond_dpdk')
245         ;;
246     VPP-VERIFY-PERF-MEMIF )
247         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif'
248               'pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif'
249               'mrrANDnic_intel-x520-da2AND1t1cANDmemif'
250               'mrrANDnic_intel-x520-da2AND2t2cANDmemif')
251         ;;
252     VPP-VERIFY-PERF-ACL )
253         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDacl'
254               'mrrANDnic_intel-x520-da2AND2t2cANDacl')
255         ;;
256     VPP-VERIFY-PERF-IPSECHW )
257         TAGS=('pdrdiscANDnic_intel-xl710AND1t1cANDipsechw'
258               'pdrdiscANDnic_intel-xl710AND2t2cANDipsechw'
259               'mrrANDnic_intel-xl710AND1t1cANDipsechw'
260               'mrrANDnic_intel-xl710AND2t2cANDipsechw')
261         ;;
262     VPP-VERIFY-PERF-SRV6 )
263         TAGS=('mrrANDsrv6AND1t1c'
264               'mrrANDsrv6AND2t2c')
265         ;;
266     VERIFY-PERF-PATCH )
267         if [[ -z "$TEST_TAG_STRING" ]]; then
268             # If nothing is specified, we will run pre-selected tests by
269             # following tags. Items of array will be concatenated by OR in Robot
270             # Framework.
271             TEST_TAG_ARRAY=('mrrANDnic_intel-x710AND1t1cAND64bANDip4base'
272                             'mrrANDnic_intel-x710AND1t1cAND78bANDip6base'
273                             'mrrANDnic_intel-x710AND1t1cAND64bANDl2bdbase')
274         else
275             # If trigger contains tags, split them into array.
276             TEST_TAG_ARRAY=(${TEST_TAG_STRING//:/ })
277         fi
278
279         TAGS=()
280
281         for TAG in "${TEST_TAG_ARRAY[@]}"; do
282             if [[ ${TAG} == "!"* ]]; then
283                 # Exclude tags are not prefixed.
284                 TAGS+=("${TAG}")
285             else
286                 # We will prefix with perftest to prevent running other tests
287                 # (e.g. Functional).
288                 prefix="perftestAND"
289                 if [[ ${JOB_NAME} == vpp-* ]] ; then
290                     # Automatic prefixing for VPP jobs to limit the NIC used and
291                     # traffic evaluation to MRR.
292                     prefix="${prefix}mrrANDnic_intel-x710AND"
293                 fi
294                 TAGS+=("$prefix${TAG}")
295             fi
296         done
297         ;;
298     * )
299         TAGS=('perftest')
300 esac
301
302 # Catenate TAG selections
303 EXPANDED_TAGS=()
304 for TAG in "${TAGS[@]}"; do
305     if [[ ${TAG} == "!"* ]]; then
306         EXPANDED_TAGS+=(" --exclude ${TAG#$"!"} ")
307     else
308         EXPANDED_TAGS+=(" --include ${TAG} ")
309     fi
310 done
311
312 # Execute the test
313 pybot ${PYBOT_ARGS}${EXPANDED_TAGS[@]} tests/
314 RETURN_STATUS=$(echo $?)
315
316 # Archive JOB artifacts in jenkins
317 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
318     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
319 done
320 # Archive JOB artifacts to logs.fd.io
321 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
322     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
323 done
324
325 exit ${RETURN_STATUS}