3 # Copyright 2015-2016 Intel Corporation.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # VSPERF nightly build execution script
20 # build-vsperf.sh job_type
21 # where job_type is one of "verify", "merge", "daily"
30 EXIT_NO_TEST_REPORT_LOG_DIR=11
37 LOG_FILE_PREFIX="/tmp/vsperf_build"
38 DATE=$(date -u +"%Y-%m-%d_%H-%M-%S")
39 BRANCH=${GIT_BRANCH##*/}
41 # CI job specific configuration
42 # VERIFY - run basic set of TCs with default settings
43 TESTCASES_VERIFY="phy2phy_tput pvp_tput"
45 # MERGE - run selected TCs with default settings
46 TESTCASES_MERGE="phy2phy_tput back2back phy2phy_cont pvp_tput pvvp_tput"
48 # DAILY - run selected TCs for defined packet sizes
49 TESTCASES_DAILY='phy2phy_tput back2back phy2phy_tput_mod_vlan phy2phy_scalability pvp_tput pvp_back2back pvvp_tput pvvp_back2back'
50 TESTPARAM_DAILY='--test-params pkt_sizes=64,128,512,1024,1518'
51 # check if user config file exists if not then we will use default settings
52 if [ -f $HOME/vsperf-${BRANCH}.conf ] ; then
53 # branch specific config was found
54 CONF_FILE="--conf-file ${HOME}/vsperf-${BRANCH}.conf"
56 if [ -f $HOME/vsperf.conf ] ; then
57 CONF_FILE="--conf-file ${HOME}/vsperf.conf"
63 # Test report related configuration
64 TEST_REPORT_PARTIAL="*_test_report.rst"
65 TEST_REPORT_DIR="${WORKSPACE}/docs/results"
66 TEST_REPORT_INDEX="${TEST_REPORT_DIR}/index.rst"
67 TEST_REPORT_LINK_OLD="https://wiki.opnfv.org/wiki/vsperf_results"
68 TEST_REPORT_FILE="${WORKSPACE}/docs_output/results/results.pdf"
69 TEST_REPORT_TARBALL="vswitchperf_logs_${DATE}.tar.gz"
71 if [[ "x${BRANCH}" == "xmaster" ]]; then
72 TEST_REPORT_LINK_NEW="https://artifacts.opnfv.org/logs/$PROJECT/$NODE_NAME/$DATE/${TEST_REPORT_TARBALL}"
74 TEST_REPORT_LINK_NEW="https://artifacts.opnfv.org/logs/$PROJECT/$NODE_NAME/$BRANCH/$DATE/${TEST_REPORT_TARBALL}"
77 TEST_REPORT_LOG_DIR="${HOME}/opnfv/$PROJECT/results/$BRANCH"
83 # terminate vsperf and all its utilities
84 # it is expected that vsperf is the only python3 app
85 # and no other ovs or qemu instances are running
89 function terminate_vsperf() {
90 sudo pkill stress &> /dev/null
91 sudo pkill python3 &> /dev/null
92 sudo killall -9 qemu-system-x86_64 &> /dev/null
94 # sometimes qemu resists to terminate, so wait a bit and kill it again
95 if pgrep qemu-system-x86_64 &> /dev/null ; then
97 sudo killall -9 qemu-system-x86_64 &> /dev/null
101 sudo pkill ovs-vswitchd &> /dev/null
103 sudo pkill ovsdb-server &> /dev/null
107 # check and print testcase execution status
109 # $1 - directory with results
110 function print_results() {
111 for i in $TESTCASES ; do
112 if [[ $i == *"pvp"* ]]; then
114 elif [[ $i == *"pvvp"* ]]; then
119 RES_FILE="result_${i}_${DEPLOYMENT}.csv"
121 if [ -e "${1}/${RES_FILE}" ]; then
122 printf " %-70s %-6s\n" $RES_FILE "OK"
124 printf " %-70s %-6s\n" $RES_FILE "FAILED"
130 # execute tests and display results
132 # $1 - vswitch and vnf combination, one of OVS_vanilla, OVS_with_DPDK_and_vHost_User
133 # $2 - CI job type, one of verify, merge, daily
134 function execute_vsperf() {
135 # figure out list of TCs and execution parameters
138 TESTPARAM=$TESTPARAM_VERIFY
139 TESTCASES=$TESTCASES_VERIFY
142 TESTPARAM=$TESTPARAM_MERGE
143 TESTCASES=$TESTCASES_MERGE
146 # by default use daily build
147 TESTPARAM=$TESTPARAM_DAILY
148 TESTCASES=$TESTCASES_DAILY
153 echo -e "\nExecution of VSPERF for $1"
155 DATE_SUFFIX=$(date -u +"%Y-%m-%d_%H-%M-%S")
159 # figure out log file name
160 LOG_SUBDIR="OvsVanilla"
161 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
163 echo "$VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE"
164 $VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
167 # figure out log file name
168 LOG_SUBDIR="OvsDpdkVhost"
169 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
171 echo "$VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES > $LOG_FILE"
172 $VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
176 # evaluation of results
177 echo -e "\nResults for $1"
178 RES_DIR="/$(grep "Creating result directory" $LOG_FILE | cut -d'/' -f2-)"
179 if [[ "/" == "${RES_DIR}" ]] ; then
180 echo "FAILURE: Results are not available."
181 exit $EXIT_NO_RESULTS
183 print_results "${RES_DIR}"
186 # show detailed result figures
187 for md_file in $(grep '\.md"$' $LOG_FILE | cut -d'"' -f2); do
188 # TC resut file header
189 echo -e "\n-------------------------------------------------------------------"
191 echo -e "-------------------------------------------------------------------\n"
193 sed -n '/^- Test ID/,/Bidirectional/{/Packet size/b;p;/Bidirectional/q};/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file
195 sed -n '/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file | grep -v "Unknown" | cat -s
198 # add test results into the final doc template
199 for report in ${RES_DIR}/${TEST_REPORT_PARTIAL} ; do
200 # modify link to the artifactory with test report and logs
201 if [ -f $report ] ; then
202 sed -i -e "s,$TEST_REPORT_LINK_OLD,$TEST_REPORT_LINK_NEW," "$report"
203 cp $report $TEST_REPORT_DIR
204 echo " $(basename $report)" >> $TEST_REPORT_INDEX
208 # copy logs into dedicated directory
209 mkdir ${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}
210 [ -f "$LOG_FILE" ] && cp -a "${LOG_FILE}" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
211 [ -d "$RES_DIR" ] && cp -ar "$RES_DIR" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
214 # generates final test_report in PDF and HTML formats
215 function generate_report() {
217 # prepare final tarball with all logs...
218 tar --exclude "${TEST_REPORT_TARBALL}" -czf "${TEST_REPORT_LOG_DIR}/${TEST_REPORT_TARBALL}" $(find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d)
219 # ...and remove original log files
220 find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d -exec rm -rf \{\} \;
222 # clone opnfvdocs repository
223 echo "Cloning opnfvdocs repository..."
224 [ -d opnfvdocs ] && rm -rf opnfvdocs
225 git clone https://gerrit.opnfv.org/gerrit/opnfvdocs &> /dev/null
227 # generate final docs with test results
228 echo "Generating test report..."
229 sed -ie 's,python ,python2 ,g' ./opnfvdocs/scripts/docs-build.sh
230 OPNFVDOCS_DIR='./opnfvdocs' ./opnfvdocs/scripts/docs-build.sh &> /dev/null
232 # store PDF with test results into dedicated directory
233 if [ -f $TEST_REPORT_FILE ] ; then
234 cp -a $TEST_REPORT_FILE $TEST_REPORT_LOG_DIR
235 echo "Final test report has been created."
237 echo "FAILURE: Generation of final test report has failed."
241 # pushes test report and logs collected during test execution into artifactory
242 function push_results_to_artifactory() {
243 # clone releng repository
244 echo "Cloning releng repository..."
245 [ -d releng ] && rm -rf releng
246 git clone https://gerrit.opnfv.org/gerrit/releng &> /dev/null
248 echo "Pushing results and logs into artifactory..."
249 . ./releng/utils/push-test-logs.sh "$DATE"
251 # enter workspace as it could be modified by 3rd party script
255 # removes any local changes of repository
257 echo "Cleaning up..."
261 # prepares directory for logs collection and removes old logs
262 function initialize_logdir() {
263 if [[ "x$TEST_REPORT_LOG_DIR" == "x" ]] ; then
264 echo "FAILURE: Logging directory is not defined. Logs and report cannot be published!"
265 exit $EXIT_NO_TEST_REPORT_LOG_DIR
267 # remove TEST_REPORT_LOG_DIR if it exists
268 if [ -e $TEST_REPORT_LOG_DIR ] ; then
269 if [ -f $TEST_REPORT_LOG_DIR ] ; then
270 rm $TEST_REPORT_LOG_DIR
272 rm -rf ${TEST_REPORT_LOG_DIR}
275 # create TEST_REPORT_LOG_DIR
276 mkdir -p $TEST_REPORT_LOG_DIR
284 # enter workspace dir
290 # execute job based on passed parameter
293 echo "VSPERF verify job"
294 echo "================="
296 #execute_vsperf OVS_with_DPDK_and_vHost_User $1
301 echo "VSPERF merge job"
302 echo "================"
304 #execute_vsperf OVS_with_DPDK_and_vHost_User $1
309 echo "VSPERF daily job"
310 echo "================"
313 execute_vsperf OVS_with_DPDK_and_vHost_User $1
315 execute_vsperf OVS_vanilla $1
320 push_results_to_artifactory