e08a9234851d23e92a2c83177223d8b6703bf672
[csit.git] / bootstrap-verify-perf.sh
1 #!/bin/bash
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:
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 -x
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 PYBOT_ARGS="-W 150"
29
30 ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)
31
32 # If we run this script from CSIT jobs we want to use stable vpp version
33 if [[ ${JOB_NAME} == csit-* ]] ;
34 then
35     mkdir vpp_download
36     cd vpp_download
37
38     if [[ ${TEST_TAG} == "PERFTEST_NIGHTLY" ]] ;
39     then
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
43
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' )"
47     else
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)
51         VPP_CLASSIFIER="-deb"
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' ' ' )"
61     fi
62
63     cd ..
64
65 # If we run this script from vpp project we want to use local build
66 elif [[ ${JOB_NAME} == vpp-* ]] ;
67 then
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)
76     VPP_CLASSIFIER="-deb"
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 ))
81 else
82     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
83     exit 1
84 fi
85
86 WORKING_TOPOLOGY=""
87 export PYTHONPATH=${SCRIPT_DIR}
88
89 sudo apt-get -y update
90 sudo apt-get -y install libpython2.7-dev python-virtualenv
91
92 virtualenv --system-site-packages env
93 . env/bin/activate
94
95 echo pip install
96 pip install -r requirements.txt
97
98 # We iterate over available topologies and wait until we reserve topology
99 while :; do
100     for TOPOLOGY in ${TOPOLOGIES};
101     do
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}"
106             break
107         fi
108     done
109
110     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
111         # Exit the infinite while loop if we made a reservation
112         break
113     fi
114
115     # Wait ~3minutes before next try
116     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
117     echo "Sleeping ${SLEEP_TIME}"
118     sleep ${SLEEP_TIME}
119 done
120
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
124 }
125
126 # On script exit we cancel the reservation and installation and delete all vpp
127 # packages
128 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
129
130 python ${SCRIPT_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
131                                                        -d ${INSTALLATION_DIR} \
132                                                        -p ${VPP_DEBS}
133 if [ $? -eq 0 ]; then
134     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
135 else
136     echo "Failed to copy vpp deb files to DUTs"
137     exit 1
138 fi
139
140 case "$TEST_TAG" in
141     # run specific performance tests based on jenkins job type variable
142     PERFTEST_LONG )
143         pybot ${PYBOT_ARGS} \
144               -L TRACE \
145               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
146               -s "tests.perf" \
147               --exclude SKIP_PATCH \
148               -i NDRPDRDISC \
149               tests/
150         RETURN_STATUS=$(echo $?)
151         ;;
152     PERFTEST_SHORT )
153         pybot ${PYBOT_ARGS} \
154               -L TRACE \
155               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
156               -s "tests.perf" \
157               -i NDRCHK \
158               tests/
159         RETURN_STATUS=$(echo $?)
160         ;;
161    PERFTEST_NIGHTLY )
162         #run all available tests
163         pybot ${PYBOT_ARGS} \
164               -L TRACE \
165               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
166               -s "tests.perf" \
167               tests/
168         RETURN_STATUS=$(echo $?)
169         ;;
170     * )
171         # run full performance test suite and exit on fail
172         pybot ${PYBOT_ARGS} \
173               -L TRACE \
174               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
175               -s "tests.perf" \
176               tests/
177         RETURN_STATUS=$(echo $?)
178 esac
179
180 # Pybot output post-processing
181 echo Post-processing test data...
182
183 python ${SCRIPT_DIR}/resources/tools/robot_output_parser.py \
184        -i ${SCRIPT_DIR}/output.xml \
185        -o ${SCRIPT_DIR}/output_perf_data.xml \
186        -v ${VPP_STABLE_VER}
187 if [ ! $? -eq 0 ]; then
188     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
189 fi
190
191 # Archive artifacts
192 mkdir archive
193 for i in ${ARCHIVE_ARTIFACTS[@]}; do
194     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
195 done
196
197 echo Post-processing finished.
198
199 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.