Don't use dpdk dev packages - weekly, func and perf jobs
[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)_amd64
49         VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL_UBUNTU)
50         VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU)
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-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
57         wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
58         wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
59         VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
60     fi
61
62     cd ..
63
64 # If we run this script from vpp project we want to use local build
65 elif [[ ${JOB_NAME} == vpp-* ]] ;
66 then
67     # Use local packages provided as argument list
68     # Jenkins VPP deb paths (convert to full path)
69     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
70     # Take vpp package and get the vpp version
71     VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )"
72     # Download DPDK parts not included in dpdk plugin of vpp build
73     DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)_amd64
74     VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL_UBUNTU)
75     VPP_CLASSIFIER="-deb"
76     wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit
77     VPP_DEBS+=($( readlink -f vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb ))
78 else
79     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
80     exit 1
81 fi
82
83 WORKING_TOPOLOGY=""
84 export PYTHONPATH=${SCRIPT_DIR}
85
86 sudo apt-get -y update
87 sudo apt-get -y install libpython2.7-dev python-virtualenv
88
89 virtualenv --system-site-packages env
90 . env/bin/activate
91
92 echo pip install
93 pip install -r requirements.txt
94
95 # We iterate over available topologies and wait until we reserve topology
96 while :; do
97     for TOPOLOGY in ${TOPOLOGIES};
98     do
99         python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
100         if [ $? -eq 0 ]; then
101             WORKING_TOPOLOGY=${TOPOLOGY}
102             echo "Reserved: ${WORKING_TOPOLOGY}"
103             break
104         fi
105     done
106
107     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
108         # Exit the infinite while loop if we made a reservation
109         break
110     fi
111
112     # Wait ~3minutes before next try
113     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
114     echo "Sleeping ${SLEEP_TIME}"
115     sleep ${SLEEP_TIME}
116 done
117
118 function cancel_all {
119     python ${SCRIPT_DIR}/resources/tools/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
120     python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -c -t $1
121 }
122
123 # On script exit we cancel the reservation and installation and delete all vpp
124 # packages
125 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
126
127 python ${SCRIPT_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
128                                                        -d ${INSTALLATION_DIR} \
129                                                        -p ${VPP_DEBS}
130 if [ $? -eq 0 ]; then
131     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
132 else
133     echo "Failed to copy vpp deb files to DUTs"
134     exit 1
135 fi
136
137 case "$TEST_TAG" in
138     # run specific performance tests based on jenkins job type variable
139     PERFTEST_LONG )
140         pybot ${PYBOT_ARGS} \
141               -L TRACE \
142               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
143               -s "tests.perf" \
144               --exclude SKIP_PATCH \
145               -i NDRPDRDISC \
146               tests/
147         RETURN_STATUS=$(echo $?)
148         ;;
149     PERFTEST_SHORT )
150         pybot ${PYBOT_ARGS} \
151               -L TRACE \
152               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
153               -s "tests.perf" \
154               -i NDRCHK \
155               tests/
156         RETURN_STATUS=$(echo $?)
157         ;;
158    PERFTEST_NIGHTLY )
159         #run all available tests
160         pybot ${PYBOT_ARGS} \
161               -L TRACE \
162               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
163               -s "tests.perf" \
164               tests/
165         RETURN_STATUS=$(echo $?)
166         ;;
167     * )
168         # run full performance test suite and exit on fail
169         pybot ${PYBOT_ARGS} \
170               -L TRACE \
171               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
172               -s "tests.perf" \
173               tests/
174         RETURN_STATUS=$(echo $?)
175 esac
176
177 # Pybot output post-processing
178 echo Post-processing test data...
179
180 python ${SCRIPT_DIR}/resources/tools/robot_output_parser.py \
181        -i ${SCRIPT_DIR}/output.xml \
182        -o ${SCRIPT_DIR}/output_perf_data.xml \
183        -v ${VPP_STABLE_VER}
184 if [ ! $? -eq 0 ]; then
185     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
186 fi
187
188 # Archive artifacts
189 mkdir archive
190 for i in ${ARCHIVE_ARTIFACTS[@]}; do
191     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
192 done
193
194 echo Post-processing finished.
195
196 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.