CSIT-806 Container Orchestration in CSIT - Low Level Design
[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 output_perf_data.json)
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/scripts/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 else
75     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
76     exit 1
77 fi
78
79 WORKING_TOPOLOGY=""
80 export PYTHONPATH=${SCRIPT_DIR}
81
82 sudo apt-get -y update
83 sudo apt-get -y install libpython2.7-dev python-virtualenv
84
85 virtualenv --system-site-packages env
86 . env/bin/activate
87
88 echo pip install
89 pip install -r requirements.txt
90
91 # We iterate over available topologies and wait until we reserve topology
92 while :; do
93     for TOPOLOGY in ${TOPOLOGIES};
94     do
95         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
96         if [ $? -eq 0 ]; then
97             WORKING_TOPOLOGY=${TOPOLOGY}
98             echo "Reserved: ${WORKING_TOPOLOGY}"
99             break
100         fi
101     done
102
103     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
104         # Exit the infinite while loop if we made a reservation
105         break
106     fi
107
108     # Wait ~3minutes before next try
109     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
110     echo "Sleeping ${SLEEP_TIME}"
111     sleep ${SLEEP_TIME}
112 done
113
114 function cancel_all {
115     python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
116     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
117 }
118
119 # On script exit we cancel the reservation and installation and delete all vpp
120 # packages
121 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
122
123 python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -t ${WORKING_TOPOLOGY} \
124                                                        -d ${INSTALLATION_DIR} \
125                                                        -p ${VPP_DEBS}
126 if [ $? -eq 0 ]; then
127     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
128 else
129     echo "Failed to copy vpp deb files to DUTs"
130     exit 1
131 fi
132
133 case "$TEST_TAG" in
134     # run specific performance tests based on jenkins job type variable
135     PERFTEST_DAILY )
136         pybot ${PYBOT_ARGS} \
137               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
138               -s "tests.vpp.perf" \
139               --include ndrdiscANDnic_intel-x520-da2AND1t1cORndrdiscANDnic_intel-x520-da2AND2t2c \
140               --include ndrdiscAND1t1cANDipsecORndrdiscAND2t2cANDipsec \
141               tests/
142         RETURN_STATUS=$(echo $?)
143         ;;
144     PERFTEST_SEMI_WEEKLY )
145         pybot ${PYBOT_ARGS} \
146               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
147               -s "tests.vpp.perf" \
148               --include ndrdiscANDnic_intel-x710AND1t1cORndrdiscANDnic_intel-x710AND2t2cORndrdiscANDnic_intel-xl710AND1t1cORndrdiscANDnic_intel-xl710AND2t2c \
149               tests/
150         RETURN_STATUS=$(echo $?)
151         ;;
152     VERIFY-PERF-NDRDISC )
153         pybot ${PYBOT_ARGS} \
154               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
155               -s "tests.vpp.perf" \
156               --include ndrdiscAND1t1cORndrdiscAND2t2c \
157               tests/
158         RETURN_STATUS=$(echo $?)
159         ;;
160     VERIFY-PERF-PDRDISC )
161         pybot ${PYBOT_ARGS} \
162               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
163               -s "tests.vpp.perf" \
164               --include pdrdiscAND1t1cORpdrdiscAND2t2c \
165               tests/
166         RETURN_STATUS=$(echo $?)
167         ;;
168     VERIFY-PERF-NDRCHK )
169         pybot ${PYBOT_ARGS} \
170               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
171               -s "tests.vpp.perf" \
172               --include ndrchkAND1t1cORndrchkAND2t2c \
173               tests/
174         RETURN_STATUS=$(echo $?)
175         ;;
176     PERFTEST_NDRCHK_DAILY )
177         pybot ${PYBOT_ARGS} \
178               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
179               -s "tests.vpp.perf" \
180               --include ndrchkAND1t1cORndrchkAND2t2c \
181               tests/
182         RETURN_STATUS=$(echo $?)
183         ;;
184     VERIFY-PERF-IP4 )
185         pybot ${PYBOT_ARGS} \
186               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
187               -s "tests.vpp.perf" \
188               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip4baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
189               tests/
190         RETURN_STATUS=$(echo $?)
191         ;;
192     VERIFY-PERF-IP6 )
193         pybot ${PYBOT_ARGS} \
194               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
195               -s "tests.vpp.perf" \
196               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip6baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
197               tests/
198         RETURN_STATUS=$(echo $?)
199         ;;
200     VERIFY-PERF-L2 )
201         pybot ${PYBOT_ARGS} \
202               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
203               -s "tests.vpp.perf" \
204               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrdiscANDnic_intel-x520-da2AND1t1cANDl2bdbase \
205               tests/
206         RETURN_STATUS=$(echo $?)
207         ;;
208     VERIFY-PERF-LISP )
209         pybot ${PYBOT_ARGS} \
210               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
211               -s "tests.vpp.perf" \
212               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDlisp \
213               tests/
214         RETURN_STATUS=$(echo $?)
215         ;;
216     VERIFY-PERF-VXLAN )
217         pybot ${PYBOT_ARGS} \
218               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
219               -s "tests.vpp.perf" \
220               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvxlan \
221               tests/
222         RETURN_STATUS=$(echo $?)
223         ;;
224     VERIFY-PERF-VHOST )
225         pybot ${PYBOT_ARGS} \
226               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
227               -s "tests.vpp.perf" \
228               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
229               tests/
230         RETURN_STATUS=$(echo $?)
231         ;;
232     VERIFY-PERF-MEMIF )
233         pybot ${PYBOT_ARGS} \
234               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
235               -s "tests.vpp.perf" \
236               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDmemif \
237               tests/
238         RETURN_STATUS=$(echo $?)
239         ;;
240     VPP-VERIFY-PERF-IP4 )
241         pybot ${PYBOT_ARGS} \
242               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
243               -s "tests.vpp.perf" \
244               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip4baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
245               tests/
246         RETURN_STATUS=$(echo $?)
247         ;;
248     VPP-VERIFY-PERF-IP6 )
249         pybot ${PYBOT_ARGS} \
250               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
251               -s "tests.vpp.perf" \
252               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip6baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
253               tests/
254         RETURN_STATUS=$(echo $?)
255         ;;
256     VPP-VERIFY-PERF-L2 )
257         pybot ${PYBOT_ARGS} \
258               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
259               -s "tests.vpp.perf" \
260               --include pdrchkANDnic_intel-x520-da2AND1t1cANDl2xcbaseORpdrchkANDnic_intel-x520-da2AND1t1cANDl2bdbase \
261               tests/
262         RETURN_STATUS=$(echo $?)
263         ;;
264     VPP-VERIFY-PERF-LISP )
265         pybot ${PYBOT_ARGS} \
266               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
267               -s "tests.vpp.perf" \
268               --include pdrchkANDnic_intel-x520-da2AND1t1cANDlisp \
269               tests/
270         RETURN_STATUS=$(echo $?)
271         ;;
272     VPP-VERIFY-PERF-VXLAN )
273         pybot ${PYBOT_ARGS} \
274               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
275               -s "tests.vpp.perf" \
276               --include pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan \
277               tests/
278         RETURN_STATUS=$(echo $?)
279         ;;
280     VPP-VERIFY-PERF-VHOST )
281         pybot ${PYBOT_ARGS} \
282               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
283               -s "tests.vpp.perf" \
284               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
285               tests/
286         RETURN_STATUS=$(echo $?)
287         ;;
288     VPP-VERIFY-PERF-MEMIF )
289         pybot ${PYBOT_ARGS} \
290               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
291               -s "tests.vpp.perf" \
292               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif \
293               --include pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif \
294               tests/
295         RETURN_STATUS=$(echo $?)
296         ;;
297     VPP-VERIFY-PERF-ACL )
298         pybot ${PYBOT_ARGS} \
299               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
300               -s "tests.vpp.perf" \
301               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDacl \
302               --include pdrdiscANDnic_intel-x520-da2AND2t2cANDacl \
303               tests/
304         RETURN_STATUS=$(echo $?)
305         ;;
306     PERFTEST_LONG )
307         pybot ${PYBOT_ARGS} \
308               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
309               -s "tests.vpp.perf" \
310               --exclude SKIP_PATCH \
311               -i NDRPDRDISC \
312               tests/
313         RETURN_STATUS=$(echo $?)
314         ;;
315     PERFTEST_SHORT )
316         pybot ${PYBOT_ARGS} \
317               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
318               -s "tests.vpp.perf" \
319               -i NDRCHK \
320               tests/
321         RETURN_STATUS=$(echo $?)
322         ;;
323     PERFTEST_NIGHTLY )
324         #run all available tests
325         pybot ${PYBOT_ARGS} \
326               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
327               -s "tests.vpp.perf" \
328               tests/
329         RETURN_STATUS=$(echo $?)
330         ;;
331     * )
332         # run full performance test suite and exit on fail
333         pybot ${PYBOT_ARGS} \
334               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
335               -s "tests.vpp.perf" \
336               tests/
337         RETURN_STATUS=$(echo $?)
338 esac
339
340 # Pybot output post-processing
341 echo Post-processing test data...
342
343 python ${SCRIPT_DIR}/resources/tools/scripts/robot_output_parser.py \
344        -i ${SCRIPT_DIR}/output.xml \
345        -o ${SCRIPT_DIR}/output_perf_data.xml \
346        -v ${VPP_STABLE_VER}
347 if [ ! $? -eq 0 ]; then
348     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
349 fi
350
351 python ${SCRIPT_DIR}/resources/tools/report_gen/run_robot_json_data.py \
352        --input ${SCRIPT_DIR}/output.xml \
353        --output ${SCRIPT_DIR}/output_perf_data.json \
354        --vdevice ${VPP_STABLE_VER}
355 if [ ! $? -eq 0 ]; then
356     echo "Generating JSON data for report from ${SCRIPT_DIR}/output.xml failed"
357 fi
358
359 # Archive artifacts
360 mkdir -p archive
361 for i in ${ARCHIVE_ARTIFACTS[@]}; do
362     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
363 done
364
365 echo Post-processing finished.
366
367 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.