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