SKIP_PATCH for all PDR tests instead of NDR
[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 VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER)
25 VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL)
26
27 # Reservation dir
28 RESERVATION_DIR="/tmp/reservation_dir"
29 INSTALLATION_DIR="/tmp/install_dir"
30
31 PYBOT_ARGS="-W 150"
32
33 ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)
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 vpp_download
39     cd vpp_download
40
41     if [[ ${TEST_TAG} == "PERFTEST_NIGHTLY" ]] ;
42     then
43         # Download the latest VPP build .deb install packages
44         echo Downloading VPP packages...
45         bash ${SCRIPT_DIR}/resources/tools/download_install_vpp_pkgs.sh --skip-install
46
47         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
48
49     else
50         #download vpp build from nexus and set VPP_DEBS variable
51         wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}.deb" || exit
52         wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}.deb" || exit
53         wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}.deb" || exit
54         wget -q "${VPP_REPO_URL}/vpp-dpdk-dev/${VPP_STABLE_VER}/vpp-dpdk-dev-${VPP_STABLE_VER}.deb" || exit
55         wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${VPP_STABLE_VER}/vpp-dpdk-dkms-${VPP_STABLE_VER}.deb" || exit
56         wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}.deb" || exit
57         wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}.deb" || exit
58         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
59     fi
60
61     cd ..
62
63 # If we run this script from vpp project we want to use local build
64 elif [[ ${JOB_NAME} == vpp-* ]] ;
65 then
66     #use local packages provided as argument list
67     # Jenkins VPP deb paths (convert to full path)
68     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
69 else
70     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
71     exit 1
72 fi
73
74 WORKING_TOPOLOGY=""
75 export PYTHONPATH=${SCRIPT_DIR}
76
77 sudo apt-get -y update
78 sudo apt-get -y install libpython2.7-dev python-virtualenv
79
80 virtualenv --system-site-packages env
81 . env/bin/activate
82
83 echo pip install
84 pip install -r requirements.txt
85
86 # We iterate over available topologies and wait until we reserve topology
87 while :; do
88     for TOPOLOGY in ${TOPOLOGIES};
89     do
90         python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
91         if [ $? -eq 0 ]; then
92             WORKING_TOPOLOGY=${TOPOLOGY}
93             echo "Reserved: ${WORKING_TOPOLOGY}"
94             break
95         fi
96     done
97
98     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
99         # Exit the infinite while loop if we made a reservation
100         break
101     fi
102
103     # Wait ~3minutes before next try
104     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
105     echo "Sleeping ${SLEEP_TIME}"
106     sleep ${SLEEP_TIME}
107 done
108
109 function cancel_all {
110     python ${SCRIPT_DIR}/resources/tools/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
111     python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -c -t $1
112 }
113
114 # On script exit we cancel the reservation and installation and delete all vpp
115 # packages
116 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
117
118 python ${SCRIPT_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
119                                                        -d ${INSTALLATION_DIR} \
120                                                        -p ${VPP_DEBS}
121 if [ $? -eq 0 ]; then
122     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
123 else
124     echo "Failed to copy vpp deb files to DUTs"
125     exit 1
126 fi
127
128 case "$TEST_TAG" in
129     # run specific performance tests based on jenkins job type variable
130     PERFTEST_LONG )
131         pybot ${PYBOT_ARGS} \
132               -L TRACE \
133               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
134               -s "tests.perf" \
135               --exclude SKIP_PATCH \
136               -i perftest_long \
137               tests/
138         RETURN_STATUS=$(echo $?)
139         ;;
140     PERFTEST_SHORT )
141         pybot ${PYBOT_ARGS} \
142               -L TRACE \
143               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
144               -s "tests.perf" \
145               -i perftest_short \
146               tests/
147         RETURN_STATUS=$(echo $?)
148         ;;
149     PERFTEST_LONG_BRIDGE )
150         pybot ${PYBOT_ARGS} \
151               -L TRACE \
152               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
153               -s "tests.perf.Long_Bridge_Domain*" \
154               tests/
155         RETURN_STATUS=$(echo $?)
156         ;;
157     PERFTEST_LONG_IPV4 )
158         pybot ${PYBOT_ARGS} \
159               -L TRACE \
160               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
161               -s "tests.perf.Long_IPv4*" \
162               tests/
163         RETURN_STATUS=$(echo $?)
164         ;;
165     PERFTEST_LONG_IPV6 )
166         pybot ${PYBOT_ARGS} \
167               -L TRACE \
168               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
169               -s "tests.perf.Long_IPv6*" \
170               tests/
171         RETURN_STATUS=$(echo $?)
172         ;;
173     PERFTEST_LONG_XCONNECT )
174         pybot ${PYBOT_ARGS} \
175               -L TRACE \
176               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
177               -s "tests.perf.Long_Xconnect*" \
178               tests/
179         RETURN_STATUS=$(echo $?)
180         ;;
181     PERFTEST_LONG_XCONNECT_DOT1Q )
182         pybot ${PYBOT_ARGS} \
183               -L TRACE \
184               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
185               -s "tests.perf.Long_Xconnect_Dot1q*" \
186         RETURN_STATUS=$(echo $?)
187         ;;
188     PERFTEST_NDR )
189         pybot ${PYBOT_ARGS} \
190               -L TRACE \
191               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
192               -s "tests.perf" -i NDR \
193               tests/
194         RETURN_STATUS=$(echo $?)
195         ;;
196     PERFTEST_PDR )
197         pybot ${PYBOT_ARGS} \
198               -L TRACE \
199               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
200               -s "tests.perf" -i PDR \
201               tests/
202         RETURN_STATUS=$(echo $?)
203         ;;
204    PERFTEST_NIGHTLY )
205         #run all available tests
206         pybot ${PYBOT_ARGS} \
207               -L TRACE \
208               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
209               -s "tests.perf" \
210               tests/
211         RETURN_STATUS=$(echo $?)
212         ;;
213     * )
214         # run full performance test suite and exit on fail
215         pybot ${PYBOT_ARGS} \
216               -L TRACE \
217               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
218               -s "tests.perf" \
219               tests/
220         RETURN_STATUS=$(echo $?)
221 esac
222
223 # Pybot output post-processing
224 echo Post-processing test data...
225
226 python ${SCRIPT_DIR}/resources/tools/robot_output_parser.py \
227        -i ${SCRIPT_DIR}/output.xml \
228        -o ${SCRIPT_DIR}/output_perf_data.xml \
229        -v ${VPP_STABLE_VER}
230 if [ ! $? -eq 0 ]; then
231     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
232 fi
233
234 # Archive artifacts
235 mkdir archive
236 for i in ${ARCHIVE_ARTIFACTS[@]}; do
237     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
238 done
239
240 echo Post-processing finished.
241
242 exit ${RETURN_STATUS}