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-* ]] ;
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 vpp*.deb | tr '\n' ' ' )"
62 # If we run this script from vpp project we want to use local build
63 elif [[ ${JOB_NAME} == vpp-* ]] ;
65 # Use local packages provided as argument list
66 # Jenkins VPP deb paths (convert to full path)
67 VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
69 echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
73 # Extract VPP API to specific folder
74 dpkg -x vpp_download/vpp_*.deb /tmp/vpp
76 LIGATO_REPO_URL='https://github.com/ligato/'
77 VPP_AGENT_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_AGENT_STABLE_VER)
78 DOCKER_DEB="docker-ce_18.03.0~ce-0~ubuntu_amd64.deb"
80 # Clone & checkout stable vnf-agent
81 cd .. && git clone -b ${VPP_AGENT_STABLE_VER} --single-branch \
82 ${LIGATO_REPO_URL}/vpp-agent vpp-agent
83 # If the git clone fails, complain clearly and exit
85 echo "Failed to run: git clone ${LIGATO_REPO_URL}/vpp-agent"
91 wget -q https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/${DOCKER_DEB}
92 sudo dpkg -i ${DOCKER_DEB}
93 # If installation fails, complain clearly and exit
95 echo "Failed to install Docker"
99 # Pull ligato/dev_vpp_agent docker image and re-tag as local
100 sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}
101 sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}\
104 # Start dev_vpp_agent container as daemon
105 sudo docker run --rm -itd --name agentcnt dev_vpp_agent bash
107 # Copy latest vpp api into running container
108 sudo docker cp /tmp/vpp/usr/share/vpp/api agentcnt:/usr/share/vpp
109 for f in ${SCRIPT_DIR}/vpp_download/*; do
110 sudo docker cp $f agentcnt:/opt/vpp-agent/dev/vpp/build-root/
113 # Recompile vpp-agent
114 sudo docker exec -i agentcnt \
115 script -qec '. ~/.bashrc; cd /go/src/github.com/ligato/vpp-agent && make generate && make install'
117 echo "Failed to build vpp-agent in Docker image."
120 # Save container state
121 sudo docker commit `sudo docker ps -q` dev_vpp_agent:latest
123 # Build prod_vpp_agent docker image
125 sudo docker build --tag prod_vpp_agent --no-cache .
126 # Export Docker image
127 sudo docker save prod_vpp_agent | gzip > prod_vpp_agent.tar.gz
128 # Kill running agentcnt container
129 sudo docker rm -f agentcnt
130 # If image build fails, complain clearly and exit
132 echo "Failed to build vpp-agent Docker image."
135 DOCKER_IMAGE="$( readlink -f prod_vpp_agent.tar.gz | tr '\n' ' ' )"
141 sudo apt-get -y update
142 sudo apt-get -y install libpython2.7-dev python-virtualenv
144 virtualenv --system-site-packages env
148 pip install -r requirements.txt
150 if [ -z "${TOPOLOGIES}" ]; then
151 echo "No applicable topology found!"
154 # We iterate over available topologies and wait until we reserve topology
156 for TOPOLOGY in ${TOPOLOGIES};
158 python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
159 if [ $? -eq 0 ]; then
160 WORKING_TOPOLOGY=${TOPOLOGY}
161 echo "Reserved: ${WORKING_TOPOLOGY}"
166 if [ ! -z "${WORKING_TOPOLOGY}" ]; then
167 # Exit the infinite while loop if we made a reservation
171 # Wait ~3minutes before next try
172 SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
173 echo "Sleeping ${SLEEP_TIME}"
177 function cancel_all {
178 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py -c -d ${INSTALLATION_DIR} -t $1
179 python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
182 # On script exit we cancel the reservation and installation and delete all vpp
184 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
186 python ${SCRIPT_DIR}/resources/tools/scripts/topo_container_copy.py \
187 -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -i ${DOCKER_IMAGE}
188 if [ $? -eq 0 ]; then
189 echo "Docker image copied and loaded on hosts from: ${WORKING_TOPOLOGY}"
191 echo "Failed to copy and load Docker image to DUTs"
195 # Based on job we will identify DUT
196 if [[ ${JOB_NAME} == *hc2vpp* ]] ;
199 elif [[ ${JOB_NAME} == *vpp* ]] ;
202 elif [[ ${JOB_NAME} == *ligato* ]] ;
205 elif [[ ${JOB_NAME} == *dpdk* ]] ;
209 echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
213 PYBOT_ARGS="--consolewidth 100 --loglevel TRACE --variable TOPOLOGY_PATH:${WORKING_TOPOLOGY} --suite tests.${DUT}.perf"
216 # select specific performance tests based on jenkins job type variable
218 TAGS=('ndrdiscANDnic_intel-x520-da2AND1c'
219 'ndrdiscANDnic_intel-x520-da2AND2c'
220 'ndrdiscAND1cANDipsec'
221 'ndrdiscAND2cANDipsec')
223 PERFTEST_SEMI_WEEKLY )
224 TAGS=('ndrdiscANDnic_intel-x710AND1c'
225 'ndrdiscANDnic_intel-x710AND2c'
226 'ndrdiscANDnic_intel-xl710AND1c'
227 'ndrdiscANDnic_intel-xl710AND2c')
230 TAGS=('mrrAND64bAND1c'
236 'mrrANDimixAND1cANDvhost'
237 'mrrANDimixAND2cANDvhost'
238 'mrrANDimixAND4cANDvhost'
239 'mrrANDimixAND1cANDmemif'
240 'mrrANDimixAND2cANDmemif'
241 'mrrANDimixAND4cANDmemif')
244 if [[ -z "$TEST_TAG_STRING" ]]; then
245 # If nothing is specified, we will run pre-selected tests by
246 # following tags. Items of array will be concatenated by OR in Robot
248 TEST_TAG_ARRAY=('mrrANDnic_intel-x710AND1cAND64bANDip4base'
249 'mrrANDnic_intel-x710AND1cAND78bANDip6base'
250 'mrrANDnic_intel-x710AND1cAND64bANDl2bdbase')
252 # If trigger contains tags, split them into array.
253 TEST_TAG_ARRAY=(${TEST_TAG_STRING//:/ })
258 for TAG in "${TEST_TAG_ARRAY[@]}"; do
259 if [[ ${TAG} == "!"* ]]; then
260 # Exclude tags are not prefixed.
263 # We will prefix with perftest to prevent running other tests
266 if [[ ${JOB_NAME} == vpp-* ]] ; then
267 # Automatic prefixing for VPP jobs to limit the NIC used and
268 # traffic evaluation to MRR.
269 prefix="${prefix}mrrANDnic_intel-x710AND"
271 TAGS+=("$prefix${TAG}")
279 # Catenate TAG selections
281 for TAG in "${TAGS[@]}"; do
282 if [[ ${TAG} == "!"* ]]; then
283 EXPANDED_TAGS+=(" --exclude ${TAG#$"!"} ")
285 EXPANDED_TAGS+=(" --include ${TAG} ")
290 pybot ${PYBOT_ARGS}${EXPANDED_TAGS[@]} tests/
291 RETURN_STATUS=$(echo $?)
293 # Archive JOB artifacts in jenkins
294 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
295 cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
297 # Archive JOB artifacts to logs.fd.io
298 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
299 cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
302 exit ${RETURN_STATUS}