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