CSIT-755: Presentation and analytics layer
[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               tests/
141         RETURN_STATUS=$(echo $?)
142         ;;
143     PERFTEST_SEMI_WEEKLY )
144         pybot ${PYBOT_ARGS} \
145               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
146               -s "tests.vpp.perf" \
147               --include ndrdiscANDnic_intel-x710AND1t1cORndrdiscANDnic_intel-x710AND2t2cORndrdiscANDnic_intel-xl710AND1t1cORndrdiscANDnic_intel-xl710AND2t2c \
148               tests/
149         RETURN_STATUS=$(echo $?)
150         ;;
151     VERIFY-PERF-NDRDISC )
152         pybot ${PYBOT_ARGS} \
153               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
154               -s "tests.vpp.perf" \
155               --include ndrdiscAND1t1cORndrdiscAND2t2c \
156               tests/
157         RETURN_STATUS=$(echo $?)
158         ;;
159     VERIFY-PERF-PDRDISC )
160         pybot ${PYBOT_ARGS} \
161               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
162               -s "tests.vpp.perf" \
163               --include pdrdiscAND1t1cORpdrdiscAND2t2c \
164               tests/
165         RETURN_STATUS=$(echo $?)
166         ;;
167     VERIFY-PERF-NDRCHK )
168         pybot ${PYBOT_ARGS} \
169               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
170               -s "tests.vpp.perf" \
171               --include ndrchkAND1t1cORndrchkAND2t2c \
172               tests/
173         RETURN_STATUS=$(echo $?)
174         ;;
175     PERFTEST_NDRCHK_DAILY )
176         pybot ${PYBOT_ARGS} \
177               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
178               -s "tests.vpp.perf" \
179               --include ndrchkAND1t1cORndrchkAND2t2c \
180               tests/
181         RETURN_STATUS=$(echo $?)
182         ;;
183     VERIFY-PERF-IP4 )
184         pybot ${PYBOT_ARGS} \
185               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
186               -s "tests.vpp.perf" \
187               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip4baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
188               tests/
189         RETURN_STATUS=$(echo $?)
190         ;;
191     VERIFY-PERF-IP6 )
192         pybot ${PYBOT_ARGS} \
193               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
194               -s "tests.vpp.perf" \
195               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip6baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
196               tests/
197         RETURN_STATUS=$(echo $?)
198         ;;
199     VERIFY-PERF-L2 )
200         pybot ${PYBOT_ARGS} \
201               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
202               -s "tests.vpp.perf" \
203               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrdiscANDnic_intel-x520-da2AND1t1cANDl2bdbase \
204               tests/
205         RETURN_STATUS=$(echo $?)
206         ;;
207     VERIFY-PERF-LISP )
208         pybot ${PYBOT_ARGS} \
209               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
210               -s "tests.vpp.perf" \
211               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDlisp \
212               tests/
213         RETURN_STATUS=$(echo $?)
214         ;;
215     VERIFY-PERF-VXLAN )
216         pybot ${PYBOT_ARGS} \
217               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
218               -s "tests.vpp.perf" \
219               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvxlan \
220               tests/
221         RETURN_STATUS=$(echo $?)
222         ;;
223     VERIFY-PERF-VHOST )
224         pybot ${PYBOT_ARGS} \
225               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
226               -s "tests.vpp.perf" \
227               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
228               tests/
229         RETURN_STATUS=$(echo $?)
230         ;;
231     VERIFY-PERF-MEMIF )
232         pybot ${PYBOT_ARGS} \
233               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
234               -s "tests.vpp.perf" \
235               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDmemif \
236               tests/
237         RETURN_STATUS=$(echo $?)
238         ;;
239     VPP-VERIFY-PERF-IP4 )
240         pybot ${PYBOT_ARGS} \
241               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
242               -s "tests.vpp.perf" \
243               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip4baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
244               tests/
245         RETURN_STATUS=$(echo $?)
246         ;;
247     VPP-VERIFY-PERF-IP6 )
248         pybot ${PYBOT_ARGS} \
249               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
250               -s "tests.vpp.perf" \
251               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip6baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
252               tests/
253         RETURN_STATUS=$(echo $?)
254         ;;
255     VPP-VERIFY-PERF-L2 )
256         pybot ${PYBOT_ARGS} \
257               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
258               -s "tests.vpp.perf" \
259               --include pdrchkANDnic_intel-x520-da2AND1t1cANDl2xcbaseORpdrchkANDnic_intel-x520-da2AND1t1cANDl2bdbase \
260               tests/
261         RETURN_STATUS=$(echo $?)
262         ;;
263     VPP-VERIFY-PERF-LISP )
264         pybot ${PYBOT_ARGS} \
265               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
266               -s "tests.vpp.perf" \
267               --include pdrchkANDnic_intel-x520-da2AND1t1cANDlisp \
268               tests/
269         RETURN_STATUS=$(echo $?)
270         ;;
271     VPP-VERIFY-PERF-VXLAN )
272         pybot ${PYBOT_ARGS} \
273               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
274               -s "tests.vpp.perf" \
275               --include pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan \
276               tests/
277         RETURN_STATUS=$(echo $?)
278         ;;
279     VPP-VERIFY-PERF-VHOST )
280         pybot ${PYBOT_ARGS} \
281               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
282               -s "tests.vpp.perf" \
283               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
284               tests/
285         RETURN_STATUS=$(echo $?)
286         ;;
287     VPP-VERIFY-PERF-MEMIF )
288         pybot ${PYBOT_ARGS} \
289               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
290               -s "tests.vpp.perf" \
291               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif \
292               --include pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif \
293               tests/
294         RETURN_STATUS=$(echo $?)
295         ;;
296     VPP-VERIFY-PERF-ACL )
297         pybot ${PYBOT_ARGS} \
298               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
299               -s "tests.vpp.perf" \
300               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDacl \
301               --include pdrdiscANDnic_intel-x520-da2AND2t2cANDacl \
302               tests/
303         RETURN_STATUS=$(echo $?)
304         ;;
305     PERFTEST_LONG )
306         pybot ${PYBOT_ARGS} \
307               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
308               -s "tests.vpp.perf" \
309               --exclude SKIP_PATCH \
310               -i NDRPDRDISC \
311               tests/
312         RETURN_STATUS=$(echo $?)
313         ;;
314     PERFTEST_SHORT )
315         pybot ${PYBOT_ARGS} \
316               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
317               -s "tests.vpp.perf" \
318               -i NDRCHK \
319               tests/
320         RETURN_STATUS=$(echo $?)
321         ;;
322     PERFTEST_NIGHTLY )
323         #run all available tests
324         pybot ${PYBOT_ARGS} \
325               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
326               -s "tests.vpp.perf" \
327               tests/
328         RETURN_STATUS=$(echo $?)
329         ;;
330     * )
331         # run full performance test suite and exit on fail
332         pybot ${PYBOT_ARGS} \
333               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
334               -s "tests.vpp.perf" \
335               tests/
336         RETURN_STATUS=$(echo $?)
337 esac
338
339 # Pybot output post-processing
340 echo Post-processing test data...
341
342 python ${SCRIPT_DIR}/resources/tools/scripts/robot_output_parser.py \
343        -i ${SCRIPT_DIR}/output.xml \
344        -o ${SCRIPT_DIR}/output_perf_data.xml \
345        -v ${VPP_STABLE_VER}
346 if [ ! $? -eq 0 ]; then
347     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
348 fi
349
350 python ${SCRIPT_DIR}/resources/tools/report_gen/run_robot_json_data.py \
351        --input ${SCRIPT_DIR}/output.xml \
352        --output ${SCRIPT_DIR}/output_perf_data.json \
353        --vdevice ${VPP_STABLE_VER}
354 if [ ! $? -eq 0 ]; then
355     echo "Generating JSON data for report from ${SCRIPT_DIR}/output.xml failed"
356 fi
357
358 # Archive artifacts
359 mkdir -p archive
360 for i in ${ARCHIVE_ARTIFACTS[@]}; do
361     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
362 done
363
364 echo Post-processing finished.
365
366 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.