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_Cuse, 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
166 "OVS_with_DPDK_and_vHost_Cuse")
167 # figure out log file name
168 LOG_SUBDIR="OvsDpdkVhostCuse"
169 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
171 echo "$VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostCuse $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE"
172 $VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostCuse $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
175 # figure out log file name
176 LOG_SUBDIR="OvsDpdkVhost"
177 LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log"
179 echo "$VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES > $LOG_FILE"
180 $VSPERF_BIN --opnfvpod="$NODE_NAME" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
184 # evaluation of results
185 echo -e "\nResults for $1"
186 RES_DIR="/$(grep "Creating result directory" $LOG_FILE | cut -d'/' -f2-)"
187 if [[ "/" == "${RES_DIR}" ]] ; then
188 echo "FAILURE: Results are not available."
189 exit $EXIT_NO_RESULTS
191 print_results "${RES_DIR}"
194 # show detailed result figures
195 for md_file in $(grep '\.md"$' $LOG_FILE | cut -d'"' -f2); do
196 # TC resut file header
197 echo -e "\n-------------------------------------------------------------------"
199 echo -e "-------------------------------------------------------------------\n"
201 sed -n '/^- Test ID/,/Bidirectional/{/Packet size/b;p;/Bidirectional/q};/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file
203 sed -n '/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file | grep -v "Unknown" | cat -s
206 # add test results into the final doc template
207 for report in ${RES_DIR}/${TEST_REPORT_PARTIAL} ; do
208 # modify link to the artifactory with test report and logs
209 if [ -f $report ] ; then
210 sed -i -e "s,$TEST_REPORT_LINK_OLD,$TEST_REPORT_LINK_NEW," "$report"
211 cp $report $TEST_REPORT_DIR
212 echo " $(basename $report)" >> $TEST_REPORT_INDEX
216 # copy logs into dedicated directory
217 mkdir ${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}
218 [ -f "$LOG_FILE" ] && cp -a "${LOG_FILE}" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
219 [ -d "$RES_DIR" ] && cp -ar "$RES_DIR" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
222 # generates final test_report in PDF and HTML formats
223 function generate_report() {
225 # prepare final tarball with all logs...
226 tar --exclude "${TEST_REPORT_TARBALL}" -czf "${TEST_REPORT_LOG_DIR}/${TEST_REPORT_TARBALL}" $(find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d)
227 # ...and remove original log files
228 find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d -exec rm -rf \{\} \;
230 # clone releng repository
231 echo "Cloning releng repository..."
232 [ -d releng ] && rm -rf releng
233 git clone https://gerrit.opnfv.org/gerrit/releng &> /dev/null
235 # generate final docs with test results
236 echo "Generating test report..."
237 sed -ie 's,python ,python2 ,g' ./releng/utils/docs-build.sh
238 ./releng/utils/docs-build.sh &> /dev/null
240 # store PDF with test results into dedicated directory
241 if [ -f $TEST_REPORT_FILE ] ; then
242 cp -a $TEST_REPORT_FILE $TEST_REPORT_LOG_DIR
243 echo "Final test report has been created."
245 echo "FAILURE: Generation of final test report has failed."
249 # pushes test report and logs collected during test execution into artifactory
250 function push_results_to_artifactory() {
251 echo "Pushing results and logs into artifactory..."
252 . ./releng/utils/push-test-logs.sh "$DATE"
254 # enter workspace as it could be modified by 3rd party script
258 # removes any local changes of repository
260 echo "Cleaning up..."
264 # prepares directory for logs collection and removes old logs
265 function initialize_logdir() {
266 if [[ "x$TEST_REPORT_LOG_DIR" == "x" ]] ; then
267 echo "FAILURE: Logging directory is not defined. Logs and report cannot be published!"
268 exit $EXIT_NO_TEST_REPORT_LOG_DIR
270 # remove TEST_REPORT_LOG_DIR if it exists
271 if [ -e $TEST_REPORT_LOG_DIR ] ; then
272 if [ -f $TEST_REPORT_LOG_DIR ] ; then
273 rm $TEST_REPORT_LOG_DIR
275 rm -rf ${TEST_REPORT_LOG_DIR}
278 # create TEST_REPORT_LOG_DIR
279 mkdir -p $TEST_REPORT_LOG_DIR
287 # enter workspace dir
293 # execute job based on passed parameter
296 echo "VSPERF verify job"
297 echo "================="
299 #execute_vsperf OVS_with_DPDK_and_vHost_User $1
304 echo "VSPERF merge job"
305 echo "================"
307 #execute_vsperf OVS_with_DPDK_and_vHost_User $1
312 echo "VSPERF daily job"
313 echo "================"
316 execute_vsperf OVS_with_DPDK_and_vHost_User $1
318 execute_vsperf OVS_vanilla $1
323 push_results_to_artifactory