CIMANAGE-5: update bootstrap for csit-vpp-verify-weekly job
[csit.git] / bootstrap-verify-perf.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_testbed2-710-520.yaml"
19 VPP_STABLE_VER="1.0.0-437~g8f15e92_amd64"
20 VPP_REPO_URL="https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp"
21
22 # Reservation dir
23 RESERVATION_DIR="/tmp/reservation_dir"
24 INSTALLATION_DIR="/tmp/install_dir"
25
26 PYBOT_ARGS="--noncritical MULTI_THREAD"
27
28 # If we run this script from CSIT jobs we want to use stable vpp version
29 if [[ ${JOB_NAME} == csit-* ]] ;
30 then
31     mkdir vpp_download
32     cd vpp_download
33     #download vpp build from nexus and set VPP_DEBS variable
34     wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}.deb" || exit
35     wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}.deb" || exit
36     wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}.deb" || exit
37     wget -q "${VPP_REPO_URL}/vpp-dpdk-dev/${VPP_STABLE_VER}/vpp-dpdk-dev-${VPP_STABLE_VER}.deb" || exit
38     wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${VPP_STABLE_VER}/vpp-dpdk-dkms-${VPP_STABLE_VER}.deb" || exit
39     wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}.deb" || exit
40     VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )"
41     PYBOT_ARGS="${PYBOT_ARGS} --exitonfailure"
42     cd ..
43
44 # If we run this script from vpp project we want to use local build
45 elif [[ ${JOB_NAME} == vpp-* ]] ;
46 then
47     #use local packages provided as argument list
48     # Jenkins VPP deb paths (convert to full path)
49     VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )"
50 else
51     echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}"
52     exit 1
53 fi
54
55 CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
56 WORKING_TOPOLOGY=""
57 export PYTHONPATH=${CUR_DIR}
58
59 sudo apt-get -y update
60 sudo apt-get -y install libpython2.7-dev python-virtualenv
61
62 virtualenv env
63 . env/bin/activate
64
65 echo pip install
66 pip install -r requirements.txt
67
68 # We iterate over available topologies and wait until we reserve topology
69 while :; do
70     for TOPOLOGY in ${TOPOLOGIES};
71     do
72         python ${CUR_DIR}/resources/tools/topo_reservation.py -t ${TOPOLOGY}
73         if [ $? -eq 0 ]; then
74             WORKING_TOPOLOGY=${TOPOLOGY}
75             echo "Reserved: ${WORKING_TOPOLOGY}"
76             break
77         fi
78     done
79
80     if [ ! -z "${WORKING_TOPOLOGY}" ]; then
81         # Exit the infinite while loop if we made a reservation
82         break
83     fi
84
85     # Wait ~3minutes before next try
86     SLEEP_TIME=$[ ( $RANDOM % 20 ) + 180 ]s
87     echo "Sleeping ${SLEEP_TIME}"
88     sleep ${SLEEP_TIME}
89 done
90
91 function cancel_all {
92     python ${CUR_DIR}/resources/tools/topo_installation.py -c -d ${INSTALLATION_DIR} -t $1
93     python ${CUR_DIR}/resources/tools/topo_reservation.py -c -t $1
94 }
95
96 # On script exit we cancel the reservation and installation and delete all vpp
97 # packages
98 trap "cancel_all ${WORKING_TOPOLOGY}" EXIT
99
100 python ${CUR_DIR}/resources/tools/topo_installation.py -t ${WORKING_TOPOLOGY} \
101                                                        -d ${INSTALLATION_DIR} \
102                                                        -p ${VPP_DEBS}
103 if [ $? -eq 0 ]; then
104     echo "VPP Installed on hosts from: ${WORKING_TOPOLOGY}"
105 else
106     echo "Failed to copy vpp deb files to DUTs"
107     exit 1
108 fi
109
110 case "$TEST_TAG" in
111     # run specific performance tests based on jenkins job type variable
112     PERFTEST_LONG )
113         pybot -L TRACE \
114               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
115               -i perftest_long \
116               tests/
117         ;;
118     PERFTEST_SHORT )
119         pybot -L TRACE \
120               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
121               -i perftest_short \
122               tests/
123         ;;
124     PERFTEST_LONG_BRIDGE )
125         pybot -L TRACE \
126               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
127               -s performance.long_bridge_domain \
128               tests/
129         ;;
130     PERFTEST_LONG_IPV4 )
131         pybot -L TRACE \
132               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
133               -s performance.long_ipv4 \
134               tests/
135         ;;
136     PERFTEST_LONG_IPV6 )
137         pybot -L TRACE \
138               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
139               -s performance.long_ipv6 \
140               tests/
141         ;;
142     PERFTEST_LONG_XCONNECT )
143         pybot -L TRACE \
144               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
145               -s performance.long_xconnect \
146               tests/
147         ;;
148     * )
149         # run full performance test suite and exit on fail
150         pybot ${PYBOT_ARGS} \
151               -L TRACE \
152               -v TOPOLOGY_PATH:${WORKING_TOPOLOGY} \
153               -s performance \
154               tests/
155 esac
156