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