Fix of bootstrap.sh for vpp-csit-verify-virl job
[csit.git] / bootstrap.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 gQ4fwLsknyXSV6sxYyhkDW4PEwwcTU06uqce0AAzXVffxne0fMe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
60 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
68 if [ "${#}" -ne "0" ]; then
69     arr=(${@})
70     echo ${arr[0]}
71 else
72     rm -f *.deb
73     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp/1.0.0-229~gb1df169_amd64/vpp-1.0.0-229~gb1df169_amd64.deb" || exit
74     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dbg/1.0.0-229~gb1df169_amd64/vpp-dbg-1.0.0-229~gb1df169_amd64.deb" || exit
75     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dev/1.0.0-229~gb1df169_amd64/vpp-dev-1.0.0-229~gb1df169_amd64.deb" || exit
76     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dpdk-dev/1.0.0-229~gb1df169_amd64/vpp-dpdk-dev-1.0.0-229~gb1df169_amd64.deb" || exit
77     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dpdk-dkms/1.0.0-229~gb1df169_amd64/vpp-dpdk-dkms-1.0.0-229~gb1df169_amd64.deb" || exit
78     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-lib/1.0.0-229~gb1df169_amd64/vpp-lib-1.0.0-229~gb1df169_amd64.deb" || exit
79 fi
80
81 VPP_DEBS=(*.deb)
82 echo ${VPP_DEBS[@]}
83 VIRL_DIR_LOC="/tmp"
84 VPP_DEBS_FULL=(${VPP_DEBS[@]})
85
86 # Prepend directory location at remote host to deb file list
87 for index in "${!VPP_DEBS_FULL[@]}"; do
88     VPP_DEBS_FULL[${index}]=${VIRL_DIR_LOC}/${VPP_DEBS_FULL[${index}]}
89 done
90
91 echo "Updated file names: " ${VPP_DEBS_FULL[@]}
92
93 cat ${VIRL_PKEY}
94 # Copy the files to VIRL host
95 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no *.deb \
96     ${VIRL_USERNAME}@${VIRL_SERVER}:${VIRL_DIR_LOC}/
97
98 result=$?
99 if [ "${result}" -ne "0" ]; then
100     echo "Failed to copy vpp deb files to virl host"
101     echo ${result}
102     exit ${result}
103 fi
104
105 # Start a simulation on VIRL server
106 echo "Starting simulation on VIRL server"
107
108 function stop_virl_simulation {
109     ssh -i priv_key -o StrictHostKeyChecking=no ${VIRL_USERNAME}@${VIRL_SERVER}\
110         "/home/jenkins-in/testcase-infra/bin/stop-testcase ${VIRL_SID}"
111 }
112
113 VIRL_SID=$(ssh -i priv_key -o StrictHostKeyChecking=no \
114     ${VIRL_USERNAME}@${VIRL_SERVER} \
115     "/home/jenkins-in/testcase-infra/bin/start-testcase -c simple-ring ${VPP_DEBS_FULL[@]}")
116 retval=$?
117 if [ "$?" -ne "0" ]; then
118     echo "VIRL simulation start failed"
119     exit ${retval}
120 fi
121
122 if [[ ! "${VIRL_SID}" =~ session-[a-zA-Z0-9_]{6} ]]; then
123     echo "No VIRL session ID reported."
124     exit 127
125 fi
126
127 # Upon script exit, cleanup the simulation execution
128 trap stop_virl_simulation EXIT
129 echo ${VIRL_SID}
130
131 ssh_do ${VIRL_USERNAME}@${VIRL_SERVER} cat /scratch/${VIRL_SID}/topology.yaml
132
133 # Download the topology file from virl session
134 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no \
135     ${VIRL_USERNAME}@${VIRL_SERVER}:/scratch/${VIRL_SID}/topology.yaml \
136     topologies/enabled/topology.yaml
137
138 retval=$?
139 if [ "$?" -ne "0" ]; then
140     echo "Failed to copy topology file from VIRL simulation"
141     exit ${retval}
142 fi
143
144
145 virtualenv env
146 . env/bin/activate
147
148 echo pip install
149 pip install -r requirements.txt
150
151 PYTHONPATH=`pwd` pybot -L TRACE \
152     -v TOPOLOGY_PATH:topologies/enabled/topology.yaml \
153     --exclude 3_node_double_link_topoNOT3_node_single_link_topo \
154     --include VM_ENV \
155     --exclude PERFTEST \
156     --noncritical EXPECTED_FAILING \
157     tests/

©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.