rls1807 report: added section logical topologies in ../vpp_performance_tests/overview...
[csit.git] / bootstrap-verify-perf.sh
1 #!/bin/bash
2 # Copyright (c) 2018 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 -xo pipefail
16
17 # TOPOLOGY
18 # Space separated list of available testbeds, described by topology files
19 TOPOLOGIES_3N_HSW="topologies/available/lf_3n_hsw_testbed1.yaml \
20                    topologies/available/lf_3n_hsw_testbed2.yaml \
21                    topologies/available/lf_3n_hsw_testbed3.yaml"
22 TOPOLOGIES_2N_SKX="topologies/available/lf_2n_skx_testbed21.yaml \
23                    topologies/available/lf_2n_skx_testbed24.yaml"
24 TOPOLOGIES_3N_SKX="topologies/available/lf_3n_skx_testbed31.yaml \
25                    topologies/available/lf_3n_skx_testbed32.yaml"
26
27 # SYSTEM
28 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
29 export PYTHONPATH=${SCRIPT_DIR}
30 export DEBIAN_FRONTEND=noninteractive
31
32 # RESERVATION
33 RESERVATION_DIR="/tmp/reservation_dir"
34 INSTALLATION_DIR="/tmp/install_dir"
35
36 # ARCHIVE
37 JOB_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
38 LOG_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
39 JOB_ARCHIVE_DIR="archive"
40 LOG_ARCHIVE_DIR="$WORKSPACE/archives"
41 mkdir -p ${JOB_ARCHIVE_DIR}
42 mkdir -p ${LOG_ARCHIVE_DIR}
43
44 # JOB SETTING
45 case ${JOB_NAME} in
46     *2n-skx*)
47         TOPOLOGIES=$TOPOLOGIES_2N_SKX
48         TOPOLOGIES_TAGS="2_node_*_link_topo"
49         ;;
50     *3n-skx*)
51         TOPOLOGIES=$TOPOLOGIES_3N_SKX
52         TOPOLOGIES_TAGS="3_node_*_link_topo"
53         ;;
54     *)
55         TOPOLOGIES=$TOPOLOGIES_3N_HSW
56         TOPOLOGIES_TAGS="3_node_*_link_topo"
57         ;;
58 esac
59 case ${JOB_NAME} in
60     *hc2vpp*)
61         DUT="hc2vpp"
62         ;;
63     *vpp*)
64         DUT="vpp"
65
66         case ${JOB_NAME} in
67             csit-vpp-*)
68                 # Use downloaded packages with specific version
69                 if [[ ${TEST_TAG} == *DAILY ]] || \
70                    [[ ${TEST_TAG} == *WEEKLY ]];
71                 then
72                     echo Downloading latest VPP packages from NEXUS...
73                     bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh \
74                         --skip-install
75                 else
76                     echo Downloading VPP packages of specific version from NEXUS...
77                     DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)
78                     VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU)
79                     bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh \
80                         --skip-install --vpp ${VPP_STABLE_VER} --dkms ${DPDK_STABLE_VER}
81                 fi
82                 # Jenkins VPP deb paths (convert to full path)
83                 DUT_PKGS="$( readlink -f ${DUT}*.deb | tr '\n' ' ' )"
84                 ;;
85             vpp-csit-*)
86                 # Use local packages provided as argument list
87                 # Jenkins VPP deb paths (convert to full path)
88                 DUT_PKGS="$( readlink -f $@ | tr '\n' ' ' )"
89                 ;;
90             *)
91                 echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
92                 exit 1
93                 ;;
94         esac
95         ;;
96     *ligato*)
97         DUT="kubernetes"
98         ;;
99     *dpdk*)
100         DUT="dpdk"
101         ;;
102     *)
103         echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
104         exit 1
105         ;;
106 esac
107
108 # ENVIRONMENT PREPARATION
109 virtualenv --system-site-packages env
110 . env/bin/activate
111 pip install -r requirements.txt
112
113 if [ -z "${TOPOLOGIES}" ]; then
114     echo "No applicable topology found!"
115     exit 1
116 fi
117 # We iterate over available topologies and wait until we reserve topology
118 while :; do
119     for TOPOLOGY in ${TOPOLOGIES};
120     do
121         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
122         if [ $? -eq 0 ]; then
123             WORKING_TOPOLOGY=${TOPOLOGY}
124             echo "Reserved: ${WORKING_TOPOLOGY}"
125             break
126         fi
127     done
128
129     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
130         # Exit the infinite while loop if we made a reservation
131         break
132     fi
133
134     # Wait ~3minutes before next try
135     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
136     echo "Sleeping ${SLEEP_TIME}"
137     sleep ${SLEEP_TIME}
138 done
139
140 function cancel_all {
141     python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
142     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
143 }
144
145 # On script exit we cancel the reservation and installation and delete all vpp
146 # packages
147 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
148
149 python ${SCRIPT_DIR}/resources/tools/scripts/topo_installation.py \
150     -t ${WORKING_TOPOLOGY} -d ${INSTALLATION_DIR} -p ${DUT_PKGS}
151 if [ $? -eq 0 ]; then
152     echo "DUT installed on hosts from: ${WORKING_TOPOLOGY}"
153 else
154     echo "Failed to copy DUT packages files to hosts from: ${WORKING_TOPOLOGY}"
155     exit 1
156 fi
157
158 # CSIT EXECUTION
159 PYBOT_ARGS="--consolewidth 100 \
160             --loglevel TRACE \
161             --variable TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
162             --suite tests.${DUT}.perf"
163
164 case "$TEST_TAG" in
165     # select specific performance tests based on jenkins job type variable
166     PERFTEST_DAILY )
167         TAGS=('ndrdiscANDnic_intel-x520-da2AND1c'
168               'ndrdiscANDnic_intel-x520-da2AND2c'
169               'ndrpdrANDnic_intel-x520-da2AND1c'
170               'ndrpdrANDnic_intel-x520-da2AND2c'
171               'ndrdiscAND1cANDipsec'
172               'ndrdiscAND2cANDipsec')
173         ;;
174     PERFTEST_SEMI_WEEKLY )
175         TAGS=('ndrdiscANDnic_intel-x710AND1c'
176               'ndrdiscANDnic_intel-x710AND2c'
177               'ndrdiscANDnic_intel-xl710AND1c'
178               'ndrdiscANDnic_intel-xl710AND2c')
179         ;;
180     PERFTEST_MRR_DAILY )
181        TAGS=('mrrAND64bAND1c'
182              'mrrAND64bAND2c'
183              'mrrAND64bAND4c'
184              'mrrAND78bAND1c'
185              'mrrAND78bAND2c'
186              'mrrAND78bAND4c'
187              'mrrANDimixAND1cANDvhost'
188              'mrrANDimixAND2cANDvhost'
189              'mrrANDimixAND4cANDvhost'
190              'mrrANDimixAND1cANDmemif'
191              'mrrANDimixAND2cANDmemif'
192              'mrrANDimixAND4cANDmemif')
193         ;;
194     VERIFY-PERF-PATCH )
195         if [[ -z "$TEST_TAG_STRING" ]]; then
196             # If nothing is specified, we will run pre-selected tests by
197             # following tags. Items of array will be concatenated by OR in Robot
198             # Framework.
199             TEST_TAG_ARRAY=('mrrANDnic_intel-x710AND1cAND64bANDip4base'
200                             'mrrANDnic_intel-x710AND1cAND78bANDip6base'
201                             'mrrANDnic_intel-x710AND1cAND64bANDl2bdbase')
202         else
203             # If trigger contains tags, split them into array.
204             TEST_TAG_ARRAY=(${TEST_TAG_STRING//:/ })
205         fi
206
207         TAGS=()
208
209         for TAG in "${TEST_TAG_ARRAY[@]}"; do
210             if [[ ${TAG} == "!"* ]]; then
211                 # Exclude tags are not prefixed.
212                 TAGS+=("${TAG}")
213             else
214                 # We will prefix with perftest to prevent running other tests
215                 # (e.g. Functional).
216                 prefix="perftestAND"
217                 if [[ ${JOB_NAME} == vpp-* ]] ; then
218                     # Automatic prefixing for VPP jobs to limit the NIC used and
219                     # traffic evaluation to MRR.
220                     prefix="${prefix}mrrANDnic_intel-x710AND"
221                 fi
222                 TAGS+=("$prefix${TAG}")
223             fi
224         done
225         ;;
226     * )
227         TAGS=('perftest')
228 esac
229
230 # Catenate TAG selections
231 EXPANDED_TAGS=()
232 for TAG in "${TAGS[@]}"; do
233     if [[ ${TAG} == "!"* ]]; then
234         EXPANDED_TAGS+=(" --exclude ${TAG#$"!"} ")
235     else
236         EXPANDED_TAGS+=(" --include ${TOPOLOGIES_TAGS}AND${TAG} ")
237     fi
238 done
239
240 # Execute the test
241 pybot ${PYBOT_ARGS}${EXPANDED_TAGS[@]} tests/
242 RETURN_STATUS=$(echo $?)
243
244 # Archive JOB artifacts in jenkins
245 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
246     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
247 done
248 # Archive JOB artifacts to logs.fd.io
249 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
250     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
251 done
252
253 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.