CI: update build-vsperf.sh script
[vswitchperf.git] / ci / build-vsperf.sh
1 #!/bin/bash
2 #
3 # Copyright 2015 Intel Corporation.
4 #
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
8 #
9 #   http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 # VSPERF nightly build execution script
18
19 # Usage:
20 #       build-vsperf.sh job_type
21 #   where job_type is one of "verify", "merge", "daily"
22
23 #
24 # configuration
25 #
26
27 EXIT=0
28 VSPERF_BIN='./vsperf'
29 LOG_FILE_USER='/tmp/vsperf_user.log'
30 LOG_FILE_VANILLA='/tmp/vsperf_vanilla.log'
31 LOG_FILE_PREFIX="/tmp/vsperf_build_"
32 OPNFV_POD="intel-pod3"
33
34 # CI job specific configuration
35 # VERIFY - run basic set of TCs with default settings
36 TESTCASES_VERIFY="phy2phy_tput pvp_tput"
37 TESTPARAM_VERIFY=""
38 # MERGE - run selected TCs with default settings
39 TESTCASES_MERGE="phy2phy_tput back2back phy2phy_cont pvp_tput pvvp_tput"
40 TESTPARAM_MERGE=""
41 # DAILY - run selected TCs for defined packet sizes
42 TESTCASES_DAILY='phy2phy_tput back2back phy2phy_tput_mod_vlan phy2phy_scalability pvp_tput pvp_back2back pvvp_tput pvvp_back2back'
43 TESTPARAM_DAILY='--test-params pkt_sizes=64,128,512,1024,1518'
44 # check if user config file exists if not then we will use default settings
45 [ -f $HOME/vsperf.conf ] && CONF_FILE="--conf-file ${HOME}/vsperf.conf" || CONF_FILE=""
46
47 #
48 # functions
49 #
50
51 # check and print testcase execution status
52 # parameters:
53 #   $1 - directory with results
54 function print_results() {
55     for i in $TESTCASES ; do
56         if [[ $i == *"pvp"* ]]; then
57             DEPLOYMENT="pvp"
58         elif [[ $i == *"pvvp"* ]]; then
59             DEPLOYMENT="pvvp"
60         else
61             DEPLOYMENT="p2p"
62         fi
63         RES_FILE="result_${i}_${DEPLOYMENT}.csv"
64
65         if [ -e "${1}/${RES_FILE}" ]; then
66             printf "    %-70s %-6s\n" $RES_FILE "OK"
67         else
68             printf "    %-70s %-6s\n" $RES_FILE "FAILED"
69             EXIT=1
70         fi
71     done
72 }
73
74 # execute tests and display results
75 # parameters:
76 #   $1 - vswitch and vnf combination, one of OVS_vanilla, OVS_with_DPDK_and_vHost_Cuse, OVS_with_DPDK_and_vHost_User
77 #   $2 - CI job type, one of verify, merge, daily
78 function execute_vsperf() {
79     # figure out log file name
80     LOG_FILE="${LOG_FILE_PREFIX}"`date "+%Y%m%d_%H%M%S%N"`".log"
81
82     # figure out list of TCs and execution parameters
83     case $2 in
84         "verify")
85             TESTPARAM=$TESTPARAM_VERIFY
86             TESTCASES=$TESTCASES_VERIFY
87             ;;
88         "merge")
89             TESTPARAM=$TESTPARAM_MERGE
90             TESTCASES=$TESTCASES_MERGE
91             ;;
92         *)
93             # by default use daily build
94             TESTPARAM=$TESTPARAM_DAILY
95             TESTCASES=$TESTCASES_DAILY
96             ;;
97     esac
98
99     # execute testcases
100     echo -e "\nExecution of VSPERF for $1"
101     # vsperf must be executed directly from vsperf directory
102     cd ..
103     case $1 in
104         "OVS_vanilla")
105             echo "$VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE"
106             $VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
107             ;;
108         "OVS_with_DPDK_and_vHost_Cuse")
109             echo "$VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostCuse $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE"
110             $VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostCuse $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
111             ;;
112         *)
113             echo "$VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES > $LOG_FILE"
114             $VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsVanilla --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
115             ;;
116     esac
117     # let's go back to CI dir
118     cd -
119
120     # evaluation of results
121     echo -e "\nResults for $1"
122     RES_DIR=`grep "Creating result directory" $LOG_FILE | cut -d'/' -f2-`
123     if [ "x" == "x${RES_DIR}" ] ; then
124         echo "FAILURE: Results are not available."
125     else
126         print_results "/${RES_DIR}"
127     fi
128 }
129
130 #
131 # main
132 #
133
134 # execute job based on passed parameter
135 case $1 in
136     "verify")
137         echo "VSPERF verify job"
138         echo "================="
139
140         #execute_vsperf OVS_with_DPDK_and_vHost_User $1
141
142         exit $EXIT
143         ;;
144     "merge")
145         echo "VSPERF merge job"
146         echo "================"
147
148         #execute_vsperf OVS_with_DPDK_and_vHost_User $1
149
150         exit $EXIT
151         ;;
152     *)
153         echo "VSPERF daily job"
154         echo "================"
155
156         execute_vsperf OVS_with_DPDK_and_vHost_User $1
157         execute_vsperf OVS_vanilla $1
158
159         exit $EXIT
160         ;;
161 esac
162
163 exit $EXIT
164
165 #
166 # end
167 #