7c4c6d3962ad6361aa401f1a957f90683a17905d
[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 LIGATO_REPO_URL=$(cat ${SCRIPT_DIR}/LIGATO_REPO_URL)
33 LIGATO_STABLE_VER=$(cat ${SCRIPT_DIR}/LIGATO_STABLE_VER)
34 VPP_COMMIT=$1
35 VPP_BUILD=$1
36 DOCKER_DEB="docker-ce_17.06.2~ce-0~ubuntu_amd64.deb"
37
38 # Clone & checkout stable vnf-agent
39 cd .. && git clone ${LIGATO_REPO_URL}/vpp-agent
40 # If the git clone fails, complain clearly and exit
41 if [ $? != 0 ]; then
42     echo "Failed to run: git clone --depth 1 ${LIGATO_REPO_URL}/vpp-agent"
43     exit 1
44 fi
45 cd vpp-agent && git checkout ${LIGATO_STABLE_VER}
46 # If the git checkout fails, complain clearly and exit
47 if [ $? != 0 ]; then
48     echo "Failed to run: git checkout ${LIGATO_STABLE_VER}"
49     exit 1
50 fi
51
52 # Install Docker
53 wget -q https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/${DOCKER_DEB}
54 sudo dpkg -i ${DOCKER_DEB}
55 # If installation fails, complain clearly and exit
56 if [ $? != 0 ]; then
57     echo "Failed to install Docker"
58     exit 1
59 fi
60
61 # Compile vnf-agent docker image
62 cd ${SCRIPT_DIR}/../vpp-agent/docker/dev_vpp_agent/ &&\
63     ./build.sh --agent ${LIGATO_STABLE_VER} --vpp ${VPP_COMMIT} &&\
64     ./shrink.sh
65 cd ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/ &&\
66     ./build.sh &&\
67     ./shrink.sh
68 # Export Docker image
69 sudo docker save prod_vpp_agent_shrink | gzip > prod_vpp_agent_shrink.tar.gz
70 # If image build fails, complain clearly and exit
71 if [ $? != 0 ]; then
72     echo "Failed to build vpp-agent Docker image."
73     exit 1
74 fi
75 DOCKER_IMAGE="$( readlink -f prod_vpp_agent_shrink.tar.gz | tr '\n' ' ' )"
76
77 cd ${SCRIPT_DIR}
78
79 sudo apt-get -y update
80 sudo apt-get -y install libpython2.7-dev python-virtualenv
81
82 WORKING_TOPOLOGY=""
83 export PYTHONPATH=${SCRIPT_DIR}
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_container_copy.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_container_copy.py\
124     -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -i ${DOCKER_IMAGE}
125 if [ $? -eq 0 ]; then
126     echo "Docker image copied and loaded on hosts from: ${WORKING_TOPOLOGY}"
127 else
128     echo "Failed to copy and load Docker image to DUTs"
129     exit 1
130 fi
131
132 case "$TEST_TAG" in
133     # run specific performance tests based on jenkins job type variable
134     PERFTEST_DAILY )
135         pybot ${PYBOT_ARGS} \
136               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
137               -v DPDK_TEST:True \
138               -s "tests.ligato.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               -v DPDK_TEST:True \
147               -s "tests.ligato.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               -v DPDK_TEST:True \
156               -s "tests.ligato.perf" \
157               --include ndrdiscAND1t1cORndrdiscAND2t2c \
158               tests/
159         RETURN_STATUS=$(echo $?)
160         ;;
161     VERIFY-PERF-PDRDISC )
162         pybot ${PYBOT_ARGS} \
163               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
164               -v DPDK_TEST:True \
165               -s "tests.ligato.perf" \
166               --include pdrdiscAND1t1cORpdrdiscAND2t2c \
167               tests/
168         RETURN_STATUS=$(echo $?)
169         ;;
170     VERIFY-PERF-NDRCHK )
171         pybot ${PYBOT_ARGS} \
172               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
173               -v DPDK_TEST:True \
174               -s "tests.ligato.perf" \
175               --include ndrchkAND1t1cORndrchkAND2t2c \
176               tests/
177         RETURN_STATUS=$(echo $?)
178         ;;
179     PERFTEST_NDRCHK_DAILY )
180         pybot ${PYBOT_ARGS} \
181               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
182               -v DPDK_TEST:True \
183               -s "tests.ligato.perf" \
184               --include ndrchkAND1t1cORndrchkAND2t2c \
185               tests/
186         RETURN_STATUS=$(echo $?)
187         ;;
188     VERIFY-PERF-IP4 )
189         pybot ${PYBOT_ARGS} \
190               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
191               -v DPDK_TEST:True \
192               -s "tests.ligato.perf" \
193               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip4baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
194               tests/
195         RETURN_STATUS=$(echo $?)
196         ;;
197     VERIFY-PERF-IP6 )
198         pybot ${PYBOT_ARGS} \
199               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
200               -v DPDK_TEST:True \
201               -s "tests.ligato.perf" \
202               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip6baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
203               tests/
204         RETURN_STATUS=$(echo $?)
205         ;;
206     VERIFY-PERF-L2 )
207         pybot ${PYBOT_ARGS} \
208               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
209               -v DPDK_TEST:True \
210               -s "tests.ligato.perf" \
211               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrdiscANDnic_intel-x520-da2AND1t1cANDl2bdbase \
212               tests/
213         RETURN_STATUS=$(echo $?)
214         ;;
215     VERIFY-PERF-LISP )
216         pybot ${PYBOT_ARGS} \
217               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
218               -v DPDK_TEST:True \
219               -s "tests.ligato.perf" \
220               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDlisp \
221               tests/
222         RETURN_STATUS=$(echo $?)
223         ;;
224     VERIFY-PERF-VXLAN )
225         pybot ${PYBOT_ARGS} \
226               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
227               -v DPDK_TEST:True \
228               -s "tests.ligato.perf" \
229               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvxlan \
230               tests/
231         RETURN_STATUS=$(echo $?)
232         ;;
233     VERIFY-PERF-VHOST )
234         pybot ${PYBOT_ARGS} \
235               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
236               -v DPDK_TEST:True \
237               -s "tests.ligato.perf" \
238               --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
239               tests/
240         RETURN_STATUS=$(echo $?)
241         ;;
242     VPP-VERIFY-PERF-IP4 )
243         pybot ${PYBOT_ARGS} \
244               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
245               -v DPDK_TEST:True \
246               -s "tests.ligato.perf" \
247               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip4baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
248               tests/
249         RETURN_STATUS=$(echo $?)
250         ;;
251     VPP-VERIFY-PERF-IP6 )
252         pybot ${PYBOT_ARGS} \
253               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
254               -v DPDK_TEST:True \
255               -s "tests.ligato.perf" \
256               --include pdrchkANDnic_intel-x520-da2AND1t1cANDip6baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
257               tests/
258         RETURN_STATUS=$(echo $?)
259         ;;
260     VPP-VERIFY-PERF-L2 )
261         pybot ${PYBOT_ARGS} \
262               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
263               -v DPDK_TEST:True \
264               -s "tests.ligato.perf" \
265               --include pdrchkANDnic_intel-x520-da2AND1t1cANDl2xcbaseORpdrchkANDnic_intel-x520-da2AND1t1cANDl2bdbase \
266               tests/
267         RETURN_STATUS=$(echo $?)
268         ;;
269     VPP-VERIFY-PERF-LISP )
270         pybot ${PYBOT_ARGS} \
271               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
272               -v DPDK_TEST:True \
273               -s "tests.ligato.perf" \
274               --include pdrchkANDnic_intel-x520-da2AND1t1cANDlisp \
275               tests/
276         RETURN_STATUS=$(echo $?)
277         ;;
278     VPP-VERIFY-PERF-VXLAN )
279         pybot ${PYBOT_ARGS} \
280               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
281               -v DPDK_TEST:True \
282               -s "tests.ligato.perf" \
283               --include pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan \
284               tests/
285         RETURN_STATUS=$(echo $?)
286         ;;
287     VPP-VERIFY-PERF-VHOST )
288         pybot ${PYBOT_ARGS} \
289               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
290               -v DPDK_TEST:True \
291               -s "tests.ligato.perf" \
292               --include pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
293               tests/
294         RETURN_STATUS=$(echo $?)
295         ;;
296     VPP-VERIFY-PERF-ACL )
297         pybot ${PYBOT_ARGS} \
298               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
299               -v DPDK_TEST:True \
300               -s "tests.ligato.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               -v DPDK_TEST:True \
310               -s "tests.ligato.perf" \
311               --exclude SKIP_PATCH \
312               -i NDRPDRDISC \
313               tests/
314         RETURN_STATUS=$(echo $?)
315         ;;
316     PERFTEST_SHORT )
317         pybot ${PYBOT_ARGS} \
318               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
319               -v DPDK_TEST:True \
320               -s "tests.ligato.perf" \
321               -i NDRCHK \
322               tests/
323         RETURN_STATUS=$(echo $?)
324         ;;
325     PERFTEST_NIGHTLY )
326         #run all available tests
327         pybot ${PYBOT_ARGS} \
328               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
329               -v DPDK_TEST:True \
330               -s "tests.ligato.perf" \
331               tests/
332         RETURN_STATUS=$(echo $?)
333         ;;
334     * )
335         # run full performance test suite and exit on fail
336         pybot ${PYBOT_ARGS} \
337               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
338               -v DPDK_TEST:True \
339               -s "tests.ligato.perf" \
340               tests/
341         RETURN_STATUS=$(echo $?)
342 esac
343
344 # Pybot output post-processing
345 echo Post-processing test data...
346
347 python ${SCRIPT_DIR}/resources/tools/scripts/robot_output_parser.py \
348        -i ${SCRIPT_DIR}/output.xml \
349        -o ${SCRIPT_DIR}/output_perf_data.xml \
350        -v ${VPP_BUILD}
351 if [ ! $? -eq 0 ]; then
352     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
353 fi
354
355 # Archive artifacts
356 mkdir -p archive
357 for i in ${ARCHIVE_ARTIFACTS[@]}; do
358     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
359 done
360
361 echo Post-processing finished.
362
363 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.