summaryrefslogtreecommitdiffstats
path: root/ci/build-vsperf.sh
blob: e08dd3575db0fc442a8143488586f60ae73fcc44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/bash
#
# Copyright 2015 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# VSPERF nightly build execution script

# Usage:
#       build-vsperf.sh job_type
#   where job_type is one of "verify", "merge", "daily"

#
# configuration
#

EXIT=0
VSPERF_BIN='./vsperf'
LOG_FILE_USER='/tmp/vsperf_user.log'
LOG_FILE_VANILLA='/tmp/vsperf_vanilla.log'
LOG_FILE_PREFIX="/tmp/vsperf_build_"
OPNFV_POD="intel-pod3"

# CI job specific configuration
# VERIFY - run basic set of TCs with default settings
TESTCASES_VERIFY="phy2phy_tput pvp_tput"
TESTPARAM_VERIFY=""
# MERGE - run selected TCs with default settings
TESTCASES_MERGE="phy2phy_tput back2back phy2phy_cont pvp_tput pvvp_tput"
TESTPARAM_MERGE=""
# DAILY - run selected TCs for defined packet sizes
TESTCASES_DAILY='phy2phy_tput back2back phy2phy_tput_mod_vlan phy2phy_scalability pvp_tput pvp_back2back pvvp_tput pvvp_back2back'
TESTPARAM_DAILY='--test-params pkt_sizes=64,128,512,1024,1518'
# check if user config file exists if not then we will use default settings
[ -f $HOME/vsperf.conf ] && CONF_FILE="--conf-file ${HOME}/vsperf.conf" || CONF_FILE=""

#
# functions
#

# terminate vsperf and all its utilities
# it is expected that vsperf is the only python3 app
# and no other ovs or qemu instances are running
# at CI machine
# parameters:
#   none
function terminate_vsperf() {
    sudo pkill stress &> /dev/null
    sudo pkill python3 &> /dev/null
    sudo killall -9 qemu-system-x86_64 &> /dev/null

    # sometimes qemu resists to terminate, so wait a bit and kill it again
    if pgrep qemu-system-x86_64 &> /dev/null ; then
        sleep 5
        sudo killall -9 qemu-system-x86_64 &> /dev/null
        sleep 5
    fi

    sudo pkill ovs-vswitchd &> /dev/null
    sleep 1
    sudo pkill ovsdb-server &> /dev/null
    sleep 1
}

# check and print testcase execution status
# parameters:
#   $1 - directory with results
function print_results() {
    for i in $TESTCASES ; do
        if [[ $i == *"pvp"* ]]; then
            DEPLOYMENT="pvp"
        elif [[ $i == *"pvvp"* ]]; then
            DEPLOYMENT="pvvp"
        else
            DEPLOYMENT="p2p"
        fi
        RES_FILE="result_${i}_${DEPLOYMENT}.csv"

        if [ -e "${1}/${RES_FILE}" ]; then
            printf "    %-70s %-6s\n" $RES_FILE "OK"
        else
            printf "    %-70s %-6s\n" $RES_FILE "FAILED"
            EXIT=1
        fi
    done
}

# execute tests and display results
# parameters:
#   $1 - vswitch and vnf combination, one of OVS_vanilla, OVS_with_DPDK_and_vHost_Cuse, OVS_with_DPDK_and_vHost_User
#   $2 - CI job type, one of verify, merge, daily
function execute_vsperf() {
    # figure out log file name
    LOG_FILE="${LOG_FILE_PREFIX}"`date "+%Y%m%d_%H%M%S%N"`".log"

    # figure out list of TCs and execution parameters
    case $2 in
        "verify")
            TESTPARAM=$TESTPARAM_VERIFY
            TESTCASES=$TESTCASES_VERIFY
            ;;
        "merge")
            TESTPARAM=$TESTPARAM_MERGE
            TESTCASES=$TESTCASES_MERGE
            ;;
        *)
            # by default use daily build
            TESTPARAM=$TESTPARAM_DAILY
            TESTCASES=$TESTCASES_DAILY
            ;;
    esac

    # execute testcases
    echo -e "\nExecution of VSPERF for $1"
    # vsperf must be executed directly from vsperf directory
    cd ..
    case $1 in
        "OVS_vanilla")
            echo "$VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE"
            $VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsVanilla --vnf QemuVirtioNet $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
            ;;
        "OVS_with_DPDK_and_vHost_Cuse")
            echo "$VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostCuse $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE"
            $VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostCuse $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
            ;;
        *)
            echo "$VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES > $LOG_FILE"
            $VSPERF_BIN --opnfvpod="$OPNFV_POD" --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES &> $LOG_FILE
            ;;
    esac
    # let's go back to CI dir
    cd -

    # evaluation of results
    echo -e "\nResults for $1"
    RES_DIR=`grep "Creating result directory" $LOG_FILE | cut -d'/' -f2-`
    if [ "x" == "x${RES_DIR}" ] ; then
        echo "FAILURE: Results are not available."
    else
        print_results "/${RES_DIR}"
    fi

    # show detailed result figures
    for md_file in $(grep '\.md"$' $LOG_FILE | cut -d'"' -f2); do
        # TC resut file header
        echo -e "\n-------------------------------------------------------------------"
        echo -e " $md_file"
        echo -e "-------------------------------------------------------------------\n"
        # TC details
        sed -n '/^- Test ID/,/Bidirectional/{/Packet size/b;p;/Bidirectional/q};/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file
        # TC results
        sed -n '/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file | grep -v "Unknown" | cat -s
    done
}

#
# main
#

# execute job based on passed parameter
case $1 in
    "verify")
        echo "VSPERF verify job"
        echo "================="

        #execute_vsperf OVS_with_DPDK_and_vHost_User $1

        exit $EXIT
        ;;
    "merge")
        echo "VSPERF merge job"
        echo "================"

        #execute_vsperf OVS_with_DPDK_and_vHost_User $1

        exit $EXIT
        ;;
    *)
        echo "VSPERF daily job"
        echo "================"

        terminate_vsperf
        execute_vsperf OVS_with_DPDK_and_vHost_User $1
        terminate_vsperf
        execute_vsperf OVS_vanilla $1
        terminate_vsperf

        exit $EXIT
        ;;
esac

exit $EXIT

#
# end
#