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:
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
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"
22 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25 RESERVATION_DIR="/tmp/reservation_dir"
26 INSTALLATION_DIR="/tmp/install_dir"
28 PYBOT_ARGS="-W 150 -L TRACE"
30 ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)
32 # If we run this script from CSIT jobs we want to use stable vpp version
33 if [[ ${JOB_NAME} == csit-* ]] ;
35 mkdir -p vpp/build-root
38 if [[ ${TEST_TAG} == *NIGHTLY ]] || \
39 [[ ${TEST_TAG} == *DAILY ]] || \
40 [[ ${TEST_TAG} == *WEEKLY ]];
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
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' )"
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)
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' ' ' )"
65 dpkg -x vpp-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb /tmp/vpp
66 # Temporary workaround as ligato docker file requires specific file name
67 rename -v 's/^(.*)-(\d.*)-deb.deb/$1_$2.deb/' *.deb
70 # If we run this script from vpp project we want to use local build
71 elif [[ ${JOB_NAME} == vpp-* ]] ;
73 mkdir -p vpp/build-root
74 # Use local packages provided as argument list
75 # Jenkins VPP deb paths (convert to full path)
76 VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
77 # Take vpp package and get the vpp version
78 VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )"
79 # Move files to build-root for packing
80 for deb in ${VPP_DEBS}; do mv ${deb} vpp/build-root/; done
81 dpkg -x vpp/build-root/vpp_${VPP_STABLE_VER}.deb /tmp/vpp
83 echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
87 # Compress all VPP debs and remove temporary directory
88 tar -zcvf ${SCRIPT_DIR}/vpp.tar.gz vpp/* && rm -R vpp
90 LIGATO_REPO_URL=$(cat ${SCRIPT_DIR}/LIGATO_REPO_URL)
91 VPP_AGENT_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_AGENT_STABLE_VER)
92 VPP_AGENT_STABLE_COMMIT="$( expr match `cat VPP_AGENT_STABLE_VER` '.*g\(.*\)' )"
93 DOCKER_DEB="docker-ce_17.09.0~ce-0~ubuntu_amd64.deb"
95 # Clone & checkout stable vnf-agent
96 cd .. && git clone ${LIGATO_REPO_URL}/vpp-agent
97 # If the git clone fails, complain clearly and exit
99 echo "Failed to run: git clone --depth 1 ${LIGATO_REPO_URL}/vpp-agent"
102 cd vpp-agent && git checkout ${VPP_AGENT_STABLE_COMMIT}
103 # If the git checkout fails, complain clearly and exit
105 echo "Failed to run: git checkout ${VPP_AGENT_STABLE_VER}"
110 wget -q https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/${DOCKER_DEB}
111 sudo dpkg -i ${DOCKER_DEB}
112 # If installation fails, complain clearly and exit
114 echo "Failed to install Docker"
118 # Pull ligato/dev_vpp_agent docker image and re-tag as local
119 sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}
120 sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}\
124 # Start dev_vpp_agent container as daemon
125 sudo docker run --rm -itd --name agentcnt dev_vpp_agent bash
126 # Copy latest vpp api into running container
127 sudo docker cp /tmp/vpp/usr/share/vpp/api agentcnt:/usr/share/vpp
128 # Recompile vpp-agent
129 sudo docker exec -i agentcnt \
130 script -qc '. ~/.bashrc; cd /root/go/src/github.com/ligato/vpp-agent && make generate && make install'
134 sudo docker cp agentcnt:/root/go/bin/vpp-agent agent/
135 sudo docker cp agentcnt:/root/go/bin/vpp-agent-ctl agent/
136 sudo docker cp agentcnt:/root/go/bin/agentctl agent/
137 tar -zcvf ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/agent.tar.gz agent
138 # Kill running container
139 sudo docker rm -f agentcnt
141 # Build prod_vpp_agent docker image
142 cd ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/ &&\
143 mv ${SCRIPT_DIR}/vpp.tar.gz . &&\
144 sudo docker build -t prod_vpp_agent --no-cache .
145 # Export Docker image
146 sudo docker save prod_vpp_agent | gzip > prod_vpp_agent.tar.gz
147 # If image build fails, complain clearly and exit
149 echo "Failed to build vpp-agent Docker image."
152 DOCKER_IMAGE="$( readlink -f prod_vpp_agent.tar.gz | tr '\n' ' ' )"
156 sudo apt-get -y update
157 sudo apt-get -y install libpython2.7-dev python-virtualenv
160 export PYTHONPATH=${SCRIPT_DIR}
162 virtualenv --system-site-packages env
166 pip install -r requirements.txt
168 # We iterate over available topologies and wait until we reserve topology
170 for TOPOLOGY in ${TOPOLOGIES};
172 python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
173 if [ $? -eq 0 ]; then
174 WORKING_TOPOLOGY=${TOPOLOGY}
175 echo "Reserved: ${WORKING_TOPOLOGY}"
180 if [ ! -z "${WORKING_TOPOLOGY}" ]; then
181 # Exit the infinite while loop if we made a reservation
185 # Wait ~3minutes before next try
186 SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
187 echo "Sleeping ${SLEEP_TIME}"
191 function cancel_all {
192 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py -c -d ${INSTALLATION_DIR} -t $1
193 python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
196 # On script exit we cancel the reservation and installation and delete all vpp
198 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
200 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py\
201 -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -i ${DOCKER_IMAGE}
202 if [ $? -eq 0 ]; then
203 echo "Docker image copied and loaded on hosts from: ${WORKING_TOPOLOGY}"
205 echo "Failed to copy and load Docker image to DUTs"
210 # run specific performance tests based on jenkins job type variable
212 pybot ${PYBOT_ARGS} \
213 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
215 -s "tests.kubernetes.perf" \
216 --include ndrdiscANDnic_intel-x520-da2AND1t1cORndrdiscANDnic_intel-x520-da2AND2t2c \
218 RETURN_STATUS=$(echo $?)
220 PERFTEST_SEMI_WEEKLY )
221 pybot ${PYBOT_ARGS} \
222 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
224 -s "tests.kubernetes.perf" \
225 --include ndrdiscANDnic_intel-x710AND1t1cORndrdiscANDnic_intel-x710AND2t2cORndrdiscANDnic_intel-xl710AND1t1cORndrdiscANDnic_intel-xl710AND2t2c \
227 RETURN_STATUS=$(echo $?)
229 VERIFY-PERF-NDRDISC )
230 pybot ${PYBOT_ARGS} \
231 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
233 -s "tests.kubernetes.perf" \
234 --include ndrdiscAND1t1cORndrdiscAND2t2c \
236 RETURN_STATUS=$(echo $?)
238 VERIFY-PERF-PDRDISC )
239 pybot ${PYBOT_ARGS} \
240 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
242 -s "tests.kubernetes.perf" \
243 --include pdrdiscAND1t1cORpdrdiscAND2t2c \
245 RETURN_STATUS=$(echo $?)
248 pybot ${PYBOT_ARGS} \
249 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
251 -s "tests.kubernetes.perf" \
252 --include ndrchkAND1t1cORndrchkAND2t2c \
254 RETURN_STATUS=$(echo $?)
256 PERFTEST_NDRCHK_DAILY )
257 pybot ${PYBOT_ARGS} \
258 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
260 -s "tests.kubernetes.perf" \
261 --include ndrchkAND1t1cORndrchkAND2t2c \
263 RETURN_STATUS=$(echo $?)
266 pybot ${PYBOT_ARGS} \
267 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
269 -s "tests.kubernetes.perf" \
270 --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip4baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
272 RETURN_STATUS=$(echo $?)
275 pybot ${PYBOT_ARGS} \
276 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
278 -s "tests.kubernetes.perf" \
279 --include ndrdiscANDnic_intel-x520-da2AND1t1cANDip6baseORndrdiscANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
281 RETURN_STATUS=$(echo $?)
284 pybot ${PYBOT_ARGS} \
285 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
287 -s "tests.kubernetes.perf" \
288 --include ndrdiscANDnic_intel-x520-da2AND1t1cANDl2xcbaseORndrdiscANDnic_intel-x520-da2AND1t1cANDl2bdbase \
290 RETURN_STATUS=$(echo $?)
293 pybot ${PYBOT_ARGS} \
294 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
296 -s "tests.kubernetes.perf" \
297 --include ndrdiscANDnic_intel-x520-da2AND1t1cANDlisp \
299 RETURN_STATUS=$(echo $?)
302 pybot ${PYBOT_ARGS} \
303 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
305 -s "tests.kubernetes.perf" \
306 --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvxlan \
308 RETURN_STATUS=$(echo $?)
311 pybot ${PYBOT_ARGS} \
312 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
314 -s "tests.kubernetes.perf" \
315 --include ndrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
317 RETURN_STATUS=$(echo $?)
319 VPP-VERIFY-PERF-IP4 )
320 pybot ${PYBOT_ARGS} \
321 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
323 -s "tests.kubernetes.perf" \
324 --include pdrchkANDnic_intel-x520-da2AND1t1cANDip4baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m \
326 RETURN_STATUS=$(echo $?)
328 VPP-VERIFY-PERF-IP6 )
329 pybot ${PYBOT_ARGS} \
330 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
332 -s "tests.kubernetes.perf" \
333 --include pdrchkANDnic_intel-x520-da2AND1t1cANDip6baseORpdrchkANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m \
335 RETURN_STATUS=$(echo $?)
338 pybot ${PYBOT_ARGS} \
339 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
341 -s "tests.kubernetes.perf" \
342 --include pdrchkANDnic_intel-x520-da2AND1t1cANDl2xcbaseORpdrchkANDnic_intel-x520-da2AND1t1cANDl2bdbase \
344 RETURN_STATUS=$(echo $?)
346 VPP-VERIFY-PERF-LISP )
347 pybot ${PYBOT_ARGS} \
348 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
350 -s "tests.kubernetes.perf" \
351 --include pdrchkANDnic_intel-x520-da2AND1t1cANDlisp \
353 RETURN_STATUS=$(echo $?)
355 VPP-VERIFY-PERF-VXLAN )
356 pybot ${PYBOT_ARGS} \
357 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
359 -s "tests.kubernetes.perf" \
360 --include pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan \
362 RETURN_STATUS=$(echo $?)
364 VPP-VERIFY-PERF-VHOST )
365 pybot ${PYBOT_ARGS} \
366 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
368 -s "tests.kubernetes.perf" \
369 --include pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost \
371 RETURN_STATUS=$(echo $?)
373 VPP-VERIFY-PERF-ACL )
374 pybot ${PYBOT_ARGS} \
375 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
377 -s "tests.kubernetes.perf" \
378 --include pdrdiscANDnic_intel-x520-da2AND1t1cANDacl \
379 --include pdrdiscANDnic_intel-x520-da2AND2t2cANDacl \
381 RETURN_STATUS=$(echo $?)
384 pybot ${PYBOT_ARGS} \
385 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
387 -s "tests.kubernetes.perf" \
388 --exclude SKIP_PATCH \
391 RETURN_STATUS=$(echo $?)
394 pybot ${PYBOT_ARGS} \
395 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
397 -s "tests.kubernetes.perf" \
400 RETURN_STATUS=$(echo $?)
403 #run all available tests
404 pybot ${PYBOT_ARGS} \
405 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
407 -s "tests.kubernetes.perf" \
409 RETURN_STATUS=$(echo $?)
412 # run full performance test suite and exit on fail
413 pybot ${PYBOT_ARGS} \
414 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
416 -s "tests.kubernetes.perf" \
418 RETURN_STATUS=$(echo $?)
421 # Pybot output post-processing
422 echo Post-processing test data...
424 python ${SCRIPT_DIR}/resources/tools/scripts/robot_output_parser.py \
425 -i ${SCRIPT_DIR}/output.xml \
426 -o ${SCRIPT_DIR}/output_perf_data.xml \
428 if [ ! $? -eq 0 ]; then
429 echo "Parsing ${SCRIPT_DIR}/output.xml failed"
434 for i in ${ARCHIVE_ARTIFACTS[@]}; do
435 cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
438 echo Post-processing finished.
440 exit ${RETURN_STATUS}