2 # Copyright (c) 2016 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"
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-* ]] ;
38 if [[ ${TEST_TAG} == "PERFTEST_NIGHTLY" ]] ;
40 # Download the latest VPP build .deb install packages
41 echo Downloading VPP packages...
42 bash ${SCRIPT_DIR}/resources/tools/download_install_vpp_pkgs.sh --skip-install
44 VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
45 # Take vpp package and get the vpp version
46 VPP_STABLE_VER="$( expr match $(ls *.deb | head -n 1) 'vpp-\(.*\)-deb.deb' )"
48 DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)
49 VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL)
50 VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER)
52 # Download vpp build from nexus and set VPP_DEBS variable
53 wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
54 wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
55 wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
56 wget -q "${VPP_REPO_URL}/vpp-dpdk-dev/${DPDK_STABLE_VER}/vpp-dpdk-dev-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
57 wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
58 wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
59 wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
60 VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
65 # If we run this script from vpp project we want to use local build
66 elif [[ ${JOB_NAME} == vpp-* ]] ;
68 # Use local packages provided as argument list
69 # Jenkins VPP deb paths (convert to full path)
70 VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
71 # Take vpp package and get the vpp version
72 VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )"
73 # DPDK is not part of the vpp build
74 DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)
75 VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL)
77 wget -q "${VPP_REPO_URL}/vpp-dpdk-dev/${DPDK_STABLE_VER}/vpp-dpdk-dev-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
78 wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
79 VPP_DEBS+=($( readlink -f vpp-dpdk-dev-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb ))
80 VPP_DEBS+=($( readlink -f vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb ))
82 echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
87 export PYTHONPATH=${SCRIPT_DIR}
89 sudo apt-get -y update
90 sudo apt-get -y install libpython2.7-dev python-virtualenv
92 virtualenv --system-site-packages env
96 pip install -r requirements.txt
98 # We iterate over available topologies and wait until we reserve topology
100 for TOPOLOGY in ${TOPOLOGIES};
102 python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
103 if [ $? -eq 0 ]; then
104 WORKING_TOPOLOGY=${TOPOLOGY}
105 echo "Reserved: ${WORKING_TOPOLOGY}"
110 if [ ! -z "${WORKING_TOPOLOGY}" ]; then
111 # Exit the infinite while loop if we made a reservation
115 # Wait ~3minutes before next try
116 SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
117 echo "Sleeping ${SLEEP_TIME}"
121 function cancel_all {
122 python ${SCRIPT_DIR}/resources/tools/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
123 python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -c -t $1
126 # On script exit we cancel the reservation and installation and delete all vpp
128 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
130 python ${SCRIPT_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
131 -d ${INSTALLATION_DIR} \
133 if [ $? -eq 0 ]; then
134 echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
136 echo "Failed to copy vpp deb files to DUTs"
141 # run specific performance tests based on jenkins job type variable
143 pybot ${PYBOT_ARGS} \
145 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
147 --exclude SKIP_PATCH \
150 RETURN_STATUS=$(echo $?)
153 pybot ${PYBOT_ARGS} \
155 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
159 RETURN_STATUS=$(echo $?)
162 #run all available tests
163 pybot ${PYBOT_ARGS} \
165 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
168 RETURN_STATUS=$(echo $?)
171 # run full performance test suite and exit on fail
172 pybot ${PYBOT_ARGS} \
174 -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
177 RETURN_STATUS=$(echo $?)
180 # Pybot output post-processing
181 echo Post-processing test data...
183 python ${SCRIPT_DIR}/resources/tools/robot_output_parser.py \
184 -i ${SCRIPT_DIR}/output.xml \
185 -o ${SCRIPT_DIR}/output_perf_data.xml \
187 if [ ! $? -eq 0 ]; then
188 echo "Parsing ${SCRIPT_DIR}/output.xml failed"
193 for i in ${ARCHIVE_ARTIFACTS[@]}; do
194 cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
197 echo Post-processing finished.
199 exit ${RETURN_STATUS}