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