3 # Copyright 2015-2017 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"
29 EXIT_SANITY_TC_FAILED=2
32 EXIT_NO_TEST_REPORT_LOG_DIR=256
39 LOG_FILE_PREFIX="/tmp/vsperf_build"
40 DATE=$(date -u +"%Y-%m-%d_%H-%M-%S")
41 BRANCH=${GIT_BRANCH##*/}
42 VSPERFENV_DIR="$HOME/vsperfenv"
43 RESULTS_ARCHIVE="$HOME/ci_results_archive"
45 # CI job specific configuration
46 # VERIFY - run basic set of TCs with default settings
47 TESTCASES_VERIFY="vswitch_add_del_bridge vswitch_add_del_bridges vswitch_add_del_vport vswitch_add_del_vports vswitch_vports_add_del_flow"
48 TESTPARAM_VERIFY="--integration"
49 TESTCASES_VERIFY_VPP="vswitch_add_del_bridge vswitch_add_del_bridges vswitch_add_del_vport vswitch_add_del_vports vswitch_vports_add_del_connection_vpp"
50 TESTPARAM_VERIFY_VPP=$TESTPARAM_VERIFY
51 # MERGE - run selected TCs with default settings
52 TESTCASES_MERGE=$TESTCASES_VERIFY
53 TESTPARAM_MERGE=$TESTPARAM_VERIFY
54 TESTCASES_MERGE_VPP=$TESTCASES_VERIFY_VPP
55 TESTPARAM_MERGE_VPP=$TESTPARAM_VERIFY_VPP
56 # DAILY - run selected TCs for defined packet sizes
57 TESTCASES_DAILY='phy2phy_tput back2back phy2phy_tput_mod_vlan phy2phy_scalability pvp_tput pvp_back2back pvvp_tput pvvp_back2back'
58 TESTCASES_DAILY_VPP='phy2phy_tput_vpp phy2phy_back2back_vpp pvp_tput_vpp pvp_back2back_vpp pvvp_tput_vpp pvvp_back2back_vpp'
59 TESTPARAM_DAILY='--test-params TRAFFICGEN_PKT_SIZES=(64,128,512,1024,1518)'
60 TESTPARAM_DAILY_VPP=$TESTPARAM_DAILY
61 TESTCASES_SRIOV='pvp_tput'
62 TESTPARAM_SRIOV='--test-params TRAFFICGEN_PKT_SIZES=(64,128,512,1024,1518)'
63 # check if user config file exists if not then we will use default settings
64 if [ -f $HOME/vsperf-${BRANCH}.conf ] ; then
65 # branch specific config was found
66 CONF_FILE="--conf-file ${HOME}/vsperf-${BRANCH}.conf"
68 if [ -f $HOME/vsperf.conf ] ; then
69 CONF_FILE="--conf-file ${HOME}/vsperf.conf"
74 # check if sriov specific config file exists if not then use default configuration
75 if [ -f $HOME/vsperf-${BRANCH}.conf.sriov ] ; then
76 CONF_FILE_SRIOV="${CONF_FILE}.sriov"
78 CONF_FILE_SRIOV=$CONF_FILE
81 # Test report related configuration
82 TEST_REPORT_PARTIAL="*_test_report.rst"
83 TEST_REPORT_DIR="${WORKSPACE}/docs/testing/developer/devguide/results"
84 TEST_REPORT_INDEX="${TEST_REPORT_DIR}/index.rst"
85 TEST_REPORT_LINK_OLD="https://wiki.opnfv.org/wiki/vsperf_results"
86 TEST_REPORT_FILE="${WORKSPACE}/docs_output/testing_developer_devguide_results/index.html"
87 TEST_REPORT_TARBALL="vswitchperf_logs_${DATE}.tar.gz"
89 if [[ "x${BRANCH}" == "xmaster" ]]; then
90 TEST_REPORT_LINK_NEW="https://artifacts.opnfv.org/logs/$PROJECT/$NODE_NAME/$DATE/${TEST_REPORT_TARBALL}"
92 TEST_REPORT_LINK_NEW="https://artifacts.opnfv.org/logs/$PROJECT/$NODE_NAME/$BRANCH/$DATE/${TEST_REPORT_TARBALL}"
95 TEST_REPORT_LOG_DIR="${HOME}/opnfv/$PROJECT/results/$BRANCH"
101 # terminate vsperf and all its utilities
102 # it is expected that vsperf is the only python3 app
103 # and no other ovs or qemu instances are running
107 function terminate_vsperf() {
108 sudo pkill stress &> /dev/null
109 sudo pkill python3 &> /dev/null
110 sudo killall -9 qemu-system-x86_64 &> /dev/null
112 # sometimes qemu resists to terminate, so wait a bit and kill it again
113 if pgrep qemu-system-x86_64 &> /dev/null ; then
115 sudo killall -9 qemu-system-x86_64 &> /dev/null
119 sudo pkill ovs-vswitchd &> /dev/null
121 sudo pkill ovsdb-server &> /dev/null
125 # check and print testcase execution status
127 # $1 - directory with results
128 function print_results() {
129 for i in $TESTCASES ; do
130 if [ ! -e $1 ] ; then
131 printf " %-70s %-6s\n" "result_${i}" "FAILED"
134 RES_FILE=`ls -1 $1 | egrep "result_${i}_[0-9a-zA-Z\-]+.csv"`
136 if [ "x$RES_FILE" != "x" -a -e "${1}/${RES_FILE}" ]; then
137 if grep ^FAILED "${1}/${RES_FILE}" &> /dev/null ; then
138 printf " %-70s %-6s\n" "result_${i}" "FAILED"
141 printf " %-70s %-6s\n" "result_${i}" "OK"
144 printf " %-70s %-6s\n" "result_${i}" "FAILED"
151 # execute tests and display results
153 # $1 - vswitch and vnf combination, one of OVS_vanilla, OVS_with_DPDK_and_vHost_User
154 # $2 - CI job type, one of verify, merge, daily
155 function execute_vsperf() {
157 # figure out list of TCs and execution parameters
160 if [ "$1" == "VPP" ] ; then
161 TESTPARAM=$TESTPARAM_VERIFY_VPP
162 TESTCASES=$TESTCASES_VERIFY_VPP
164 TESTPARAM=$TESTPARAM_VERIFY
165 TESTCASES=$TESTCASES_VERIFY
169 if [ "$1" == "VPP" ] ; then
170 TESTPARAM=$TESTPARAM_MERGE_VPP
171 TESTCASES=$TESTCASES_MERGE_VPP
173 TESTPARAM=$TESTPARAM_MERGE
174 TESTCASES=$TESTCASES_MERGE
178 # by default use daily build and upload results to the OPNFV databse
179 if [ "$1" == "VPP" ] ; then
180 TESTPARAM=$TESTPARAM_DAILY_VPP
181 TESTCASES=$TESTCASES_DAILY_VPP
182 # don't report VPP results into testresults DB, until TC name mapping
183 # for VPP tests will be defined
184 #OPNFVPOD="--opnfvpod=$NODE_NAME"
186 TESTPARAM=$TESTPARAM_DAILY
187 TESTCASES=$TESTCASES_DAILY
188 OPNFVPOD="--opnfvpod=$NODE_NAME"
194 echo -e "\nExecution of VSPERF for $1"
196 DATE_SUFFIX=$(date -u +"%Y-%m-%d_%H-%M-%S")
200 # use SRIOV specific TCs and configuration
201 TESTPARAM=$TESTPARAM_SRIOV
202 TESTCASES=$TESTCASES_SRIOV
203 # figure out log file name
205 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
207 echo " $VSPERF_BIN --vswitch none --vnf QemuPciPassthrough $CONF_FILE_SRIOV $TESTPARAM $TESTCASES &> $LOG_FILE"
208 $VSPERF_BIN --vswitch none --vnf QemuPciPassthrough $CONF_FILE_SRIOV $TESTPARAM $TESTCASES &> $LOG_FILE
211 # figure out log file name
212 LOG_SUBDIR="VppDpdkVhost"
213 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
215 hugepages_info > $LOG_FILE
216 echo " $VSPERF_BIN $OPNFVPOD --vswitch VppDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES > $LOG_FILE"
217 $VSPERF_BIN $OPNFVPOD --vswitch VppDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES &>> $LOG_FILE
218 hugepages_info >> $LOG_FILE
221 # figure out log file name
222 LOG_SUBDIR="OvsVanilla"
223 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
225 echo " $VSPERF_BIN $OPNFVPOD --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE"
226 $VSPERF_BIN $OPNFVPOD --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
229 # figure out log file name
230 LOG_SUBDIR="OvsDpdkVhost"
231 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
233 hugepages_info > $LOG_FILE
234 echo " $VSPERF_BIN $OPNFVPOD --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES > $LOG_FILE"
235 $VSPERF_BIN $OPNFVPOD --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES &>> $LOG_FILE
236 hugepages_info >> $LOG_FILE
240 # evaluation of results
241 echo -e "\nResults for $1"
242 RES_DIR="/$(grep "Creating result directory" $LOG_FILE | cut -d'/' -f2-)"
243 if [[ "/" == "${RES_DIR}" ]] ; then
244 echo "FAILURE: Results are not available."
245 echo "-------------------------------------------------------------------"
247 echo "-------------------------------------------------------------------"
248 exit $EXIT_NO_RESULTS
250 print_results "${RES_DIR}"
251 if [ $(($EXIT & $EXIT_TC_FAILED)) -gt 0 ] ; then
252 echo "-------------------------------------------------------------------"
254 echo "-------------------------------------------------------------------"
258 # show detailed result figures
259 for md_file in $(grep '\.md"$' $LOG_FILE | cut -d'"' -f2); do
260 # TC resut file header
261 echo -e "\n-------------------------------------------------------------------"
263 echo -e "-------------------------------------------------------------------\n"
265 sed -n '/^- Test ID/,/Bidirectional/{/Packet size/b;p;/Bidirectional/q};/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file
267 sed -n '/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file | grep -v "Unknown" | cat -s
270 # add test results into the final doc template
271 for report in ${RES_DIR}/${TEST_REPORT_PARTIAL} ; do
272 # modify link to the artifactory with test report and logs
273 if [ -f $report ] ; then
274 sed -i -e "s,$TEST_REPORT_LINK_OLD,$TEST_REPORT_LINK_NEW," "$report"
275 cp $report $TEST_REPORT_DIR
276 echo " $(basename $report)" >> $TEST_REPORT_INDEX
280 # copy logs into dedicated directory
281 mkdir ${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}
282 [ -f "$LOG_FILE" ] && cp -a "${LOG_FILE}" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
283 [ -d "$RES_DIR" ] && cp -ar "$RES_DIR" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
286 # generates final test_report in PDF and HTML formats
287 function generate_report() {
289 # prepare final tarball with all logs...
290 tar --exclude "${TEST_REPORT_TARBALL}" -czf "${TEST_REPORT_LOG_DIR}/${TEST_REPORT_TARBALL}" $(find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d)
291 # ...and move original log files to the archive directory...
292 find "${TEST_REPORT_LOG_DIR}" -maxdepth 2 -name "results_*" -type d -exec mv \{\} ${RESULTS_ARCHIVE} \;
293 # ...and remove the rest
294 find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d -exec rm -rf \{\} \;
296 # clone opnfvdocs repository
297 echo "Cloning opnfvdocs repository..."
298 [ -d opnfvdocs ] && rm -rf opnfvdocs
299 git clone https://gerrit.opnfv.org/gerrit/opnfvdocs &> /dev/null
301 # generate final docs with test results
302 echo "Generating test report..."
303 sed -ie 's,python ,python2 ,g' ./opnfvdocs/scripts/docs-build.sh
304 OPNFVDOCS_DIR='./opnfvdocs' ./opnfvdocs/scripts/docs-build.sh &> /dev/null
306 # store HTML report with test results into dedicated directory
307 if [ -f $TEST_REPORT_FILE ] ; then
308 cp -ar $TEST_REPORT_FILE $(dirname $TEST_REPORT_FILE)/_static $TEST_REPORT_LOG_DIR
309 echo "Final test report has been created."
311 echo "FAILURE: Generation of final test report has failed."
315 # generates graphs from recent test results
316 function generate_and_push_graphs() {
317 # create graphs from results in archive directory
318 ./ci/plot-results.sh "$1" "$2" "$RESULTS_ARCHIVE"
320 # push graphs into artifactory
321 if ls *png &> /dev/null ; then
322 gsutil cp *png gs://artifacts.opnfv.org/logs/vswitchperf/intel-pod12/graphs/
324 echo "Graphs were not created."
328 # pushes test report and logs collected during test execution into artifactory
329 function push_results_to_artifactory() {
330 # clone releng repository
331 echo "Cloning releng repository..."
332 [ -d releng ] && rm -rf releng
333 git clone https://gerrit.opnfv.org/gerrit/releng &> /dev/null
335 echo "Pushing results and logs into artifactory..."
336 . ./releng/utils/push-test-logs.sh "$DATE"
338 # enter workspace as it could be modified by 3rd party script
342 # removes any local changes of repository
344 echo "Cleaning up..."
348 # prepares directory for logs collection and removes old logs
349 function initialize_logdir() {
350 if [[ "x$TEST_REPORT_LOG_DIR" == "x" ]] ; then
351 echo "FAILURE: Logging directory is not defined. Logs and report cannot be published!"
352 exit $EXIT_NO_TEST_REPORT_LOG_DIR
354 # remove TEST_REPORT_LOG_DIR if it exists
355 if [ -e $TEST_REPORT_LOG_DIR ] ; then
356 if [ -f $TEST_REPORT_LOG_DIR ] ; then
357 rm $TEST_REPORT_LOG_DIR
359 rm -rf ${TEST_REPORT_LOG_DIR}
362 # create TEST_REPORT_LOG_DIR
363 mkdir -p $TEST_REPORT_LOG_DIR
367 # verify basic vsperf functionality
368 function execute_vsperf_sanity() {
369 DATE_SUFFIX=$(date -u +"%Y-%m-%d_%H-%M-%S")
370 LOG_FILE="${LOG_FILE_PREFIX}_sanity_${DATE_SUFFIX}.log"
371 echo "Execution of VSPERF sanity checks:"
372 for PARAM in '--version' '--help' '--list-trafficgens' '--list-collectors' '--list-vswitches' '--list-fwdapps' '--list-vnfs' '--list-settings' '--list' '--integration --list'; do
373 echo -e "-------------------------------------------------------------------" >> $LOG_FILE
374 echo "$VSPERF_BIN $PARAM $CONF_FILE" >> $LOG_FILE
375 echo -e "-------------------------------------------------------------------" >> $LOG_FILE
376 $VSPERF_BIN $PARAM $CONF_FILE &>> $LOG_FILE
377 if $VSPERF_BIN $PARAM $CONF_FILE &>> $LOG_FILE ; then
378 printf " %-70s %-6s\n" "$VSPERF_BIN $PARAM" "OK"
380 printf " %-70s %-6s\n" "$VSPERF_BIN $PARAM" "FAILED"
381 EXIT=$EXIT_SANITY_TC_FAILED
385 echo "Sanity log file $LOG_FILE"
386 if [ $(($EXIT & $EXIT_SANITY_TC_FAILED)) -gt 0 ] ; then
387 echo "-------------------------------------------------------------------"
389 echo "-------------------------------------------------------------------"
393 # execute pylint to check code quality
394 function execute_vsperf_pylint_check() {
395 if ! ./check -b ; then
396 EXIT=$EXIT_PYLINT_FAILED
400 # check and install required packages at nodes running VERIFY and MERGE jobs
401 function dependencies_check() {
403 if [ $ID == "ubuntu" ] ; then
404 echo "Dependencies check"
405 echo "=================="
406 # install system packages
407 for PACKAGE in "python3-tk" "sysstat" "bc" ; do
408 if dpkg -s $PACKAGE &> /dev/null ; then
409 printf " %-70s %-6s\n" $PACKAGE "OK"
411 printf " %-70s %-6s\n" $PACKAGE "missing"
412 sudo apt-get install -y $PACKAGE
415 # install additional python packages into python environment
416 for PACKAGE in "pylint" ; do
417 if pip show $PACKAGE &> /dev/null ; then
418 printf " %-70s %-6s\n" $PACKAGE "OK"
420 printf " %-70s %-6s\n" $PACKAGE "missing"
428 # configure hugepages
429 function configure_hugepages() {
432 HP_NR=`cat /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages`
433 HP_FREE=`cat /sys/devices/system/node/node0/hugepages/hugepages-2048kB/free_hugepages`
434 # check if HP must be (re)configured
435 if [ $HP_FREE -lt $HP_REQUESTED ] ; then
436 HP_NR_NEW=$(($HP_NR+($HP_REQUESTED-$HP_FREE)))
437 if [ $HP_NR_NEW -gt $HP_MAX ] ; then
440 sudo bash -c "echo $HP_NR_NEW > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages"
443 if [ -f /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages ] ; then
444 sudo bash -c "echo 0 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages"
448 # dump hugepages configuration
449 function hugepages_info() {
450 echo "-------------------------------------------------------------------"
451 head /sys/devices/system/node/node*/hugepages/hugepages*/*
452 echo "-------------------------------------------------------------------"
461 # enter workspace dir
464 # create virtualenv if needed
465 if [ ! -e $VSPERFENV_DIR ] ; then
466 echo "Create VSPERF environment"
467 echo "========================="
468 virtualenv --python=python3 "$VSPERFENV_DIR"
472 # acivate and update virtualenv
473 echo "Update VSPERF environment"
474 echo "========================="
475 source "$VSPERFENV_DIR"/bin/activate
476 pip install -r ./requirements.txt
479 # VERFIY&MERGE job specific - check if required packages are installed
485 # configure hugepages
486 echo "Configure hugepages"
487 echo "==================="
489 hugepages_info | grep -v '^--'
492 # execute job based on passed parameter
495 echo "================="
496 echo "VSPERF verify job"
497 echo "================="
499 execute_vsperf_pylint_check
501 execute_vsperf_sanity
503 execute_vsperf OVS_with_DPDK_and_vHost_User $1
505 execute_vsperf OVS_vanilla $1
507 execute_vsperf VPP $1
513 echo "================"
514 echo "VSPERF merge job"
515 echo "================"
519 execute_vsperf_sanity
521 execute_vsperf OVS_with_DPDK_and_vHost_User $1
523 execute_vsperf OVS_vanilla $1
525 execute_vsperf VPP $1
531 echo "================"
532 echo "VSPERF daily job"
533 echo "================"
536 execute_vsperf OVS_with_DPDK_and_vHost_User $1
538 execute_vsperf OVS_vanilla $1
540 execute_vsperf VPP $1
542 execute_vsperf SRIOV $1
547 push_results_to_artifactory
549 generate_and_push_graphs "$TESTCASES_DAILY" ",OvsDpdkVhost,"
550 generate_and_push_graphs "$TESTCASES_DAILY" ",OvsVanilla,"
551 generate_and_push_graphs "$TESTCASES_DAILY_VPP" ",VppDpdkVhost,"
552 generate_and_push_graphs "$TESTCASES_SRIOV" ",none,"