CSIT-1212: Add 2n/3n-skx to Test Configuration
[csit.git] / bootstrap-verify-perf-DPDK.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
35 # ARCHIVE
36 JOB_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
37 LOG_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
38 JOB_ARCHIVE_DIR="archive"
39 LOG_ARCHIVE_DIR="$WORKSPACE/archives"
40 mkdir -p ${JOB_ARCHIVE_DIR}
41 mkdir -p ${LOG_ARCHIVE_DIR}
42
43 # JOB SETTING
44 case ${JOB_NAME} in
45     *2n-skx*)
46         TOPOLOGIES=$TOPOLOGIES_2N_SKX
47         TOPOLOGIES_TAGS="2_node_*_link_topo"
48         ;;
49     *3n-skx*)
50         TOPOLOGIES=$TOPOLOGIES_3N_SKX
51         TOPOLOGIES_TAGS="3_node_*_link_topo"
52         ;;
53     *)
54         TOPOLOGIES=$TOPOLOGIES_3N_HSW
55         TOPOLOGIES_TAGS="3_node_*_link_topo"
56         ;;
57 esac
58 case ${JOB_NAME} in
59     *hc2vpp*)
60         DUT="hc2vpp"
61         ;;
62     *vpp*)
63         DUT="vpp"
64         ;;
65     *ligato*)
66         DUT="kubernetes"
67         ;;
68     *dpdk*)
69         DUT="dpdk"
70
71         # If we run this script from CSIT jobs we want to use stable version
72         DPDK_REPO='https://fast.dpdk.org/rel/'
73         if [[ ${TEST_TAG} == *DAILY ]] || \
74            [[ ${TEST_TAG} == *WEEKLY ]];
75         then
76             echo Downloading latest DPDK packages from repo...
77             DPDK_STABLE_VER=$(wget --no-check-certificate --quiet -O - ${DPDK_REPO} | \
78                 grep -v '2015' | grep -Eo 'dpdk-[^\"]+xz' | tail -1)
79         else
80             echo Downloading DPDK packages of specific version from repo...
81             DPDK_STABLE_VER='dpdk-18.05.tar.xz'
82         fi
83         wget --no-check-certificate --quiet ${DPDK_REPO}${DPDK_STABLE_VER}
84         ;;
85     *)
86         echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
87         exit 1
88         ;;
89 esac
90
91
92 # ENVIRONMENT PREPARATION
93 virtualenv --system-site-packages env
94 . env/bin/activate
95 pip install -r requirements.txt
96
97 if [ -z "${TOPOLOGIES}" ]; then
98     echo "No applicable topology found!"
99     exit 1
100 fi
101 # We iterate over available topologies and wait until we reserve topology
102 while :; do
103     for TOPOLOGY in ${TOPOLOGIES};
104     do
105         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
106         if [ $? -eq 0 ]; then
107             WORKING_TOPOLOGY=${TOPOLOGY}
108             echo "Reserved: ${WORKING_TOPOLOGY}"
109             break
110         fi
111     done
112
113     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
114         # Exit the infinite while loop if we made a reservation
115         break
116     fi
117
118     # Wait ~3minutes before next try
119     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
120     echo "Sleeping ${SLEEP_TIME}"
121     sleep ${SLEEP_TIME}
122 done
123
124 #for DPDK test, we don't need to install the VPP deb
125 function cancel_all {
126     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
127 }
128
129 # On script exit we cancel the reservation
130 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
131
132 # CSIT EXECUTION
133 PYBOT_ARGS="--consolewidth 100 \
134             --loglevel TRACE \
135             --variable TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
136             --suite tests.${DUT}.perf"
137
138 case "$TEST_TAG" in
139     # select specific performance tests based on jenkins job type variable
140     PERFTEST_MRR_DAILY )
141        TAGS=('mrrAND64bAND1c'
142              'mrrAND64bAND2c'
143              'mrrAND64bAND4c'
144              'mrrAND78bAND1c'
145              'mrrAND78bAND2c'
146              'mrrAND78bAND4c'
147              'mrrANDimixAND1c'
148              'mrrANDimixAND2c'
149              'mrrANDimixAND4c')
150         ;;
151     VERIFY-PERF-PATCH )
152         if [[ -z "$TEST_TAG_STRING" ]]; then
153             # If nothing is specified, we will run pre-selected tests by
154             # following tags. Items of array will be concatenated by OR in Robot
155             # Framework.
156             TEST_TAG_ARRAY=('mrrANDnic_intel-x710AND1cAND64b')
157         else
158             # If trigger contains tags, split them into array.
159             TEST_TAG_ARRAY=(${TEST_TAG_STRING//:/ })
160         fi
161
162         TAGS=()
163
164         for TAG in "${TEST_TAG_ARRAY[@]}"; do
165             if [[ ${TAG} == "!"* ]]; then
166                 # Exclude tags are not prefixed.
167                 TAGS+=("${TAG}")
168             else
169                 # We will prefix with perftest to prevent running other tests
170                 # (e.g. Functional).
171                 prefix="perftestAND"
172                 if [[ ${JOB_NAME} == vpp-* ]] ; then
173                     # Automatic prefixing for VPP jobs to limit the NIC used and
174                     # traffic evaluation to MRR.
175                     prefix="${prefix}mrrANDnic_intel-x710AND"
176                 fi
177                 TAGS+=("$prefix${TAG}")
178             fi
179         done
180         ;;
181     * )
182         TAGS=('perftest')
183 esac
184
185 # Catenate TAG selections
186 EXPANDED_TAGS=()
187 for TAG in "${TAGS[@]}"; do
188     if [[ ${TAG} == "!"* ]]; then
189         EXPANDED_TAGS+=(" --exclude ${TAG#$"!"} ")
190     else
191         EXPANDED_TAGS+=(" --include ${TOPOLOGIES_TAGS}AND${TAG} ")
192     fi
193 done
194
195 # Execute the test
196 pybot ${PYBOT_ARGS}${EXPANDED_TAGS[@]} tests/
197 RETURN_STATUS=$(echo $?)
198
199 # Archive JOB artifacts in jenkins
200 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
201     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
202 done
203 # Archive JOB artifacts to logs.fd.io
204 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
205     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
206 done
207
208 exit ${RETURN_STATUS}