start-testcase-DMM file addition
[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 JOB_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
29 LOG_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
30 JOB_ARCHIVE_DIR="archive"
31 LOG_ARCHIVE_DIR="$WORKSPACE/archives"
32 mkdir -p ${JOB_ARCHIVE_DIR}
33 mkdir -p ${LOG_ARCHIVE_DIR}
34
35 # If we run this script from CSIT jobs we want to use stable vpp version
36 if [[ ${JOB_NAME} == csit-* ]] ;
37 then
38     mkdir -p vpp/build-root
39     cd vpp/build-root
40
41     if [[ ${TEST_TAG} == *DAILY ]] || \
42        [[ ${TEST_TAG} == *WEEKLY ]];
43     then
44         # Download the latest VPP build .deb install packages
45         echo Downloading VPP packages...
46         bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh --skip-install
47
48         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
49         # Take vpp package and get the vpp version
50         VPP_STABLE_VER="$( expr match $(ls *.deb | head -n 1) 'vpp-\(.*\)-deb.deb' )"
51     else
52         DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)_amd64
53         VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL_UBUNTU)
54         VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU)
55         VPP_CLASSIFIER="-deb"
56         # Download vpp build from nexus and set VPP_DEBS variable
57         wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
58         wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
59         wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
60         # Temporary disable using dpdk
61         # wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
62         wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
63         wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
64         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
65     fi
66
67     # Temporary workaround as ligato docker file requires specific file name
68     rename -v 's/^(.*)-(\d.*)-deb.deb/$1_$2.deb/' *.deb
69     cd ${SCRIPT_DIR}
70
71 # If we run this script from vpp project we want to use local build
72 elif [[ ${JOB_NAME} == vpp-* ]] ;
73 then
74     mkdir -p vpp/build-root
75     # Use local packages provided as argument list
76     # Jenkins VPP deb paths (convert to full path)
77     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
78     # Take vpp package and get the vpp version
79     VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )"
80     # Move files to build-root for packing
81     for deb in ${VPP_DEBS}; do mv ${deb} vpp/build-root/; done
82 else
83     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
84     exit 1
85 fi
86
87 # Extract VPP API to specific folder
88 dpkg -x vpp/build-root/vpp_${VPP_STABLE_VER}.deb /tmp/vpp
89 # Compress all VPP debs and remove temporary directory
90 tar -zcvf ${SCRIPT_DIR}/vpp.tar.gz vpp/* && rm -R vpp
91
92 LIGATO_REPO_URL=$(cat ${SCRIPT_DIR}/LIGATO_REPO_URL)
93 VPP_AGENT_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_AGENT_STABLE_VER)
94 DOCKER_DEB="docker-ce_18.03.0~ce-0~ubuntu_amd64.deb"
95
96 # Clone & checkout stable vnf-agent
97 cd .. && git clone ${LIGATO_REPO_URL}/vpp-agent
98 # If the git clone fails, complain clearly and exit
99 if [ $? != 0 ]; then
100     echo "Failed to run: git clone --depth 1 ${LIGATO_REPO_URL}/vpp-agent"
101     exit 1
102 fi
103 cd vpp-agent && git checkout ${VPP_AGENT_STABLE_VER}
104 # If the git checkout fails, complain clearly and exit
105 if [ $? != 0 ]; then
106     echo "Failed to run: git checkout ${VPP_AGENT_STABLE_VER}"
107     exit 1
108 fi
109
110 # Install Docker
111 wget -q https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/${DOCKER_DEB}
112 sudo dpkg -i ${DOCKER_DEB}
113 # If installation fails, complain clearly and exit
114 if [ $? != 0 ]; then
115     echo "Failed to install Docker"
116     exit 1
117 fi
118
119 # Pull ligato/dev_vpp_agent docker image and re-tag as local
120 sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}
121 sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}\
122     dev_vpp_agent:latest
123
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 -qec '. ~/.bashrc; cd /root/go/src/github.com/ligato/vpp-agent && make generate && make install'
131 if [ $? != 0 ]; then
132     echo "Failed to build vpp-agent in Docker image."
133     exit 1
134 fi
135 # Extract vpp-agent
136 rm -rf agent
137 mkdir -p agent
138 sudo docker cp agentcnt:/root/go/bin/vpp-agent agent/
139 sudo docker cp agentcnt:/root/go/bin/vpp-agent-ctl agent/
140 sudo docker cp agentcnt:/root/go/bin/agentctl agent/
141 tar -zcvf ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/agent.tar.gz agent
142 # Kill running container
143 sudo docker rm -f agentcnt
144
145 # Build prod_vpp_agent docker image
146 cd ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/ &&\
147     mv ${SCRIPT_DIR}/vpp.tar.gz . &&\
148     sudo docker build -t prod_vpp_agent --no-cache .
149 # Export Docker image
150 sudo docker save prod_vpp_agent | gzip > prod_vpp_agent.tar.gz
151 # If image build fails, complain clearly and exit
152 if [ $? != 0 ]; then
153     echo "Failed to build vpp-agent Docker image."
154     exit 1
155 fi
156 DOCKER_IMAGE="$( readlink -f prod_vpp_agent.tar.gz | tr '\n' ' ' )"
157
158 cd ${SCRIPT_DIR}
159
160 WORKING_TOPOLOGY=""
161 export PYTHONPATH=${SCRIPT_DIR}
162
163 sudo apt-get -y update
164 sudo apt-get -y install libpython2.7-dev python-virtualenv
165
166 virtualenv --system-site-packages env
167 . env/bin/activate
168
169 echo pip install
170 pip install -r requirements.txt
171
172 # We iterate over available topologies and wait until we reserve topology
173 while :; do
174     for TOPOLOGY in ${TOPOLOGIES};
175     do
176         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
177         if [ $? -eq 0 ]; then
178             WORKING_TOPOLOGY=${TOPOLOGY}
179             echo "Reserved: ${WORKING_TOPOLOGY}"
180             break
181         fi
182     done
183
184     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
185         # Exit the infinite while loop if we made a reservation
186         break
187     fi
188
189     # Wait ~3minutes before next try
190     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
191     echo "Sleeping ${SLEEP_TIME}"
192     sleep ${SLEEP_TIME}
193 done
194
195 function cancel_all {
196     python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py -c -d ${INSTALLATION_DIR} -t $1
197     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
198 }
199
200 # On script exit we cancel the reservation and installation and delete all vpp
201 # packages
202 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
203
204 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py \
205     -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -i ${DOCKER_IMAGE}
206 if [ $? -eq 0 ]; then
207     echo "Docker image copied and loaded on hosts from: ${WORKING_TOPOLOGY}"
208 else
209     echo "Failed to copy and load Docker image to DUTs"
210     exit 1
211 fi
212
213 # Based on job we will identify DUT
214 if [[ ${JOB_NAME} == *hc2vpp* ]] ;
215 then
216     DUT="hc2vpp"
217 elif [[ ${JOB_NAME} == *vpp* ]] ;
218 then
219     DUT="vpp"
220 elif [[ ${JOB_NAME} == *ligato* ]] ;
221 then
222     DUT="kubernetes"
223 elif [[ ${JOB_NAME} == *dpdk* ]] ;
224 then
225     DUT="dpdk"
226 else
227     echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
228     exit 1
229 fi
230
231 PYBOT_ARGS="--consolewidth 120 --loglevel TRACE --variable TOPOLOGY_PATH:${WORKING_TOPOLOGY} --suite tests.${DUT}.perf"
232
233 case "$TEST_TAG" in
234     # select specific performance tests based on jenkins job type variable
235     PERFTEST_DAILY )
236         TAGS=('ndrdiscANDnic_intel-x520-da2AND1t1c'
237               'ndrdiscANDnic_intel-x520-da2AND2t2c'
238               'ndrdiscAND1t1cANDipsec'
239               'ndrdiscAND2t2cANDipsec')
240         ;;
241     PERFTEST_SEMI_WEEKLY )
242         TAGS=('ndrdiscANDnic_intel-x710AND1t1c'
243               'ndrdiscANDnic_intel-x710AND2t2c'
244               'ndrdiscANDnic_intel-xl710AND1t1c'
245               'ndrdiscANDnic_intel-xl710AND2t2c')
246         ;;
247     PERFTEST_MRR_DAILY )
248        TAGS=('mrrAND64bAND1t1c'
249              'mrrAND64bAND2t2c'
250              'mrrAND64bAND4t4c'
251              'mrrAND78bAND1t1c'
252              'mrrAND78bAND2t2c'
253              'mrrAND78bAND4t4c'
254              'mrrANDimixAND1t1cANDvhost'
255              'mrrANDimixAND2t2cANDvhost'
256              'mrrANDimixAND4t4cANDvhost'
257              'mrrANDimixAND1t1cANDmemif'
258              'mrrANDimixAND2t2cANDmemif'
259              'mrrANDimixAND4t4cANDmemif')
260         ;;
261     VERIFY-PERF-NDRDISC )
262         TAGS=('ndrdiscAND1t1c'
263               'ndrdiscAND2t2c')
264         ;;
265     VERIFY-PERF-PDRDISC )
266         TAGS=('pdrdiscAND1t1c'
267               'pdrdiscAND2t2c')
268         ;;
269     VERIFY-PERF-MRR )
270         TAGS=('mrrAND1t1c'
271               'mrrAND2t2c')
272         ;;
273     VERIFY-PERF-IP4 )
274         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip4base'
275               'mrrANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m')
276         ;;
277     VERIFY-PERF-IP6 )
278         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip6base'
279               'mrrANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m')
280         ;;
281     VERIFY-PERF-L2 )
282         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDl2xcbase'
283               'mrrANDnic_intel-x520-da2AND1t1cANDl2bdbase')
284         ;;
285     VERIFY-PERF-LISP )
286         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDlisp')
287         ;;
288     VERIFY-PERF-VXLAN )
289         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan')
290         ;;
291     VERIFY-PERF-VHOST )
292         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost')
293         ;;
294     VERIFY-PERF-MEMIF )
295         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif'
296               'pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif'
297               'mrrANDnic_intel-x520-da2AND1t1cANDmemif'
298               'mrrANDnic_intel-x520-da2AND2t2cANDmemif')
299         ;;
300     VERIFY-PERF-IPSECHW )
301         TAGS=('pdrdiscANDnic_intel-xl710AND1t1cANDipsechw'
302               'pdrdiscANDnic_intel-xl710AND2t2cANDipsechw'
303               'mrrANDnic_intel-xl710AND1t1cANDipsechw'
304               'mrrANDnic_intel-xl710AND2t2cANDipsechw')
305         ;;
306     VPP-VERIFY-PERF-IP4 )
307         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip4base'
308               'mrrANDnic_intel-x520-da2AND1t1cANDip4fwdANDfib_2m')
309         ;;
310     VPP-VERIFY-PERF-IP6 )
311         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDip6base'
312               'mrrANDnic_intel-x520-da2AND1t1cANDip6fwdANDfib_2m')
313         ;;
314     VPP-VERIFY-PERF-L2 )
315         TAGS=('mrrANDnic_intel-x520-da2AND1t1cANDl2xcbase'
316               'mrrANDnic_intel-x520-da2AND1t1cANDl2bdbase')
317         ;;
318     VPP-VERIFY-PERF-LISP )
319         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDlisp')
320         ;;
321     VPP-VERIFY-PERF-VXLAN )
322         TAGS=('pdrchkANDnic_intel-x520-da2AND1t1cANDvxlan')
323         ;;
324     VPP-VERIFY-PERF-VHOST )
325         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDvhost')
326         ;;
327     VPP-VERIFY-PERF-MEMIF )
328         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDmemif'
329               'pdrdiscANDnic_intel-x520-da2AND2t2cANDmemif'
330               'mrrANDnic_intel-x520-da2AND1t1cANDmemif'
331               'mrrANDnic_intel-x520-da2AND2t2cANDmemif')
332         ;;
333     VPP-VERIFY-PERF-ACL )
334         TAGS=('pdrdiscANDnic_intel-x520-da2AND1t1cANDacl'
335               'pdrdiscANDnic_intel-x520-da2AND2t2cANDacl')
336         ;;
337     VPP-VERIFY-PERF-IPSECHW )
338         TAGS=('pdrdiscANDnic_intel-xl710AND1t1cANDipsechw'
339               'pdrdiscANDnic_intel-xl710AND2t2cANDipsechw'
340               'mrrANDnic_intel-xl710AND1t1cANDipsechw'
341               'mrrANDnic_intel-xl710AND2t2cANDipsechw')
342         ;;
343     * )
344         TAGS=('perftest')
345 esac
346
347 # Catenate TAG selections by 'OR'
348 printf -v INCLUDES " --include %s " "${TAGS[@]}"
349
350 # Execute the test
351 pybot ${PYBOT_ARGS}${INCLUDES} tests/
352 RETURN_STATUS=$(echo $?)
353
354 # Archive JOB artifacts in jenkins
355 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
356     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
357 done
358 # Archive JOB artifacts to logs.fd.io
359 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
360     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
361 done
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.