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