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