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