Use files to store VPP stable build data
[csit.git] / bootstrap-vpp-verify-weekly.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 cat /etc/hostname
18 cat /etc/hosts
19
20 export DEBIAN_FRONTEND=noninteractive
21 sudo apt-get -y update
22 sudo apt-get -y install libpython2.7-dev python-virtualenv
23
24 function ssh_do() {
25     echo
26     echo "### "  ssh $@
27     ssh -i priv_key -o StrictHostKeyChecking=no $@
28 }
29
30 VIRL_SERVER=10.30.51.28
31 VIRL_USERNAME=jenkins-in
32 VIRL_PKEY=priv_key
33
34 rm -f ${VIRL_PKEY}
35 cat > ${VIRL_PKEY} <<EOF
36 -----BEGIN RSA PRIVATE KEY-----
37 MIIEpQIBAAKCAQEA+IHXq87GcqMR1C47rzx6Cbip5Ghq8pKrbqKrP5Nf41HcYrT6
38 GOXl9nFWKsMOzIlIn+8y7Il27eZh7csQGApbg8QLiHMtcYEmWNzKZpkqg4nuAPxX
39 VXwlKgnKX902SrET9Gp9TDayiHtCRWVfrlPPPSA0UEXW6BjLN/uHJ+W/Xzrrab+9
40 asBVa05vT2W6n0KJ66zfCaeDM912mQ6SttscAwFoWDmdHlegiVqrlIG2ABxOvxxz
41 L3dM3iSmlmQlzv9bThjo+nI4KFYh6m5wrZmAo5r/4q9CIJc21HVnTqkGOWJIZz6J
42 73lePJVSq5gYqaoGw3swFEA/MDkOx7baWKSoLQIDAQABAoIBAQCNBeolNp+JWJ76
43 gQ4fwLsknyXSV6sxYyhkDW4PEwwcTU06uqce0AAzXVffxne0fMe48x47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 cWsudXjMki8734WSpMBqBp/J8wG3C9ZS6IpQD+U7UXA+roB7Qr+j4TqtWfM+87Rh
61 maOpG56uAyR0w5Z9BhwzA3VakibVk9KwDgZ29WtKFzuATLFnOtCS46E=
62 -----END RSA PRIVATE KEY-----
63 EOF
64 chmod 600 priv_key
65
66 # Temporarily download VPP packages from nexus.fd.io
67 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
68
69 rm -f *.deb
70 if [ "${#}" -ne "0" ]; then
71     arr=(${@})
72     echo ${arr[0]}
73 else
74     VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_MASTER_STABLE_VER)
75     VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_MASTER_REPO_URL)
76     wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}.deb" || exit
77     wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}.deb" || exit
78     wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}.deb" || exit
79     wget -q "${VPP_REPO_URL}/vpp-dpdk-dev/${VPP_STABLE_VER}/vpp-dpdk-dev-${VPP_STABLE_VER}.deb" || exit
80     wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${VPP_STABLE_VER}/vpp-dpdk-dkms-${VPP_STABLE_VER}.deb" || exit
81     wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}.deb" || exit
82 fi
83
84 VPP_DEBS=(*.deb)
85 echo ${VPP_DEBS[@]}
86 VIRL_DIR_LOC="/tmp"
87 VPP_DEBS_FULL=(${VPP_DEBS[@]})
88
89 # Prepend directory location at remote host to deb file list
90 for index in "${!VPP_DEBS_FULL[@]}"; do
91     VPP_DEBS_FULL[${index}]=${VIRL_DIR_LOC}/${VPP_DEBS_FULL[${index}]}
92 done
93
94 echo "Updated file names: " ${VPP_DEBS_FULL[@]}
95
96 # Copy the files to VIRL host
97 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no *.deb \
98     ${VIRL_USERNAME}@${VIRL_SERVER}:${VIRL_DIR_LOC}/
99
100 result=$?
101 if [ "${result}" -ne "0" ]; then
102     echo "Failed to copy vpp deb files to virl host"
103     echo ${result}
104     exit ${result}
105 fi
106
107 # Start a simulation on VIRL server
108 echo "Starting simulation on VIRL server"
109
110 function stop_virl_simulation {
111     ssh -i priv_key -o StrictHostKeyChecking=no ${VIRL_USERNAME}@${VIRL_SERVER}\
112         "/home/jenkins-in/testcase-infra/bin/stop-testcase ${VIRL_SID}"
113 }
114
115 VIRL_SID=$(ssh -i priv_key -o StrictHostKeyChecking=no \
116     ${VIRL_USERNAME}@${VIRL_SERVER} \
117     "/home/jenkins-in/testcase-infra/bin/start-testcase -c double-ring-nested ${VPP_DEBS_FULL[@]}")
118 retval=$?
119 if [ "$?" -ne "0" ]; then
120     echo "VIRL simulation start failed"
121     exit ${retval}
122 fi
123
124 if [[ ! "${VIRL_SID}" =~ session-[a-zA-Z0-9_]{6} ]]; then
125     echo "No VIRL session ID reported."
126     exit 127
127 fi
128
129 # Upon script exit, cleanup the simulation execution
130 trap stop_virl_simulation EXIT
131 echo ${VIRL_SID}
132
133 ssh_do ${VIRL_USERNAME}@${VIRL_SERVER} cat /scratch/${VIRL_SID}/topology.yaml
134
135 # Download the topology file from virl session
136 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no \
137     ${VIRL_USERNAME}@${VIRL_SERVER}:/scratch/${VIRL_SID}/topology.yaml \
138     topologies/enabled/topology.yaml
139
140 retval=$?
141 if [ "$?" -ne "0" ]; then
142     echo "Failed to copy topology file from VIRL simulation"
143     exit ${retval}
144 fi
145
146
147 virtualenv --system-site-packages env
148 . env/bin/activate
149
150 echo pip install
151 pip install -r requirements.txt
152
153 # There are used three iterations of tests there to check
154 # the stability and reliability of the results
155
156 RC=0
157 MORE_FAILS=0
158
159 for test_set in 1 2 3
160 do
161     echo
162     echo ${test_set}. test loop
163     PYTHONPATH=`pwd` pybot -L TRACE \
164         -v TOPOLOGY_PATH:${SCRIPT_DIR}/topologies/enabled/topology.yaml \
165         --include vm_envAND3_node_single_link_topo \
166         --include vm_envAND3_node_double_link_topo \
167         --exclude PERFTEST \
168         --noncritical EXPECTED_FAILING \
169         --output log_test_set${test_set} \
170         tests/
171     PARTIAL_RC=$(echo $?)
172     if [ ${PARTIAL_RC} -eq 250 ]; then
173         MORE_FAILS=1
174     fi
175     RC=$((RC+PARTIAL_RC))
176 done
177
178 # Log the final result
179 if [ ${RC} -eq 0 ]; then
180     set +x
181     echo
182     echo "=============================================================================="
183     echo "Final result of all test loops:                                       | PASS |"
184     echo "All critical tests have passed."
185     echo "=============================================================================="
186     echo
187     set -x
188 elif [ ${MORE_FAILS} -eq 0 ]; then
189     if [ ${RC} -eq 1 ]; then
190         HLP_STR="test has"
191     else
192         HLP_STR="tests have"
193     fi
194     set +x
195     echo
196     echo "=============================================================================="
197     echo "Final result of all test loops:                                       | FAIL |"
198     echo "${RC} critical ${HLP_STR} failed."
199     echo "=============================================================================="
200     echo
201     set -x
202 else
203     set +x
204     echo
205     echo "=============================================================================="
206     echo "Final result of all test loops:                                       | FAIL |"
207     echo "More then 250 critical tests have failed in one test loop."
208     echo "=============================================================================="
209     echo
210     set -x
211 fi
212
213 echo Post-processing test data...
214
215 # Rebot output post-processing
216 rebot --output output.xml ./log_test_set1.xml ./log_test_set2.xml ./log_test_set3.xml
217
218 # Remove unnecessary log files
219 rm -f ./log_test_set1.xml ./log_test_set2.xml ./log_test_set3.xml
220
221 echo Post-processing finished.
222
223 if [ ${RC} -eq 0 ]; then
224     RETURN_STATUS=0
225 else
226     RETURN_STATUS=1
227 fi
228
229 exit ${RETURN_STATUS}

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.