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 ght (c) 2016 Cisco and/or its affiliates.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not usecopy of the License at:
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
24 export DEBIAN_FRONTEND=noninteractive
25 sudo apt-get -y update
26 sudo apt-get -y install libpython2.7-dev python-virtualenv
28 PYBOT_ARGS="--noncritical MULTI_THREAD"
30 ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
32 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
33 export PYTHONPATH=${SCRIPT_DIR}
36 # 1st step: Download and prepare VPP packages
38 # Temporarily download VPP packages from nexus.fd.io
40 if [ "${#}" -ne "0" ]; then
44 # Download the latest VPP build .deb install packages
45 echo Downloading VPP packages...
46 bash ${SCRIPT_DIR}/resources/tools/download_install_vpp_pkgs.sh --skip-install
52 VPP_VER=$(echo ${VPP_DEBS#vpp-})
53 VPP_VER=$(echo ${VPP_VER%-deb.deb})
56 echo "****************************************************************************************************************************************"
57 echo "1st step: Download VPP packages FINISHED"
58 echo "VPP version to be tested: ${VPP_VER}"
59 echo "****************************************************************************************************************************************"
63 # 2nd step: Start virtual env and install requirements
65 echo Starting virtual env...
66 virtualenv --system-site-packages env
69 echo Installing requirements...
70 pip install -r ${SCRIPT_DIR}/requirements.txt
73 echo "****************************************************************************************************************************************"
74 echo "2nd step: Start virtual env and install requirements FINISHED"
75 echo "****************************************************************************************************************************************"
79 # 3rd step: Prepare VIRL system
80 echo Preparing VIRL system...
82 VIRL_SERVERS=("10.30.51.28" "10.30.51.29" "10.30.51.30")
85 VIRL_USERNAME=jenkins-in
87 VIRL_SERVER_STATUS_FILE="status"
88 VIRL_SERVER_EXPECTED_STATUS="PRODUCTION"
90 VIRL_TOPOLOGY=double-ring-nested.xenial
91 VIRL_RELEASE=csit-ubuntu-16.04.1_2016-12-19_1.6
93 SSH_OPTIONS="-i ${VIRL_PKEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o LogLevel=error"
102 cat > ${VIRL_PKEY} <<EOF
103 -----BEGIN RSA PRIVATE KEY-----
104 MIIEpQIBAAKCAQEA+IHXq87GcqMR1C47rzx6Cbip5Ghq8pKrbqKrP5Nf41HcYrT6
105 GOXl9nFWKsMOzIlIn+8y7Il27eZh7csQGApbg8QLiHMtcYEmWNzKZpkqg4nuAPxX
106 VXwlKgnKX902SrET9Gp9TDayiHtCRWVfrlPPPSA0UEXW6BjLN/uHJ+W/Xzrrab+9
107 asBVa05vT2W6n0KJ66zfCaeDM912mQ6SttscAwFoWDmdHlegiVqrlIG2ABxOvxxz
108 L3dM3iSmlmQlzv9bThjo+nI4KFYh6m5wrZmAo5r/4q9CIJc21HVnTqkGOWJIZz6J
109 73lePJVSq5gYqaoGw3swFEA/MDkOx7baWKSoLQIDAQABAoIBAQCNBeolNp+JWJ76
110 gQ4fwLsknyXSV6sxYyhkDW4PEwwcTU06uqce0AAzXVffxne0fMe48x47+zqBgPbb
111 4huM+Pu8B9nfojUMr5TaYtl9Zbgpk3F8H7dT7LKOa6XrxvZTZrADSRc30+Z26zPN
112 e9zTaf42Gvt0/l0Zs1BHwbaOXqO+XuwJ3/F9Sf3PQYWXD3EOWjpHDP/X/1vAs6lV
113 SLkm6J/9KKE1m6I6LTYjIXuYt4SXybW6N2TSy54hhQtYcDUnIU2hR/PHVWKrGA0J
114 kELgrtTNTdbML27O5gFWU4PLUEYTZ9fN11D6qUZKxLcPOiPPHXkiILMRCCnG5DYI
115 ksBAU/YlAoGBAPxZO9VO18TYc8THV1nLKcvT2+1oSs1UcA2wNQMU55t910ZYinRa
116 MRwUhMOf8Mv5wOeiZaRICQB1PnVWtDVmGECgPpK6jUxqAwn8rgJcnoafLGL5YKMY
117 RVafTe6N5LXgCaOcJrk21wxs6v7ninEbUxxc575urOvZMBkymDw91dwbAoGBAPwa
118 YRhKhrzFKZzdK0RadVjnxKvolUllpoqqg3XuvmeAJHAOAnaOgVWq68NAcp5FZJv0
119 2D2Up7TX8pjf9MofP1SJbcraKBpK4NzfNkA0dSdEi+FhVofAJ9umB2o5LW1n7sab
120 UIrjsdzSJK/9Zb9yTTHPyibYzNEgaJV1HsbxfEFXAoGAYO2RmvRm0phll18OQVJV
121 IpKk9kLKAKZ/R/K32hAsikBC8SVPQTPniyaifFWx81diblalff2hX4ipTf7Yx24I
122 wMIMZuW7Im/R7QMef4+94G3Bad7p7JuE/qnAEHJ2OBnu+eYfxaK35XDsrq6XMazS
123 NqHE7hOq3giVfgg+C12hCKMCgYEAtu9dbYcG5owbehxzfRI2/OCRsjz/t1bv1seM
124 xVMND4XI6xb/apBWAZgZpIFrqrWoIBM3ptfsKipZe91ngBPUnL9s0Dolx452RVAj
125 yctHB8uRxWYgqDkjsxtzXf1HnZBBkBS8CUzYj+hdfuddoeKLaY3invXLCiV+PpXS
126 U4KAK9kCgYEAtSv0m5+Fg74BbAiFB6kCh11FYkW94YI6B/E2D/uVTD5dJhyEUFgZ
127 cWsudXjMki8734WSpMBqBp/J8wG3C9ZS6IpQD+U7UXA+roB7Qr+j4TqtWfM+87Rh
128 maOpG56uAyR0w5Z9BhwzA3VakibVk9KwDgZ29WtKFzuATLFnOtCS46E=
129 -----END RSA PRIVATE KEY-----
131 chmod 600 ${VIRL_PKEY}
134 # Pick a random host from the array of VIRL servers, and attempt
135 # to reach it and verify it's status.
137 # The server must be reachable, and have a "status" file with
138 # the content "PRODUCTION", to be selected.
140 # If the server is not reachable, or does not have the correct
141 # status, remove it from the array and start again.
143 # Abort if there are no more servers left in the array.
145 while [[ ! "$VIRL_SERVER" ]]
147 num_hosts=${#VIRL_SERVERS[@]}
148 if [ $num_hosts == 0 ]
150 echo "No more VIRL candidate hosts available, failing."
153 element=$[ $RANDOM % $num_hosts ]
154 virl_server_candidate=${VIRL_SERVERS[$element]}
155 virl_server_status=$(ssh ${SSH_OPTIONS} ${VIRL_USERNAME}@${virl_server_candidate} cat $VIRL_SERVER_STATUS_FILE 2>&1)
156 echo VIRL HOST $virl_server_candidate status is \"$virl_server_status\"
157 if [ "$virl_server_status" == "$VIRL_SERVER_EXPECTED_STATUS" ]
159 # Candidate is in good status. Select this server.
160 VIRL_SERVER="$virl_server_candidate"
162 # Candidate is in bad status. Remove from array.
163 VIRL_SERVERS=("${VIRL_SERVERS[@]:0:$element}" "${VIRL_SERVERS[@]:$[$element+1]}")
169 VPP_DEBS_VIRL=(${VPP_DEBS[@]})
171 # Prepend directory location at remote host to deb file list
172 for index in "${!VPP_DEBS_VIRL[@]}"; do
173 VPP_DEBS_VIRL[${index}]=${VIRL_DIR_LOC}/${VPP_DEBS_VIRL[${index}]}
176 echo "Updated file names: " ${VPP_DEBS_VIRL[@]}
179 # Copy the files to VIRL host
180 scp ${SSH_OPTIONS} *.deb \
181 ${VIRL_USERNAME}@${VIRL_SERVER}:${VIRL_DIR_LOC}/
184 if [ "${result}" -ne "0" ]; then
185 echo "Failed to copy vpp deb files to virl host"
190 # Start a simulation on VIRL server
191 echo "Starting simulation on VIRL server"
193 function stop_virl_simulation {
194 ssh ${SSH_OPTIONS} ${VIRL_USERNAME}@${VIRL_SERVER}\
195 "stop-testcase ${VIRL_SID}"
198 VIRL_SID=$(ssh ${SSH_OPTIONS} \
199 ${VIRL_USERNAME}@${VIRL_SERVER} \
200 "start-testcase -c ${VIRL_TOPOLOGY} -r ${VIRL_RELEASE} ${VPP_DEBS_VIRL[@]}")
202 if [ ${retval} -ne "0" ]; then
203 echo "VIRL simulation start failed"
207 if [[ ! "${VIRL_SID}" =~ session-[a-zA-Z0-9_]{6} ]]; then
208 echo "No VIRL session ID reported."
212 # Upon script exit, cleanup the VIRL simulation execution
213 trap stop_virl_simulation EXIT
216 ssh_do ${VIRL_USERNAME}@${VIRL_SERVER} cat /scratch/${VIRL_SID}/topology.yaml
218 # Download the topology file from VIRL session
220 ${VIRL_USERNAME}@${VIRL_SERVER}:/scratch/${VIRL_SID}/topology.yaml \
221 topologies/enabled/topology_VIRL.yaml
224 if [ ${retval} -ne "0" ]; then
225 echo "Failed to copy topology file from VIRL simulation"
230 echo "****************************************************************************************************************************************"
231 echo "3rd step: Start the simulation on the VIRL server FINISHED"
232 echo "****************************************************************************************************************************************"
236 # 4th step: Run functional test suites
241 echo Running functional tests on the VIRL system...
243 # There are used three iterations of functional tests there
244 # to check the stability and reliability of the results.
245 for test_set in 1 2 3
248 echo Functional test loop: ${test_set}
251 pybot -L TRACE -W 136\
252 -v TOPOLOGY_PATH:${SCRIPT_DIR}/topologies/enabled/topology_VIRL.yaml \
253 --suite "tests.func" \
254 --include vm_envAND3_node_single_link_topo \
255 --include vm_envAND3_node_double_link_topo \
257 --noncritical EXPECTED_FAILING \
258 --output log_func_test_set${test_set} \
260 PARTIAL_RC=$(echo $?)
261 if [ ${PARTIAL_RC} -eq 250 ]; then
264 RC=$((RC+PARTIAL_RC))
268 echo "****************************************************************************************************************************************"
269 echo "4th step: Run functional tests FINISHED"
270 echo "****************************************************************************************************************************************"
273 # Set RETURN_STATUS=1 if some critical test failed
274 if [ ! ${RC} -eq 0 ]; then
278 # Log the final result
279 if [ ${RC} -eq 0 ]; then
282 echo "========================================================================================================================================"
283 echo "Final result of all test loops: | PASS |"
284 echo "All critical tests have passed."
285 echo "========================================================================================================================================"
288 elif [ ${MORE_FAILS} -eq 0 ]; then
289 if [ ${RC} -eq 1 ]; then
296 echo "========================================================================================================================================"
297 echo "Final result of all test loops: | FAIL |"
298 echo "${RC} critical ${HLP_STR} failed."
299 echo "========================================================================================================================================"
305 echo "========================================================================================================================================"
306 echo "Final result of all test loops: | FAIL |"
307 echo "More then 250 critical tests have failed in one test loop."
308 echo "========================================================================================================================================"
313 # 7th step: Post-processing test data
314 echo Post-processing test data...
316 # Rebot output post-processing
317 rebot --noncritical EXPECTED_FAILING \
318 --output output.xml \
319 ./log_func_test_set1.xml ./log_func_test_set2.xml ./log_func_test_set3.xml
321 # Remove unnecessary files
322 rm -f ./log_test_set1.xml ./log_test_set2.xml ./log_test_set3.xml
326 for i in ${ARCHIVE_ARTIFACTS[@]}; do
327 cp $( readlink -f ${i} | tr '\n' ' ' ) archive/
330 echo Post-processing finished.
332 exit ${RETURN_STATUS}