CSIT-18: Add GRE tunnel libraries and tests.
[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 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
68 if [ "${#}" -ne "0" ]; then
69     arr=(${@})
70     echo ${arr[0]}
71 else
72     rm -f *.deb
73     VPP_STABLE_VER="1.0.0-451~g686a5a5_amd64"
74     VPP_REPO_URL="https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp"
75     wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}.deb" || exit
76     wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}.deb" || exit
77     wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}.deb" || exit
78     wget -q "${VPP_REPO_URL}/vpp-dpdk-dev/${VPP_STABLE_VER}/vpp-dpdk-dev-${VPP_STABLE_VER}.deb" || exit
79     wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${VPP_STABLE_VER}/vpp-dpdk-dkms-${VPP_STABLE_VER}.deb" || exit
80     wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}.deb" || exit
81 fi
82
83 VPP_DEBS=(*.deb)
84 echo ${VPP_DEBS[@]}
85 VIRL_DIR_LOC="/tmp"
86 VPP_DEBS_FULL=(${VPP_DEBS[@]})
87
88 # Prepend directory location at remote host to deb file list
89 for index in "${!VPP_DEBS_FULL[@]}"; do
90     VPP_DEBS_FULL[${index}]=${VIRL_DIR_LOC}/${VPP_DEBS_FULL[${index}]}
91 done
92
93 echo "Updated file names: " ${VPP_DEBS_FULL[@]}
94
95 cat ${VIRL_PKEY}
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 env
148 . env/bin/activate
149
150 echo pip install
151 pip install -r requirements.txt
152
153 pykwalify -s resources/topology_schemas/3_node_topology.sch.yaml \
154           -s resources/topology_schemas/topology.sch.yaml \
155           -d topologies/enabled/topology.yaml \
156           -vvv
157
158 result=$?
159 if [ "${result}" -ne "0" ]; then
160     echo "Topology schema validation failed."
161     echo "However, the tests will start."
162 fi
163
164 PYTHONPATH=`pwd` pybot -L TRACE \
165     -v TOPOLOGY_PATH:topologies/enabled/topology.yaml \
166     --include vm_envAND3_node_single_link_topo \
167     --include vm_envAND3_node_double_link_topo \
168     --exclude PERFTEST \
169     --noncritical EXPECTED_FAILING \
170     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.