Add with-statment support to VatTerminal.
[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 echo | sudo tee -a /etc/hostname
18 echo "127.0.0.1 `cat /etc/hostname` " | sudo tee -a /etc/hosts
19
20 cat /etc/hostname
21 cat /etc/hosts
22
23 export DEBIAN_FRONTEND=noninteractive
24 sudo apt-get -y update
25 sudo apt-get -y install libpython2.7-dev python-virtualenv
26
27 #VIRL_VMS="10.30.51.53,10.30.51.51,10.30.51.52"
28 #IFS=',' read -ra ADDR <<< "${VIRL_VMS}"
29 #
30
31 function ssh_do() {
32     echo
33     echo "### "  ssh $@
34     ssh -i priv_key -o StrictHostKeyChecking=no $@
35 }
36
37 #for addr in "${ADDR[@]}"; do
38 #    echo
39 #    echo ${addr}
40 #    echo
41 #
42 #    ssh_do cisco@${addr} hostname || true
43 #    ssh_do cisco@${addr} "ifconfig -a" || true
44 #    ssh_do cisco@${addr} "lspci -Dnn | grep 0200" || true
45 #    ssh_do cisco@${addr} "free -m" || true
46 #    ssh_do cisco@${addr} "cat /proc/meminfo" || true
47 #    ssh_do cisco@${addr} "dpkg -l vpp\*" || true
48 #    ssh_do cisco@${addr} "lshw -c network" || true
49 #    ssh_do cisco@${addr} "sudo -S sh -c 'echo exec show  hardware | vpp_api_test '"
50 #done
51
52 VIRL_SERVER=10.30.51.28
53 VIRL_USERNAME=jenkins-in
54 VIRL_PKEY=priv_key
55
56 rm -f ${VIRL_PKEY}
57 cat > ${VIRL_PKEY} <<EOF
58 -----BEGIN RSA PR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7sab
75 UIrjsdzSJK/9Zb9yTTHPyibYzNEgaJV1HsbxfEFXAoGAYO2RmvRm0phll18OQVJV
76 IpKk9kLKAKZ/R/K32hAsikBC8SVPQTPniyaifFWx81diblalff2hX4ipTf7Yx24I
77 wMIMZuW7Im/R7QMef4+94G3Bad7p7JuE/qnAEHJ2OBnu+eYfxaK35XDsrq6XMazS
78 NqHE7hOq3giVfgg+C12hCKMCgYEAtu9dbYcG5owbehxzfRI2/OCRsjz/t1bv1seM
79 xVMND4XI6xb/apBWAZgZpIFrqrWoIBM3ptfsKipZe91ngBPUnL9s0Dolx452RVAj
80 yctHB8uRxWYgqDkjsxtzXf1HnZBBkBS8CUzYj+hdfuddoeKLaY3invXLCiV+PpXS
81 U4KAK9kCgYEAtSv0m5+Fg74BbAiFB6kCh11FYkW94YI6B/E2D/uVTD5dJhyEUFgZ
82 cWsudXjMki8734WSpMBqBp/J8wG3C9ZS6IpQD+U7UXA+roB7Qr+j4TqtWfM+87Rh
83 maOpG56uAyR0w5Z9BhwzA3VakibVk9KwDgZ29WtKFzuATLFnOtCS46E=
84 -----END RSA PRIVATE KEY-----
85 EOF
86 chmod 600 priv_key
87
88 # Temporarily download VPP packages from nexus.fd.io
89
90 rm -f *.deb
91 if [ "${#}" -ne "0" ]; then
92     echo "let's use the parameters"
93     arr=(${@})
94     echo ${arr[0]}
95 else
96     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp/1.0.0-185~gca0f3b3_amd64/vpp-1.0.0-185~gca0f3b3_amd64.deb" || exit
97     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dbg/1.0.0-185~gca0f3b3_amd64/vpp-dbg-1.0.0-185~gca0f3b3_amd64.deb" || exit
98     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dev/1.0.0-185~gca0f3b3_amd64/vpp-dev-1.0.0-185~gca0f3b3_amd64.deb" || exit
99     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dpdk-dev/1.0.0-185~gca0f3b3_amd64/vpp-dpdk-dev-1.0.0-185~gca0f3b3_amd64.deb" || exit
100     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-dpdk-dkms/1.0.0-185~gca0f3b3_amd64/vpp-dpdk-dkms-1.0.0-185~gca0f3b3_amd64.deb" || exit
101     wget -q "https://nexus.fd.io/service/local/repositories/fd.io.dev/content/io/fd/vpp/vpp-lib/1.0.0-185~gca0f3b3_amd64/vpp-lib-1.0.0-185~gca0f3b3_amd64.deb" || exit
102 fi
103
104 VPP_DEBS=(*.deb)
105 echo ${VPP_DEBS[@]}
106 VIRL_DIR_LOC="/tmp"
107 VPP_DEBS_FULL=(${VPP_DEBS[@]})
108
109 # Prepend directory location at remote host to deb file list
110 for index in "${!VPP_DEBS_FULL[@]}"; do
111     VPP_DEBS_FULL[${index}]=${VIRL_DIR_LOC}/${VPP_DEBS_FULL[${index}]}
112 done
113
114 echo "Updated file names: " ${VPP_DEBS_FULL[@]}
115
116 cat ${VIRL_PKEY}
117 # Copy the files to VIRL host
118 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no *.deb \
119     ${VIRL_USERNAME}@${VIRL_SERVER}:${VIRL_DIR_LOC}/
120
121 result=$?
122 if [ "${result}" -ne "0" ]; then
123     echo "Failed to copy vpp deb files to virl host"
124     echo ${result}
125     exit ${result}
126 fi
127
128 # Start a simulation on VIRL server
129 echo "Starting simulation on VIRL server"
130
131 function stop_virl_simulation {
132     ssh -i priv_key -o StrictHostKeyChecking=no ${VIRL_USERNAME}@${VIRL_SERVER}\
133         "/home/jenkins-in/testcase-infra/bin/stop-testcase ${VIRL_SID}"
134 }
135
136 VIRL_SID=$(ssh -i priv_key -o StrictHostKeyChecking=no \
137     ${VIRL_USERNAME}@${VIRL_SERVER} \
138     "/home/jenkins-in/testcase-infra/bin/start-testcase -c simple-ring ${VPP_DEBS_FULL[@]}")
139 retval=$?
140 if [ "$?" -ne "0" ]; then
141     echo "VIRL simulation start failed"
142     exit ${retval}
143 fi
144
145 if [[ ! "${VIRL_SID}" =~ session-[a-zA-Z0-9]{6} ]]; then
146     echo "No VIRL session ID reported."
147     exit 127
148 fi
149
150 # Upon script exit, cleanup the simulation execution
151 trap stop_virl_simulation EXIT
152 echo ${VIRL_SID}
153
154 ssh_do ${VIRL_USERNAME}@${VIRL_SERVER} cat /scratch/${VIRL_SID}/topology.yaml
155
156 # Download the topology file from virl session
157 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no \
158     ${VIRL_USERNAME}@${VIRL_SERVER}:/scratch/${VIRL_SID}/topology.yaml \
159     topologies/enabled/topology.yaml
160
161 retval=$?
162 if [ "$?" -ne "0" ]; then
163     echo "Failed to copy topology file from VIRL simulation"
164     exit ${retval}
165 fi
166
167
168 virtualenv env
169 . env/bin/activate
170
171 echo pip install
172 pip install -r requirements.txt
173
174 PYTHONPATH=`pwd` pybot -L TRACE \
175     -v TOPOLOGY_PATH:topologies/enabled/topology.yaml \
176     --include vm_env \
177     --include 3_NODE_SINGLE_LINK_TOPO \
178     --exclude 3_node_double_link_topoNOT3_node_single_link_topo \
179     --exclude PERFTEST \
180     --noncritical EXPECTED_FAILING \
181     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.