start-testcase-DMM file addition
[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_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 JOB_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
29 LOG_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
30 JOB_ARCHIVE_DIR="archive"
31 LOG_ARCHIVE_DIR="$WORKSPACE/archives"
32 mkdir -p ${JOB_ARCHIVE_DIR}
33 mkdir -p ${LOG_ARCHIVE_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 ${SCRIPT_DIR}
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 \
126     -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -p ${VPP_DEBS}
127 if [ $? -eq 0 ]; then
128     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
129 else
130     echo "Failed to copy vpp deb files to DUTs"
131     exit 1
132 fi
133
134 # Based on job we will identify DUT
135 if [[ ${JOB_NAME} == *hc2vpp* ]] ;
136 then
137     DUT="hc2vpp"
138 elif [[ ${JOB_NAME} == *vpp* ]] ;
139 then
140     DUT="vpp"
141 elif [[ ${JOB_NAME} == *ligato* ]] ;
142 then
143     DUT="kubernetes"
144 elif [[ ${JOB_NAME} == *dpdk* ]] ;
145 then
146     DUT="dpdk"
147 else
148     echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
149     exit 1
150 fi
151
152 PYBOT_ARGS="--consolewidth 120 --loglevel TRACE --variable TOPOLOGY_PATH:${WORKING_TOPOLOGY} --suite tests.${DUT}.perf"
153
154 case "$TEST_TAG" in
155     # select specific performance tests based on jenkins job type variable
156     PERFTEST_DAILY )
157         TAGS=('ndrdiscANDnic_intel-x520-da2AND1t1c'
158               'ndrdiscANDnic_intel-x520-da2AND2t2c'
159               'ndrpdrANDnic_intel-x520-da2AND1t1c'
160               'ndrpdrANDnic_intel-x520-da2AND2t2c'
161               'ndrdiscAND1t1cANDipsec'
162               'ndrdiscAND2t2cANDipsec')
163         ;;
164     PERFTEST_SEMI_WEEKLY )
165         TAGS=('ndrdiscANDnic_intel-x710AND1t1c'
166               'ndrdiscANDnic_intel-x710AND2t2c'
167               'ndrdiscANDnic_intel-xl710AND1t1c'
168               'ndrdiscANDnic_intel-xl710AND2t2c')
169         ;;
170     PERFTEST_MRR_DAILY )
171        TAGS=('mrrAND64bAND1t1c'
172              'mrrAND64bAND2t2c'
173              'mrrAND64bAND4t4c'
174              'mrrAND78bAND1t1c'
175              'mrrAND78bAND2t2c'
176              'mrrAND78bAND4t4c'
177              'mrrANDimixAND1t1cANDvhost'
178              'mrrANDimixAND2t2cANDvhost'
179              'mrrANDimixAND4t4cANDvhost'
180              'mrrANDimixAND1t1cANDmemif'
181              'mrrANDimixAND2t2cANDmemif'
182              'mrrANDimixAND4t4cANDmemif')
183         ;;
184     VERIFY-PERF-NDRDISC )
185         TAGS=('ndrdiscAND1t1c'
186               'ndrdiscAND2t2c')
187         ;;
188     VERIFY-PERF-PDRDISC )
189         TAGS=('pdrdiscAND1t1c'
190               'pdrdiscAND2t2c')
191         ;;
192     VERIFY-PERF-MRR )
193         TAGS=('mrrAND1t1c'
194               'mrrAND2t2c')
195         ;;
196     VERIFY-PERF-IP4 )
197         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip4base'
198               'mrrANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m')
199         ;;
200     VERIFY-PERF-IP6 )
201         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip6base'
202               'mrrANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m')
203         ;;
204     VERIFY-PERF-L2 )
205         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDl2xcbase'
206               'mrrANDnic_intel-x520-da2AND1t1cANDl2bdbase')
207         ;;
208     VERIFY-PERF-LISP )
209         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDlisp')
210         ;;
211     VERIFY-PERF-VXLAN )
212         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan')
213         ;;
214     VERIFY-PERF-VHOST )
215         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost')
216         ;;
217     VERIFY-PERF-MEMIF )
218         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif'
219               'pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif'
220               'mrrANDnic_intel-x520-da2AND1t1cANDmemif'
221               'mrrANDnic_intel-x520-da2AND2t2cANDmemif')
222         ;;
223     VERIFY-PERF-IPSECHW )
224         TAGS=('pdrdiscANDnic_intel-xl710AND1t1cANDipsechw'
225               'pdrdiscANDnic_intel-xl710AND2t2cANDipsechw'
226               'mrrANDnic_intel-xl710AND1t1cANDipsechw'
227               'mrrANDnic_intel-xl710AND2t2cANDipsechw')
228         ;;
229     VPP-VERIFY-PERF-IP4 )
230         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip4base'
231               'mrrANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m')
232         ;;
233     VPP-VERIFY-PERF-IP6 )
234         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip6base'
235               'mrrANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m')
236         ;;
237     VPP-VERIFY-PERF-L2 )
238         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDl2xcbase'
239               'mrrANDnic_intel-x520-da2AND1t1cANDl2bdbase')
240         ;;
241     VPP-VERIFY-PERF-LISP )
242         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDlisp')
243         ;;
244     VPP-VERIFY-PERF-VXLAN )
245         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan')
246         ;;
247     VPP-VERIFY-PERF-VHOST )
248         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost')
249         ;;
250     VPP-VERIFY-PERF-MEMIF )
251         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif'
252               'pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif'
253               'mrrANDnic_intel-x520-da2AND1t1cANDmemif'
254               'mrrANDnic_intel-x520-da2AND2t2cANDmemif')
255         ;;
256     VPP-VERIFY-PERF-ACL )
257         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDacl'
258               'pdrdiscANDnic_intel-x520-da2AND2t2cANDacl')
259         ;;
260     VPP-VERIFY-PERF-IPSECHW )
261         TAGS=('pdrdiscANDnic_intel-xl710AND1t1cANDipsechw'
262               'pdrdiscANDnic_intel-xl710AND2t2cANDipsechw'
263               'mrrANDnic_intel-xl710AND1t1cANDipsechw'
264               'mrrANDnic_intel-xl710AND2t2cANDipsechw')
265         ;;
266     * )
267         TAGS=('perftest')
268 esac
269
270 # Catenate TAG selections by 'OR'
271 printf -v INCLUDES " --include %s " "${TAGS[@]}"
272
273 # Execute the test
274 pybot ${PYBOT_ARGS}${INCLUDES} tests/
275 RETURN_STATUS=$(echo $?)
276
277 # Archive JOB artifacts in jenkins
278 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
279     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
280 done
281 # Archive JOB artifacts to logs.fd.io
282 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
283     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
284 done
285
286 exit ${RETURN_STATUS}

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.