Update topology files after HW changes
[csit.git] / bootstrap-verify-perf-DPDK.sh
1 #!/bin/bash
2 # Copyright (c) 2016 Cisco and/or its affiliates.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 set -x
16
17 # Space separated list of available testbeds, described by topology files
18 TOPOLOGIES="topologies/available/lf_testbed1.yaml \
19             topologies/available/lf_testbed2.yaml \
20             topologies/available/lf_testbed3.yaml"
21
22 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23
24 # Reservation dir
25 RESERVATION_DIR="/tmp/reservation_dir"
26
27 PYBOT_ARGS="-W 150"
28
29 ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml)
30
31 # we will download the DPDK in the robot
32
33 WORKING_TOPOLOGY=""
34 export PYTHONPATH=${SCRIPT_DIR}
35
36 sudo apt-get -y update
37 sudo apt-get -y install libpython2.7-dev python-virtualenv
38
39 virtualenv --system-site-packages env
40 . env/bin/activate
41
42 echo pip install
43 pip install -r requirements.txt
44
45 # We iterate over available topologies and wait until we reserve topology
46 while :; do
47     for TOPOLOGY in ${TOPOLOGIES};
48     do
49         python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
50         if [ $? -eq 0 ]; then
51             WORKING_TOPOLOGY=${TOPOLOGY}
52             echo "Reserved: ${WORKING_TOPOLOGY}"
53             break
54         fi
55     done
56
57     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
58         # Exit the infinite while loop if we made a reservation
59         break
60     fi
61
62     # Wait ~3minutes before next try
63     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
64     echo "Sleeping ${SLEEP_TIME}"
65     sleep ${SLEEP_TIME}
66 done
67
68 #for DPDK test, we don't need to install the VPP deb
69 function cancel_all {
70     python ${SCRIPT_DIR}/resources/tools/topo_reservation.py -c -t $1
71 }
72
73 # On script exit we cancel the reservation
74 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
75
76 case "$TEST_TAG" in
77     # run specific performance tests based on jenkins job type variable
78     PERFTEST_LONG )
79         pybot ${PYBOT_ARGS} \
80               -L TRACE \
81               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
82               -v DPDK_TEST:True \
83               -s "dpdk-tests.perf" \
84               --exclude SKIP_PATCH \
85               -i NDRPDRDISC \
86               dpdk-tests/
87         RETURN_STATUS=$(echo $?)
88         ;;
89     PERFTEST_SHORT )
90         pybot ${PYBOT_ARGS} \
91               -L TRACE \
92               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
93               -v DPDK_TEST:True \
94               -s "dpdk-tests.perf" \
95               -i NDRCHK \
96               dpdk-tests/
97         RETURN_STATUS=$(echo $?)
98         ;;
99    PERFTEST_NIGHTLY )
100         #run all available tests
101         pybot ${PYBOT_ARGS} \
102               -L TRACE \
103               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
104               -v DPDK_TEST:True \
105               -s "dpdk-tests.perf" \
106               dpdk-tests/
107         RETURN_STATUS=$(echo $?)
108         ;;
109     * )
110         # run full performance test suite and exit on fail
111         pybot ${PYBOT_ARGS} \
112               -L TRACE \
113               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
114               -v DPDK_TEST:True \
115               -s "dpdk-tests.perf" \
116               dpdk-tests/
117         RETURN_STATUS=$(echo $?)
118 esac
119
120 # Pybot output post-processing
121 echo Post-processing test data...
122
123 python ${SCRIPT_DIR}/resources/tools/robot_output_parser.py \
124        -i ${SCRIPT_DIR}/output.xml \
125        -o ${SCRIPT_DIR}/output_perf_data.xml
126 if [ ! $? -eq 0 ]; then
127     echo "Parsing ${SCRIPT_DIR}/output.xml failed"
128 fi
129
130 # Archive artifacts
131 mkdir archive
132 for i in ${ARCHIVE_ARTIFACTS[@]}; do
133     cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
134 done
135
136 echo Post-processing finished.
137
138 exit ${RETURN_STATUS}