Report: Add CentOS func tests
[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=""
28
29 JOB_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
30 LOG_ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
31 JOB_ARCHIVE_DIR="archive"
32 LOG_ARCHIVE_DIR="$WORKSPACE/archives"
33 mkdir -p ${JOB_ARCHIVE_DIR}
34 mkdir -p ${LOG_ARCHIVE_DIR}
35
36 # we will download the DPDK in the robot
37
38 WORKING_TOPOLOGY=""
39 export PYTHONPATH=${SCRIPT_DIR}
40
41 sudo apt-get -y update
42 sudo apt-get -y install libpython2.7-dev python-virtualenv
43
44 virtualenv --system-site-packages env
45 . env/bin/activate
46
47 echo pip install
48 pip install -r requirements.txt
49
50 # We iterate over available topologies and wait until we reserve topology
51 while :; do
52     for TOPOLOGY in ${TOPOLOGIES};
53     do
54         python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -t ${TOPOLOGY}
55         if [ $? -eq 0 ]; then
56             WORKING_TOPOLOGY=${TOPOLOGY}
57             echo "Reserved: ${WORKING_TOPOLOGY}"
58             break
59         fi
60     done
61
62     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
63         # Exit the infinite while loop if we made a reservation
64         break
65     fi
66
67     # Wait ~3minutes before next try
68     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
69     echo "Sleeping ${SLEEP_TIME}"
70     sleep ${SLEEP_TIME}
71 done
72
73 #for DPDK test, we don't need to install the VPP deb
74 function cancel_all {
75     python ${SCRIPT_DIR}/resources/tools/scripts/topo_reservation.py -c -t $1
76 }
77
78 # On script exit we cancel the reservation
79 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
80
81 # Based on job we will identify DUT
82 if [[ ${JOB_NAME} == *hc2vpp* ]] ;
83 then
84     DUT="hc2vpp"
85 elif [[ ${JOB_NAME} == *vpp* ]] ;
86 then
87     DUT="vpp"
88 elif [[ ${JOB_NAME} == *ligato* ]] ;
89 then
90     DUT="kubernetes"
91 elif [[ ${JOB_NAME} == *dpdk* ]] ;
92 then
93     DUT="dpdk"
94 else
95     echo "Unable to identify dut type based on JOB_NAME variable: ${JOB_NAME}"
96     exit 1
97 fi
98
99 case "$TEST_TAG" in
100     # run specific performance tests based on jenkins job type variable
101     VERIFY-PERF-MRR )
102         pybot ${PYBOT_ARGS} \
103               -L TRACE \
104               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
105               -s "tests.${DUT}.perf" \
106               -i mrrAND1t1cORmrrAND2t2c \
107               tests/
108         RETURN_STATUS=$(echo $?)
109         ;;
110     * )
111         # run full performance test suite and exit on fail
112         pybot ${PYBOT_ARGS} \
113               -L TRACE \
114               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
115               -s "tests.${DUT}.perf" \
116               tests/
117         RETURN_STATUS=$(echo $?)
118 esac
119
120 # Archive JOB artifacts in jenkins
121 for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do
122     cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/
123 done
124 # Archive JOB artifacts to logs.fd.io
125 for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do
126     cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/
127 done
128
129 exit ${RETURN_STATUS}