Andy Bavier | ea5b44c | 2016-04-08 16:12:30 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Andy Bavier | cb02433 | 2016-04-29 15:52:26 -0400 | [diff] [blame] | 3 | function bootstrap() { |
| 4 | cd ~ |
Andy Bavier | b6a74cd | 2016-04-29 19:59:51 -0400 | [diff] [blame] | 5 | sudo apt-get update |
| 6 | sudo apt-get -y install git |
Andy Bavier | cb02433 | 2016-04-29 15:52:26 -0400 | [diff] [blame] | 7 | git clone https://github.com/open-cloud/openstack-cluster-setup.git |
| 8 | cd ~/openstack-cluster-setup |
| 9 | ./bootstrap.sh |
Andy Bavier | ea5b44c | 2016-04-08 16:12:30 -0400 | [diff] [blame] | 10 | |
Andy Bavier | cb02433 | 2016-04-29 15:52:26 -0400 | [diff] [blame] | 11 | # Log into the local node once to get host key |
| 12 | ssh -o StrictHostKeyChecking=no localhost "ls > /dev/null" |
| 13 | } |
Andy Bavier | ea5b44c | 2016-04-08 16:12:30 -0400 | [diff] [blame] | 14 | |
Andy Bavier | cb02433 | 2016-04-29 15:52:26 -0400 | [diff] [blame] | 15 | function setup_openstack() { |
| 16 | # Run the playbook |
| 17 | ansible-playbook -i cord-test-hosts cord-setup.yml |
| 18 | } |
| 19 | |
| 20 | function 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 | |
| 29 | function 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 | |
| 44 | function 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 | |
| 50 | function 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 | |
| 66 | function 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 | |
| 83 | function 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 |
| 134 | RUN_TEST=0 |
| 135 | while 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 Bavier | ea5b44c | 2016-04-08 16:12:30 -0400 | [diff] [blame] | 149 | done |
| 150 | |
Andy Bavier | cb02433 | 2016-04-29 15:52:26 -0400 | [diff] [blame] | 151 | # What to do |
| 152 | bootstrap |
| 153 | setup_openstack |
| 154 | pull_docker_images |
| 155 | wait_for_openstack |
| 156 | simulate_fabric |
| 157 | |
| 158 | if [[ $RUN_TEST -eq 1 ]] |
| 159 | then |
| 160 | setup_xos |
| 161 | setup_test_client |
| 162 | run_e2e_test |
| 163 | fi |