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