blob: 985e6f86b0d8d3115f8013f87ee672d394d51021 [file] [log] [blame]
Andy Bavierea5b44c2016-04-08 16:12:30 -04001#!/bin/bash
2
Andy Baviercb024332016-04-29 15:52:26 -04003function bootstrap() {
4 cd ~
5 git clone https://github.com/open-cloud/openstack-cluster-setup.git
6 cd ~/openstack-cluster-setup
7 ./bootstrap.sh
Andy Bavierea5b44c2016-04-08 16:12:30 -04008
Andy Baviercb024332016-04-29 15:52:26 -04009 # Log into the local node once to get host key
10 ssh -o StrictHostKeyChecking=no localhost "ls > /dev/null"
11}
Andy Bavierea5b44c2016-04-08 16:12:30 -040012
Andy Baviercb024332016-04-29 15:52:26 -040013function setup_openstack() {
14 # Run the playbook
15 ansible-playbook -i cord-test-hosts cord-setup.yml
16}
17
18function pull_docker_images() {
19 # Pull down the Docker images
20 echo ""
21 echo "Pull down the Docker images for ONOS and XOS"
22 echo "This can take 20 minutes or more, be patient!"
23 ssh ubuntu@onos-cord "cd cord; sudo docker-compose up -d"
24 ssh ubuntu@xos "cd xos/xos/configurations/cord-pod; sudo docker-compose pull"
25}
26
27function wait_for_openstack() {
28 # Need to wait for OpenStack services to come up before running any XOS "make" commands
29 echo "Waiting for the OpenStack services to fully come up."
30 echo "This can take 30 minutes or more, be patient!"
31 i=0
32 until juju status --format=summary|grep "started: 23" > /dev/null
33 do
34 sleep 60
35 (( i += 1 ))
36 echo "Waited $i minutes"
37 done
38
39 echo "All OpenStack services are up."
40}
41
42function simulate_fabric() {
43 echo ""
44 echo "Setting up simulated fabric on nova-compute node"
45 ssh ubuntu@nova-compute "wget https://raw.githubusercontent.com/open-cloud/openstack-cluster-setup/master/scripts/compute-ext-net.sh; sudo bash compute-ext-net.sh"
46}
47
48function setup_xos() {
49 echo ""
50 echo "Setting up XOS, will take a few minutes"
51 ssh ubuntu@xos "cd xos/xos/configurations/cord-pod; make"
52 echo ""
53 echo "Pause 2 minutes"
54 sleep 120
55
56 ssh ubuntu@xos "cd xos/xos/configurations/cord-pod; make vtn"
57 echo ""
58 echo "Pause 30 seconds"
59 sleep 30
60
61 ssh ubuntu@xos "cd xos/xos/configurations/cord-pod; make cord"
62}
63
64function setup_test_client() {
65 ssh ubuntu@nova-compute "sudo apt-get -y install lxc"
66
67 # Change default bridge
68 ssh ubuntu@nova-compute "sudo sed -i 's/lxcbr0/databr/' /etc/lxc/default.conf"
69
70 # Create test client
71 ssh ubuntu@nova-compute "sudo lxc-create -t ubuntu -n testclient"
72 ssh ubuntu@nova-compute "sudo lxc-start -n testclient"
73
74 # Configure network interface inside of test client with s-tag and c-tag
75 ssh ubuntu@nova-compute "sudo lxc-attach -n testclient -- ip link add link eth0 name eth0.222 type vlan id 222"
76 ssh ubuntu@nova-compute "sudo lxc-attach -n testclient -- ip link add link eth0.222 name eth0.222.111 type vlan id 111"
77 ssh ubuntu@nova-compute "sudo lxc-attach -n testclient -- ifconfig eth0.222 up"
78 ssh ubuntu@nova-compute "sudo lxc-attach -n testclient -- ifconfig eth0.222.111 up"
79}
80
81function run_e2e_test() {
82 source ~/admin-openrc.sh
83
84 echo "*** Wait for vSG VM to come up"
85 i=0
86 until nova list --all-tenants|grep ACTIVE > /dev/null
87 do
88 sleep 60
89 (( i += 1 ))
90 echo "Waited $i minutes"
91 done
92
93 # get mgmt IP address
94 ID=$( nova list --all-tenants|grep mysite_vsg|awk '{print $2}' )
95 MGMTIP=$( nova interface-list $ID|grep 172.27|awk '{print $8}' )
96
97 echo ""
98 echo "*** ssh into vsg VM, wait for Docker container to come up"
99 i=0
100 until ssh -o ProxyCommand="ssh -W %h:%p ubuntu@nova-compute" ubuntu@$MGMTIP "sudo docker ps|grep vcpe" > /dev/null
101 do
102 sleep 60
103 (( i += 1 ))
104 echo "Waited $i minutes"
105 done
106
107 echo ""
108 echo "*** Run dhclient in test client"
109 ssh ubuntu@nova-compute "sudo lxc-attach -n testclient -- dhclient eth0.222.111" > /dev/null
110
111 echo ""
112 echo "*** Routes in test client"
113 ssh ubuntu@nova-compute "sudo lxc-attach -n testclient -- route -n"
114
115
116 echo ""
117 echo "*** Test external connectivity in test client"
118 ssh ubuntu@nova-compute "sudo lxc-attach -n testclient -- ping -c 3 8.8.8.8"
119
120 echo ""
121 if [ $? -eq 0 ]
122 then
123 echo "*** [PASSED] End-to-end connectivity test"
124 exit 0
125 else
126 echo "*** [FAILED] End-to-end connectivity test"
127 exit 1
128 fi
129}
130
131# Parse options
132RUN_TEST=0
133while getopts ":ht" opt; do
134 case ${opt} in
135 h ) "echo Usage:"
136 echo " $0 install OpenStack and prep XOS and ONOS VMs [default]"
137 echo " $0 -h display this help message"
138 echo " $0 -t do install, bring up cord-pod configuration, run E2E test"
139 exit 0
140 ;;
141 t ) RUN_TEST=1
142 ;;
143 \? ) echo "Invalid option"
144 exit 1
145 ;;
146 esac
Andy Bavierea5b44c2016-04-08 16:12:30 -0400147done
148
Andy Baviercb024332016-04-29 15:52:26 -0400149# What to do
150bootstrap
151setup_openstack
152pull_docker_images
153wait_for_openstack
154simulate_fabric
155
156if [[ $RUN_TEST -eq 1 ]]
157then
158 setup_xos
159 setup_test_client
160 run_e2e_test
161fi