CSIT-816: SRv6 L1 KWs
[csit.git] / bootstrap-verify-perf-ligato.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 -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 PYBOT_ARGS="-W 150 -L TRACE"
29
30 ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)
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 -p vpp/build-root
36     cd vpp/build-root
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         # Temporary disable using dpdk
59         # wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
60         wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
61         wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
62         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
63     fi
64
65     # Temporary workaround as ligato docker file requires specific file name
66     rename -v 's/^(.*)-(\d.*)-deb.deb/$1_$2.deb/' *.deb
67     cd ${SCRIPT_DIR}
68
69 # If we run this script from vpp project we want to use local build
70 elif [[ ${JOB_NAME} == vpp-* ]] ;
71 then
72     mkdir -p vpp/build-root
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     # Move files to build-root for packing
79     for deb in ${VPP_DEBS}; do mv ${deb} vpp/build-root/; done
80 else
81     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
82     exit 1
83 fi
84
85 # Compress all VPP debs and remove temporary directory
86 tar -zcvf ${SCRIPT_DIR}/vpp.tar.gz vpp/*  && rm -R vpp
87
88 LIGATO_REPO_URL=$(cat ${SCRIPT_DIR}/LIGATO_REPO_URL)
89 VPP_AGENT_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_AGENT_STABLE_VER)
90 VPP_AGENT_STABLE_COMMIT="$( expr match `cat VPP_AGENT_STABLE_VER` '.*g\(.*\)' )"
91 DOCKER_DEB="docker-ce_17.06.2~ce-0~ubuntu_amd64.deb"
92
93 # Clone & checkout stable vnf-agent
94 cd .. && git clone ${LIGATO_REPO_URL}/vpp-agent
95 # If the git clone fails, complain clearly and exit
96 if [ $? != 0 ]; then
97     echo "Failed to run: git clone --depth 1 ${LIGATO_REPO_URL}/vpp-agent"
98     exit 1
99 fi
100 cd vpp-agent && git checkout ${VPP_AGENT_STABLE_COMMIT}
101 # If the git checkout fails, complain clearly and exit
102 if [ $? != 0 ]; then
103     echo "Failed to run: git checkout ${VPP_AGENT_STABLE_VER}"
104     exit 1
105 fi
106
107 # Install Docker
108 wget -q https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/${DOCKER_DEB}
109 sudo dpkg -i ${DOCKER_DEB}
110 # If installation fails, complain clearly and exit
111 if [ $? != 0 ]; then
112     echo "Failed to install Docker"
113     exit 1
114 fi
115
116 # Pull ligato/dev_vpp_agent docker image and re-tag as local
117 sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}
118 sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}\
119     dev_vpp_agent:latest
120 sudo docker images
121
122 # Build prod_vpp_agent docker image
123 cd ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/ &&\
124     mv ${SCRIPT_DIR}/vpp.tar.gz . &&\
125     ./extract_agent_files.sh &&\
126     sudo docker build -t prod_vpp_agent --no-cache . &&\
127     ./shrink.sh
128 # Export Docker image
129 sudo docker save prod_vpp_agent_shrink | gzip > prod_vpp_agent_shrink.tar.gz
130 # If image build fails, complain clearly and exit
131 if [ $? != 0 ]; then
132     echo "Failed to build vpp-agent Docker image."
133     exit 1
134 fi
135 DOCKER_IMAGE="$( readlink -f prod_vpp_agent_shrink.tar.gz | tr '\n' ' ' )"
136
137 cd ${SCRIPT_DIR}
138
139 sudo apt-get -y update
140 sudo apt-get -y install libpython2.7-dev python-virtualenv
141
142 WORKING_TOPOLOGY=""
143 export PYTHONPATH=${SCRIPT_DIR}
144
145 virtualenv --system-site-packages env
146 . env/bin/activate
147
148 echo pip install
149 pip install -r requirements.txt
150
151 # We iterate over available topologies and wait until we reserve topology
152 while :; do
153     for TOPOLOGY in ${TOPOLOGIES};
154     do
155         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
156         if [ $? -eq 0 ]; then
157             WORKING_TOPOLOGY=${TOPOLOGY}
158             echo "Reserved: ${WORKING_TOPOLOGY}"
159             break
160         fi
161     done
162
163     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
164         # Exit the infinite while loop if we made a reservation
165         break
166     fi
167
168     # Wait ~3minutes before next try
169     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
170     echo "Sleeping ${SLEEP_TIME}"
171     sleep ${SLEEP_TIME}
172 done
173
174 function cancel_all {
175     python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py -c -d ${INSTALLATION_DIR} -t $1
176     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
177 }
178
179 # On script exit we cancel the reservation and installation and delete all vpp
180 # packages
181 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
182
183 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py\
184     -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -i ${DOCKER_IMAGE}
185 if [ $? -eq 0 ]; then
186     echo "Docker image copied and loaded on hosts from: ${WORKING_TOPOLOGY}"
187 else
188     echo "Failed to copy and load Docker image to DUTs"
189     exit 1
190 fi
191
192 case "$TEST_TAG" in
193     # run specific performance tests based on jenkins job type variable
194     PERFTEST_DAILY )
195         pybot ${PYBOT_ARGS} \
196               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
197               -v DPDK_TEST:True \
198               -s "tests.kubernetes.perf" \
199               --include ndrdiscANDnic_intel-x520-da2AND1t1cORndrdiscANDnic_intel-x520-da2AND2t2c \
200               tests/
201         RETURN_STATUS=$(echo $?)
202         ;;
203     PERFTEST_SEMI_WEEKLY )
204         pybot ${PYBOT_ARGS} \
205               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
206               -v DPDK_TEST:True \
207               -s "tests.kubernetes.perf" \
208               --include ndrdiscANDnic_intel-x710AND1t1cORndrdiscANDnic_intel-x710AND2t2cORndrdiscANDnic_intel-xl710AND1t1cORndrdiscANDnic_intel-xl710AND2t2c \
209               tests/
210         RETURN_STATUS=$(echo $?)
211         ;;
212     VERIFY-PERF-NDRDISC )
213         pybot ${PYBOT_ARGS} \
214               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
215               -v DPDK_TEST:True \
216               -s "tests.kubernetes.perf" \
217               --include ndrdiscAND1t1cORndrdiscAND2t2c \
218               tests/
219         RETURN_STATUS=$(echo $?)
220         ;;
221     VERIFY-PERF-PDRDISC )
222         pybot ${PYBOT_ARGS} \
223               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
224               -v DPDK_TEST:True \
225               -s "tests.kubernetes.perf" \
226               --include pdrdiscAND1t1cORpdrdiscAND2t2c \
227               tests/
228         RETURN_STATUS=$(echo $?)
229         ;;
230     VERIFY-PERF-NDRCHK )
231         pybot ${PYBOT_ARGS} \
232               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
233               -v DPDK_TEST:True \
234               -s "tests.kubernetes.perf" \
235               --include ndrchkAND1t1cORndrchkAND2t2c \
236               tests/
237         RETURN_STATUS=$(echo $?)
238         ;;
239     PERFTEST_NDRCHK_DAILY )
240         pybot ${PYBOT_ARGS} \
241               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
242               -v DPDK_TEST:True \
243               -s "tests.kubernetes.perf" \
244               --include ndrchkAND1t1cORndrchkAND2t2c \
245               tests/
246         RETURN_STATUS=$(echo $?)
247         ;;
248     VERIFY-PERF-IP4 )
249         pybot ${PYBOT_ARGS} \
250               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
251               -v DPDK_TEST:True \
252               -s "tests.kubernetes.perf" \
253               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip4baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
254               tests/
255         RETURN_STATUS=$(echo $?)
256         ;;
257     VERIFY-PERF-IP6 )
258         pybot ${PYBOT_ARGS} \
259               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
260               -v DPDK_TEST:True \
261               -s "tests.kubernetes.perf" \
262               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip6baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
263               tests/
264         RETURN_STATUS=$(echo $?)
265         ;;
266     VERIFY-PERF-L2 )
267         pybot ${PYBOT_ARGS} \
268               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
269               -v DPDK_TEST:True \
270               -s "tests.kubernetes.perf" \
271               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrdiscANDnic_intel-x520-da2AND1t1cANDl2bdbase \
272               tests/
273         RETURN_STATUS=$(echo $?)
274         ;;
275     VERIFY-PERF-LISP )
276         pybot ${PYBOT_ARGS} \
277               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
278               -v DPDK_TEST:True \
279               -s "tests.kubernetes.perf" \
280               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDlisp \
281               tests/
282         RETURN_STATUS=$(echo $?)
283         ;;
284     VERIFY-PERF-VXLAN )
285         pybot ${PYBOT_ARGS} \
286               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
287               -v DPDK_TEST:True \
288               -s "tests.kubernetes.perf" \
289               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvxlan \
290               tests/
291         RETURN_STATUS=$(echo $?)
292         ;;
293     VERIFY-PERF-VHOST )
294         pybot ${PYBOT_ARGS} \
295               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
296               -v DPDK_TEST:True \
297               -s "tests.kubernetes.perf" \
298               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
299               tests/
300         RETURN_STATUS=$(echo $?)
301         ;;
302     VPP-VERIFY-PERF-IP4 )
303         pybot ${PYBOT_ARGS} \
304               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
305               -v DPDK_TEST:True \
306               -s "tests.kubernetes.perf" \
307               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip4baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
308               tests/
309         RETURN_STATUS=$(echo $?)
310         ;;
311     VPP-VERIFY-PERF-IP6 )
312         pybot ${PYBOT_ARGS} \
313               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
314               -v DPDK_TEST:True \
315               -s "tests.kubernetes.perf" \
316               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip6baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
317               tests/
318         RETURN_STATUS=$(echo $?)
319         ;;
320     VPP-VERIFY-PERF-L2 )
321         pybot ${PYBOT_ARGS} \
322               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
323               -v DPDK_TEST:True \
324               -s "tests.kubernetes.perf" \
325               --include pdrchkANDnic_intel-x520-da2AND1t1cANDl2xcbaseORpdrchkANDnic_intel-x520-da2AND1t1cANDl2bdbase \
326               tests/
327         RETURN_STATUS=$(echo $?)
328         ;;
329     VPP-VERIFY-PERF-LISP )
330         pybot ${PYBOT_ARGS} \
331               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
332               -v DPDK_TEST:True \
333               -s "tests.kubernetes.perf" \
334               --include pdrchkANDnic_intel-x520-da2AND1t1cANDlisp \
335               tests/
336         RETURN_STATUS=$(echo $?)
337         ;;
338     VPP-VERIFY-PERF-VXLAN )
339         pybot ${PYBOT_ARGS} \
340               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
341               -v DPDK_TEST:True \
342               -s "tests.kubernetes.perf" \
343               --include pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan \
344               tests/
345         RETURN_STATUS=$(echo $?)
346         ;;
347     VPP-VERIFY-PERF-VHOST )
348         pybot ${PYBOT_ARGS} \
349               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
350               -v DPDK_TEST:True \
351               -s "tests.kubernetes.perf" \
352               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
353               tests/
354         RETURN_STATUS=$(echo $?)
355         ;;
356     VPP-VERIFY-PERF-ACL )
357         pybot ${PYBOT_ARGS} \
358               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
359               -v DPDK_TEST:True \
360               -s "tests.kubernetes.perf" \
361               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDacl \
362               --include pdrdiscANDnic_intel-x520-da2AND2t2cANDacl \
363               tests/
364         RETURN_STATUS=$(echo $?)
365         ;;
366     PERFTEST_LONG )
367         pybot ${PYBOT_ARGS} \
368               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
369               -v DPDK_TEST:True \
370               -s "tests.kubernetes.perf" \
371               --exclude SKIP_PATCH \
372               -i NDRPDRDISC \
373               tests/
374         RETURN_STATUS=$(echo $?)
375         ;;
376     PERFTEST_SHORT )
377         pybot ${PYBOT_ARGS} \
378               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
379               -v DPDK_TEST:True \
380               -s "tests.kubernetes.perf" \
381               -i NDRCHK \
382               tests/
383         RETURN_STATUS=$(echo $?)
384         ;;
385     PERFTEST_NIGHTLY )
386         #run all available tests
387         pybot ${PYBOT_ARGS} \
388               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
389               -v DPDK_TEST:True \
390               -s "tests.kubernetes.perf" \
391               tests/
392         RETURN_STATUS=$(echo $?)
393         ;;
394     * )
395         # run full performance test suite and exit on fail
396         pybot ${PYBOT_ARGS} \
397               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
398               -v DPDK_TEST:True \
399               -s "tests.kubernetes.perf" \
400               tests/
401         RETURN_STATUS=$(echo $?)
402 esac
403
404 # Pybot output post-processing
405 echo Post-processing test data...
406
407 python ${SCRIPT_DIR}/resources/tools/scripts/robot_output_parser.py \
408        -i ${SCRIPT_DIR}/output.xml \
409        -o ${SCRIPT_DIR}/output_perf_data.xml \
410        -v ${VPP_STABLE_VER}
411 if [ ! $? -eq 0 ]; then
412     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
413 fi
414
415 # Archive artifacts
416 mkdir -p archive
417 for i in ${ARCHIVE_ARTIFACTS[@]}; do
418     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
419 done
420
421 echo Post-processing finished.
422
423 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.