CSIT-1008: Fix 9000B VM Vhost performance tests
[csit.git] / bootstrap-verify-perf-ligato.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 PYBOT_ARGS="-W 150 -L TRACE"
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     mkdir -p vpp/build-root
41     cd vpp/build-root
42
43     if [[ ${TEST_TAG} == *NIGHTLY ]] || \
44        [[ ${TEST_TAG} == *DAILY ]] || \
45        [[ ${TEST_TAG} == *WEEKLY ]];
46     then
47         # Download the latest VPP build .deb install packages
48         echo Downloading VPP packages...
49         bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh --skip-install
50
51         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
52         # Take vpp package and get the vpp version
53         VPP_STABLE_VER="$( expr match $(ls *.deb | head -n 1) 'vpp-\(.*\)-deb.deb' )"
54     else
55         DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)_amd64
56         VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL_UBUNTU)
57         VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU)
58         VPP_CLASSIFIER="-deb"
59         # Download vpp build from nexus and set VPP_DEBS variable
60         wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
61         wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
62         wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
63         # Temporary disable using dpdk
64         # wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
65         wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
66         wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
67         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
68     fi
69
70     # Temporary workaround as ligato docker file requires specific file name
71     rename -v 's/^(.*)-(\d.*)-deb.deb/$1_$2.deb/' *.deb
72     cd ${SCRIPT_DIR}
73
74 # If we run this script from vpp project we want to use local build
75 elif [[ ${JOB_NAME} == vpp-* ]] ;
76 then
77     mkdir -p vpp/build-root
78     # Use local packages provided as argument list
79     # Jenkins VPP deb paths (convert to full path)
80     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
81     # Take vpp package and get the vpp version
82     VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )"
83     # Move files to build-root for packing
84     for deb in ${VPP_DEBS}; do mv ${deb} vpp/build-root/; done
85 else
86     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
87     exit 1
88 fi
89 dpkg -x vpp/build-root/vpp_${VPP_STABLE_VER}.deb /tmp/vpp
90
91 # Compress all VPP debs and remove temporary directory
92 tar -zcvf ${SCRIPT_DIR}/vpp.tar.gz vpp/* && rm -R vpp
93
94 LIGATO_REPO_URL=$(cat ${SCRIPT_DIR}/LIGATO_REPO_URL)
95 VPP_AGENT_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_AGENT_STABLE_VER)
96 VPP_AGENT_STABLE_COMMIT="$( expr match `cat VPP_AGENT_STABLE_VER` '.*g\(.*\)' )"
97 DOCKER_DEB="docker-ce_17.09.0~ce-0~ubuntu_amd64.deb"
98
99 # Clone & checkout stable vnf-agent
100 cd .. && git clone ${LIGATO_REPO_URL}/vpp-agent
101 # If the git clone fails, complain clearly and exit
102 if [ $? != 0 ]; then
103     echo "Failed to run: git clone --depth 1 ${LIGATO_REPO_URL}/vpp-agent"
104     exit 1
105 fi
106 cd vpp-agent && git checkout b99e43a
107 # If the git checkout fails, complain clearly and exit
108 if [ $? != 0 ]; then
109     echo "Failed to run: git checkout ${VPP_AGENT_STABLE_VER}"
110     exit 1
111 fi
112
113 # Install Docker
114 wget -q https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/${DOCKER_DEB}
115 sudo dpkg -i ${DOCKER_DEB}
116 # If installation fails, complain clearly and exit
117 if [ $? != 0 ]; then
118     echo "Failed to install Docker"
119     exit 1
120 fi
121
122 # Pull ligato/dev_vpp_agent docker image and re-tag as local
123 if [[ ${VPP_AGENT_STABLE_VER} == g* ]] ;
124 then
125     sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_COMMIT}
126     sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_COMMIT}\
127         dev_vpp_agent:latest
128 else
129     sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}
130     sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}\
131         dev_vpp_agent:latest
132 fi
133 sudo docker images
134 # Start dev_vpp_agent container as daemon
135 sudo docker run --rm -itd --name agentcnt dev_vpp_agent bash
136 # Copy latest vpp api into running container
137 sudo docker cp /tmp/vpp/usr/share/vpp/api agentcnt:/usr/share/vpp
138 # Recompile vpp-agent
139 sudo docker exec -i agentcnt \
140     script -qec '. ~/.bashrc; cd /root/go/src/github.com/ligato/vpp-agent && make generate && make install'
141 if [ $? != 0 ]; then
142     echo "Failed to build vpp-agent in Docker image."
143     exit 1
144 fi
145 # Extract vpp-agent
146 rm -rf agent
147 mkdir -p agent
148 sudo docker cp agentcnt:/root/go/bin/vpp-agent agent/
149 sudo docker cp agentcnt:/root/go/bin/vpp-agent-ctl agent/
150 sudo docker cp agentcnt:/root/go/bin/agentctl agent/
151 tar -zcvf ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/agent.tar.gz agent
152 # Kill running container
153 sudo docker rm -f agentcnt
154
155 # Build prod_vpp_agent docker image
156 cd ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/ &&\
157     mv ${SCRIPT_DIR}/vpp.tar.gz . &&\
158     sudo docker build -t prod_vpp_agent --no-cache .
159 # Export Docker image
160 sudo docker save prod_vpp_agent | gzip > prod_vpp_agent.tar.gz
161 # If image build fails, complain clearly and exit
162 if [ $? != 0 ]; then
163     echo "Failed to build vpp-agent Docker image."
164     exit 1
165 fi
166 DOCKER_IMAGE="$( readlink -f prod_vpp_agent.tar.gz | tr '\n' ' ' )"
167
168 cd ${SCRIPT_DIR}
169
170 sudo apt-get -y update
171 sudo apt-get -y install libpython2.7-dev python-virtualenv
172
173 WORKING_TOPOLOGY=""
174 export PYTHONPATH=${SCRIPT_DIR}
175
176 virtualenv --system-site-packages env
177 . env/bin/activate
178
179 echo pip install
180 pip install -r requirements.txt
181
182 # We iterate over available topologies and wait until we reserve topology
183 while :; do
184     for TOPOLOGY in ${TOPOLOGIES};
185     do
186         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
187         if [ $? -eq 0 ]; then
188             WORKING_TOPOLOGY=${TOPOLOGY}
189             echo "Reserved: ${WORKING_TOPOLOGY}"
190             break
191         fi
192     done
193
194     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
195         # Exit the infinite while loop if we made a reservation
196         break
197     fi
198
199     # Wait ~3minutes before next try
200     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
201     echo "Sleeping ${SLEEP_TIME}"
202     sleep ${SLEEP_TIME}
203 done
204
205 function cancel_all {
206     python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py -c -d ${INSTALLATION_DIR} -t $1
207     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
208 }
209
210 # On script exit we cancel the reservation and installation and delete all vpp
211 # packages
212 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
213
214 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py\
215     -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -i ${DOCKER_IMAGE}
216 if [ $? -eq 0 ]; then
217     echo "Docker image copied and loaded on hosts from: ${WORKING_TOPOLOGY}"
218 else
219     echo "Failed to copy and load Docker image to DUTs"
220     exit 1
221 fi
222
223 case "$TEST_TAG" in
224     # run specific performance tests based on jenkins job type variable
225     PERFTEST_DAILY )
226         pybot ${PYBOT_ARGS} \
227               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
228               -v DPDK_TEST:True \
229               -s "tests.kubernetes.perf" \
230               --include ndrdiscANDnic_intel-x520-da2AND1t1cORndrdiscANDnic_intel-x520-da2AND2t2c \
231               --include ndrdiscAND1t1cANDipsecORndrdiscAND2t2cANDipsec \
232               tests/
233         RETURN_STATUS=$(echo $?)
234         ;;
235     PERFTEST_SEMI_WEEKLY )
236         pybot ${PYBOT_ARGS} \
237               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
238               -v DPDK_TEST:True \
239               -s "tests.kubernetes.perf" \
240               --include ndrdiscANDnic_intel-x710AND1t1cORndrdiscANDnic_intel-x710AND2t2cORndrdiscANDnic_intel-xl710AND1t1cORndrdiscANDnic_intel-xl710AND2t2c \
241               tests/
242         RETURN_STATUS=$(echo $?)
243         ;;
244     PERFTEST_MRR_DAILY )
245         pybot ${PYBOT_ARGS} \
246               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
247               -v DPDK_TEST:True \
248               -s "tests.kubernetes.perf" \
249               --include mrrAND64bAND1t1c \
250               --include mrrAND64bAND2t2c \
251               --include mrrAND64bAND4t4c \
252               --include mrrAND78bAND1t1c \
253               --include mrrAND78bAND2t2c \
254               --include mrrAND78bAND4t4c \
255               tests/
256         RETURN_STATUS=$(echo $?)
257         ;;
258     VERIFY-PERF-NDRDISC )
259         pybot ${PYBOT_ARGS} \
260               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
261               -v DPDK_TEST:True \
262               -s "tests.kubernetes.perf" \
263               --include ndrdiscAND1t1cORndrdiscAND2t2c \
264               tests/
265         RETURN_STATUS=$(echo $?)
266         ;;
267     VERIFY-PERF-PDRDISC )
268         pybot ${PYBOT_ARGS} \
269               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
270               -v DPDK_TEST:True \
271               -s "tests.kubernetes.perf" \
272               --include pdrdiscAND1t1cORpdrdiscAND2t2c \
273               tests/
274         RETURN_STATUS=$(echo $?)
275         ;;
276     VERIFY-PERF-MRR )
277         pybot ${PYBOT_ARGS} \
278               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
279               -v DPDK_TEST:True \
280               -s "tests.kubernetes.perf" \
281               --include mrrAND1t1cORmrrAND2t2c \
282               tests/
283         RETURN_STATUS=$(echo $?)
284         ;;
285     VERIFY-PERF-IP4 )
286         pybot ${PYBOT_ARGS} \
287               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
288               -v DPDK_TEST:True \
289               -s "tests.kubernetes.perf" \
290               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip4baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
291               tests/
292         RETURN_STATUS=$(echo $?)
293         ;;
294     VERIFY-PERF-IP6 )
295         pybot ${PYBOT_ARGS} \
296               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
297               -v DPDK_TEST:True \
298               -s "tests.kubernetes.perf" \
299               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip6baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
300               tests/
301         RETURN_STATUS=$(echo $?)
302         ;;
303     VERIFY-PERF-L2 )
304         pybot ${PYBOT_ARGS} \
305               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
306               -v DPDK_TEST:True \
307               -s "tests.kubernetes.perf" \
308               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrdiscANDnic_intel-x520-da2AND1t1cANDl2bdbase \
309               tests/
310         RETURN_STATUS=$(echo $?)
311         ;;
312     VERIFY-PERF-LISP )
313         pybot ${PYBOT_ARGS} \
314               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
315               -v DPDK_TEST:True \
316               -s "tests.kubernetes.perf" \
317               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDlisp \
318               tests/
319         RETURN_STATUS=$(echo $?)
320         ;;
321     VERIFY-PERF-VXLAN )
322         pybot ${PYBOT_ARGS} \
323               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
324               -v DPDK_TEST:True \
325               -s "tests.kubernetes.perf" \
326               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvxlan \
327               tests/
328         RETURN_STATUS=$(echo $?)
329         ;;
330     VERIFY-PERF-VHOST )
331         pybot ${PYBOT_ARGS} \
332               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
333               -v DPDK_TEST:True \
334               -s "tests.kubernetes.perf" \
335               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
336               tests/
337         RETURN_STATUS=$(echo $?)
338         ;;
339     VERIFY-PERF-MEMIF )
340         pybot ${PYBOT_ARGS} \
341               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
342               -v DPDK_TEST:True \
343               -s "tests.kubernetes.perf" \
344               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDmemif \
345               tests/
346         RETURN_STATUS=$(echo $?)
347         ;;
348     VERIFY-PERF-IPSECHW )
349         pybot ${PYBOT_ARGS} \
350               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
351               -v DPDK_TEST:True \
352               -s "tests.kubernetes.perf" \
353               --include ndrdiscANDnic_intel-xl710AND1t1cANDipsechw \
354               --include ndrdiscANDnic_intel-xl710AND2t2cANDipsechw \
355               tests/
356         RETURN_STATUS=$(echo $?)
357         ;;
358     VPP-VERIFY-PERF-IP4 )
359         pybot ${PYBOT_ARGS} \
360               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
361               -v DPDK_TEST:True \
362               -s "tests.kubernetes.perf" \
363               --include mrrANDnic_intel-x520-da2AND1t1cANDip4baseORmrrANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
364               tests/
365         RETURN_STATUS=$(echo $?)
366         ;;
367     VPP-VERIFY-PERF-IP6 )
368         pybot ${PYBOT_ARGS} \
369               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
370               -v DPDK_TEST:True \
371               -s "tests.kubernetes.perf" \
372               --include mrrANDnic_intel-x520-da2AND1t1cANDip6baseORmrrANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
373               tests/
374         RETURN_STATUS=$(echo $?)
375         ;;
376     VPP-VERIFY-PERF-L2 )
377         pybot ${PYBOT_ARGS} \
378               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
379               -v DPDK_TEST:True \
380               -s "tests.kubernetes.perf" \
381               --include mrrANDnic_intel-x520-da2AND1t1cANDl2xcbaseORmrrANDnic_intel-x520-da2AND1t1cANDl2bdbase \
382               tests/
383         RETURN_STATUS=$(echo $?)
384         ;;
385     VPP-VERIFY-PERF-LISP )
386         pybot ${PYBOT_ARGS} \
387               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
388               -v DPDK_TEST:True \
389               -s "tests.kubernetes.perf" \
390               --include pdrchkANDnic_intel-x520-da2AND1t1cANDlisp \
391               tests/
392         RETURN_STATUS=$(echo $?)
393         ;;
394     VPP-VERIFY-PERF-VXLAN )
395         pybot ${PYBOT_ARGS} \
396               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
397               -v DPDK_TEST:True \
398               -s "tests.kubernetes.perf" \
399               --include pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan \
400               tests/
401         RETURN_STATUS=$(echo $?)
402         ;;
403     VPP-VERIFY-PERF-VHOST )
404         pybot ${PYBOT_ARGS} \
405               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
406               -v DPDK_TEST:True \
407               -s "tests.kubernetes.perf" \
408               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
409               tests/
410         RETURN_STATUS=$(echo $?)
411         ;;
412     VPP-VERIFY-PERF-MEMIF )
413         pybot ${PYBOT_ARGS} \
414               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
415               -v DPDK_TEST:True \
416               -s "tests.kubernetes.perf" \
417               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif \
418               --include pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif \
419               --include mrrANDnic_intel-x520-da2AND1t1cANDmemif \
420               --include mrrANDnic_intel-x520-da2AND2t2cANDmemif \
421               tests/
422         RETURN_STATUS=$(echo $?)
423         ;;
424     VPP-VERIFY-PERF-ACL )
425         pybot ${PYBOT_ARGS} \
426               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
427               -v DPDK_TEST:True \
428               -s "tests.kubernetes.perf" \
429               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDacl \
430               --include pdrdiscANDnic_intel-x520-da2AND2t2cANDacl \
431               tests/
432         RETURN_STATUS=$(echo $?)
433         ;;
434     VPP-VERIFY-PERF-IPSECHW )
435         pybot ${PYBOT_ARGS} \
436               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
437               -v DPDK_TEST:True \
438               -s "tests.kubernetes.perf" \
439               --include pdrdiscANDnic_intel-xl710AND1t1cANDipsechw \
440               --include pdrdiscANDnic_intel-xl710AND2t2cANDipsechw \
441               tests/
442         RETURN_STATUS=$(echo $?)
443         ;;
444     * )
445         # run full performance test suite and exit on fail
446         pybot ${PYBOT_ARGS} \
447               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
448               -v DPDK_TEST:True \
449               -s "tests.kubernetes.perf" \
450               tests/
451         RETURN_STATUS=$(echo $?)
452 esac
453
454 # Archive JOB artifacts in jenkins
455 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
456     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
457 done
458 # Archive JOB artifacts to logs.fd.io
459 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
460     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
461 done
462
463 exit ${RETURN_STATUS}