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:
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_3n_hsw_testbed1.yaml \
19 topologies/available/lf_3n_hsw_testbed2.yaml \
20 topologies/available/lf_3n_hsw_testbed3.yaml"
22 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23 export PYTHONPATH=${SCRIPT_DIR}
24 export DEBIAN_FRONTEND=noninteractive
27 RESERVATION_DIR="/tmp/reservation_dir"
28 INSTALLATION_DIR="/tmp/install_dir"
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}
37 # If we run this script from CSIT jobs we want to use stable vpp version
38 if [[ ${JOB_NAME} == csit-* ]] ;
40 mkdir -p vpp/build-root
43 if [[ ${TEST_TAG} == *DAILY ]] || \
44 [[ ${TEST_TAG} == *WEEKLY ]];
46 echo Downloading latest VPP packages from NEXUS...
47 bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh \
50 echo Downloading VPP packages of specific version from NEXUS...
51 DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)
52 VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU)
53 #Temporary if arch will not be removed from VPP_STABLE_VER_UBUNTU
54 #VPP_STABLE_VER=${VPP_STABLE_VER%_amd64}
55 bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh \
56 --skip-install --vpp ${VPP_STABLE_VER} --dkms ${DPDK_STABLE_VER}
58 # Jenkins VPP deb paths (convert to full path)
59 VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
60 # Take vpp package and get the vpp version
61 VPP_STABLE_VER="$( expr match $(ls *.deb | head -n 1) 'vpp_\(.*\)_amd64.deb' )"
65 # If we run this script from vpp project we want to use local build
66 elif [[ ${JOB_NAME} == vpp-* ]] ;
68 mkdir -p vpp/build-root
69 # Use local packages provided as argument list
70 # Jenkins VPP deb paths (convert to full path)
71 VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
72 # Take vpp package and get the vpp version
73 VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )"
74 # Move files to build-root for packing
75 for deb in ${VPP_DEBS}; do mv ${deb} vpp/build-root/; done
77 echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
81 # Extract VPP API to specific folder
82 dpkg -x vpp/build-root/vpp_${VPP_STABLE_VER}.deb /tmp/vpp
83 # Compress all VPP debs and remove temporary directory
84 tar -zcvf ${SCRIPT_DIR}/vpp.tar.gz vpp/* && rm -R vpp
86 LIGATO_REPO_URL=$(cat ${SCRIPT_DIR}/LIGATO_REPO_URL)
87 VPP_AGENT_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_AGENT_STABLE_VER)
88 DOCKER_DEB="docker-ce_18.03.0~ce-0~ubuntu_amd64.deb"
90 # Clone & checkout stable vnf-agent
91 cd .. && git clone ${LIGATO_REPO_URL}/vpp-agent
92 # If the git clone fails, complain clearly and exit
94 echo "Failed to run: git clone --depth 1 ${LIGATO_REPO_URL}/vpp-agent"
97 cd vpp-agent && git checkout ${VPP_AGENT_STABLE_VER}
98 # If the git checkout fails, complain clearly and exit
100 echo "Failed to run: git checkout ${VPP_AGENT_STABLE_VER}"
105 wget -q https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/${DOCKER_DEB}
106 sudo dpkg -i ${DOCKER_DEB}
107 # If installation fails, complain clearly and exit
109 echo "Failed to install Docker"
113 # Pull ligato/dev_vpp_agent docker image and re-tag as local
114 sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}
115 sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}\
118 # Start dev_vpp_agent container as daemon
119 sudo docker run --rm -itd --name agentcnt dev_vpp_agent bash
120 # Copy latest vpp api into running container
121 sudo docker cp /tmp/vpp/usr/share/vpp/api agentcnt:/usr/share/vpp
122 # Recompile vpp-agent
123 sudo docker exec -i agentcnt \
124 script -qec '. ~/.bashrc; cd /root/go/src/github.com/ligato/vpp-agent && make generate && make install'
126 echo "Failed to build vpp-agent in Docker image."
132 sudo docker cp agentcnt:/root/go/bin/vpp-agent agent/
133 sudo docker cp agentcnt:/root/go/bin/vpp-agent-ctl agent/
134 sudo docker cp agentcnt:/root/go/bin/agentctl agent/
135 tar -zcvf ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/agent.tar.gz agent
136 # Kill running container
137 sudo docker rm -f agentcnt
139 # Build prod_vpp_agent docker image
140 cd ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/ &&\
141 mv ${SCRIPT_DIR}/vpp.tar.gz . &&\
142 sudo docker build -t prod_vpp_agent --no-cache .
143 # Export Docker image
144 sudo docker save prod_vpp_agent | gzip > prod_vpp_agent.tar.gz
145 # If image build fails, complain clearly and exit
147 echo "Failed to build vpp-agent Docker image."
150 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
159 virtualenv --system-site-packages env
163 pip install -r requirements.txt
165 # We iterate over available topologies and wait until we reserve topology
167 for TOPOLOGY in ${TOPOLOGIES};
169 python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
170 if [ $? -eq 0 ]; then
171 WORKING_TOPOLOGY=${TOPOLOGY}
172 echo "Reserved: ${WORKING_TOPOLOGY}"
177 if [ ! -z "${WORKING_TOPOLOGY}" ]; then
178 # Exit the infinite while loop if we made a reservation
182 # Wait ~3minutes before next try
183 SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
184 echo "Sleeping ${SLEEP_TIME}"
188 function cancel_all {
189 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py -c -d ${INSTALLATION_DIR} -t $1
190 python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
193 # On script exit we cancel the reservation and installation and delete all vpp
195 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
197 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py \
198 -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -i ${DOCKER_IMAGE}
199 if [ $? -eq 0 ]; then
200 echo "Docker image copied and loaded on hosts from: ${WORKING_TOPOLOGY}"
202 echo "Failed to copy and load Docker image to DUTs"
206 # Based on job we will identify DUT
207 if [[ ${JOB_NAME} == *hc2vpp* ]] ;
210 elif [[ ${JOB_NAME} == *vpp* ]] ;
213 elif [[ ${JOB_NAME} == *ligato* ]] ;
216 elif [[ ${JOB_NAME} == *dpdk* ]] ;
220 echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
224 PYBOT_ARGS="--consolewidth 100 --loglevel TRACE --variable TOPOLOGY_PATH:${WORKING_TOPOLOGY} --suite tests.${DUT}.perf"
227 # select specific performance tests based on jenkins job type variable
229 TAGS=('ndrdiscANDnic_intel-x520-da2AND1c'
230 'ndrdiscANDnic_intel-x520-da2AND2c'
231 'ndrdiscAND1cANDipsec'
232 'ndrdiscAND2cANDipsec')
234 PERFTEST_SEMI_WEEKLY )
235 TAGS=('ndrdiscANDnic_intel-x710AND1c'
236 'ndrdiscANDnic_intel-x710AND2c'
237 'ndrdiscANDnic_intel-xl710AND1c'
238 'ndrdiscANDnic_intel-xl710AND2c')
241 TAGS=('mrrAND64bAND1c'
247 'mrrANDimixAND1cANDvhost'
248 'mrrANDimixAND2cANDvhost'
249 'mrrANDimixAND4cANDvhost'
250 'mrrANDimixAND1cANDmemif'
251 'mrrANDimixAND2cANDmemif'
252 'mrrANDimixAND4cANDmemif')
255 if [[ -z "$TEST_TAG_STRING" ]]; then
256 # If nothing is specified, we will run pre-selected tests by
257 # following tags. Items of array will be concatenated by OR in Robot
259 TEST_TAG_ARRAY=('mrrANDnic_intel-x710AND1cAND64bANDip4base'
260 'mrrANDnic_intel-x710AND1cAND78bANDip6base'
261 'mrrANDnic_intel-x710AND1cAND64bANDl2bdbase')
263 # If trigger contains tags, split them into array.
264 TEST_TAG_ARRAY=(${TEST_TAG_STRING//:/ })
269 for TAG in "${TEST_TAG_ARRAY[@]}"; do
270 if [[ ${TAG} == "!"* ]]; then
271 # Exclude tags are not prefixed.
274 # We will prefix with perftest to prevent running other tests
277 if [[ ${JOB_NAME} == vpp-* ]] ; then
278 # Automatic prefixing for VPP jobs to limit the NIC used and
279 # traffic evaluation to MRR.
280 prefix="${prefix}mrrANDnic_intel-x710AND"
282 TAGS+=("$prefix${TAG}")
290 # Catenate TAG selections
292 for TAG in "${TAGS[@]}"; do
293 if [[ ${TAG} == "!"* ]]; then
294 EXPANDED_TAGS+=(" --exclude ${TAG#$"!"} ")
296 EXPANDED_TAGS+=(" --include ${TAG} ")
301 pybot ${PYBOT_ARGS}${EXPANDED_TAGS[@]} tests/
302 RETURN_STATUS=$(echo $?)
304 # Archive JOB artifacts in jenkins
305 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
306 cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
308 # Archive JOB artifacts to logs.fd.io
309 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
310 cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
313 exit ${RETURN_STATUS}