4911c4d5e83cba83d24a93c5bd2f200a722f7b51
[csit.git] / bootstrap.sh
1 #!/bin/bash
2
3 set -x
4
5 echo | sudo tee -a /etc/hostname
6 echo "127.0.0.1 `cat /etc/hostname` " | sudo tee -a /etc/hosts
7
8 cat /etc/hostname
9 cat /etc/hosts
10
11 export DEBIAN_FRONTEND=noninteractive
12 sudo apt-get -y update
13 sudo apt-get -y install libpython2.7-dev python-virtualenv
14
15 #VIRL_VMS="10.30.51.53,10.30.51.51,10.30.51.52"
16 #IFS=',' read -ra ADDR <<< "${VIRL_VMS}"
17 #
18
19 function ssh_do() {
20     echo
21     echo "### "  ssh $@
22     ssh -i priv_key -o StrictHostKeyChecking=no $@
23 }
24
25 #for addr in "${ADDR[@]}"; do
26 #    echo
27 #    echo ${addr}
28 #    echo
29 #
30 #    ssh_do cisco@${addr} hostname || true
31 #    ssh_do cisco@${addr} "ifconfig -a" || true
32 #    ssh_do cisco@${addr} "lspci -Dnn | grep 0200" || true
33 #    ssh_do cisco@${addr} "free -m" || true
34 #    ssh_do cisco@${addr} "cat /proc/meminfo" || true
35 #    ssh_do cisco@${addr} "dpkg -l vpp\*" || true
36 #    ssh_do cisco@${addr} "lshw -c network" || true
37 #    ssh_do cisco@${addr} "sudo -S sh -c 'echo exec show  hardware | vpp_api_test '"
38 #done
39
40 VIRL_SERVER=10.30.51.28
41 VIRL_USERNAME=jenkins-in
42 VIRL_PKEY=priv_key
43
44 rm -f ${VIRL_PKEY}
45 cat > ${VIRL_PKEY} <<EOF
46 -----BEGIN RSA PRIVATE KEY-----
47 MIIEpQIBAAKCAQEA+IHXq87GcqMR1C47rzx6Cbip5Ghq8pKrbqKrP5Nf41HcYrT6
48 GOXl9nFWKsMOzIlIn+8y7Il27eZh7csQGApbg8QLiHMtcYEmWNzKZpkqg4nuAPxX
49 VXwlKgnKX902SrET9Gp9TDayiHtCRWVfrlPPPSA0UEXW6BjLN/uHJ+W/Xzrrab+9
50 asBVa05vT2W6n0KJ66zfCaeDM912mQ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fRI2/OCRsjz/t1bv1seM
67 xVMND4XI6xb/apBWAZgZpIFrqrWoIBM3ptfsKipZe91ngBPUnL9s0Dolx452RVAj
68 yctHB8uRxWYgqDkjsxtzXf1HnZBBkBS8CUzYj+hdfuddoeKLaY3invXLCiV+PpXS
69 U4KAK9kCgYEAtSv0m5+Fg74BbAiFB6kCh11FYkW94YI6B/E2D/uVTD5dJhyEUFgZ
70 cWsudXjMki8734WSpMBqBp/J8wG3C9ZS6IpQD+U7UXA+roB7Qr+j4TqtWfM+87Rh
71 maOpG56uAyR0w5Z9BhwzA3VakibVk9KwDgZ29WtKFzuATLFnOtCS46E=
72 -----END RSA PRIVATE KEY-----
73 EOF
74 chmod 600 priv_key
75
76 # Temporarily download VPP packages from nexus.fd.io
77
78 rm -f *.deb
79 if [ "${#}" -ne "0" ]; then
80     echo "let's use the parameters"
81     arr=(${@})
82     echo ${arr[0]}
83 else
84     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
85     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
86     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
87     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
88     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
89     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
90 fi
91
92 VPP_DEBS=(*.deb)
93 echo ${VPP_DEBS[@]}
94 VIRL_DIR_LOC="/tmp"
95 VPP_DEBS_FULL=(${VPP_DEBS[@]})
96
97 # Prepend directory location at remote host to deb file list
98 for index in "${!VPP_DEBS_FULL[@]}"; do
99     VPP_DEBS_FULL[${index}]=${VIRL_DIR_LOC}/${VPP_DEBS_FULL[${index}]}
100 done
101
102 echo "Updated file names: " ${VPP_DEBS_FULL[@]}
103
104 cat ${VIRL_PKEY}
105 # Copy the files to VIRL host
106 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no *.deb \
107     ${VIRL_USERNAME}@${VIRL_SERVER}:${VIRL_DIR_LOC}/
108
109 result=$?
110 if [ "${result}" -ne "0" ]; then
111     echo "Failed to copy vpp deb files to virl host"
112     echo ${result}
113     exit ${result}
114 fi
115
116 # Start a simulation on VIRL server
117 echo "Starting simulation on VIRL server"
118
119 function stop_virl_simulation {
120     ssh -i priv_key -o StrictHostKeyChecking=no ${VIRL_USERNAME}@${VIRL_SERVER}\
121         "/home/jenkins-in/testcase-infra/bin/stop-testcase ${VIRL_SID}"
122 }
123
124 VIRL_SID=$(ssh -i priv_key -o StrictHostKeyChecking=no \
125     ${VIRL_USERNAME}@${VIRL_SERVER} \
126     "/home/jenkins-in/testcase-infra/bin/start-testcase -c simple-ring ${VPP_DEBS_FULL[@]}")
127 retval=$?
128 if [ "$?" -ne "0" ]; then
129     echo "VIRL simulation start failed"
130     exit ${retval}
131 fi
132
133 if [ "x${VIRL_SID}" == "x" ]; then
134     echo "No VIRL session ID reported."
135     exit 127
136 fi
137
138 # Upon script exit, cleanup the simulation execution
139 trap stop_virl_simulation EXIT
140 echo ${VIRL_SID}
141
142 ssh_do ${VIRL_USERNAME}@${VIRL_SERVER} cat /scratch/${VIRL_SID}/topology.yaml
143
144 # Download the topology file from virl session
145 scp -i ${VIRL_PKEY} -o StrictHostKeyChecking=no \
146     ${VIRL_USERNAME}@${VIRL_SERVER}:/scratch/${VIRL_SID}/topology.yaml \
147     topologies/enabled/topology.yaml
148
149 retval=$?
150 if [ "$?" -ne "0" ]; then
151     echo "Failed to copy topology file from VIRL simulation"
152     exit ${retval}
153 fi
154
155
156 virtualenv env
157 . env/bin/activate
158
159 echo pip install
160 pip install -r requirements.txt
161
162 PYTHONPATH=`pwd` pybot -L TRACE \
163     -v TOPOLOGY_PATH:topologies/enabled/topology.yaml \
164     --include vm_env \
165     --include 3_NODE_SINGLE_LINK_TOPO \
166     --exclude 3_node_double_link_topoNOT3_node_single_link_topo \
167     --exclude PERFTEST \
168     --noncritical EXPECTED_FAILING \
169     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.