From 67a78a8513ac023bfc834b4a71d67340eac75fe0 Mon Sep 17 00:00:00 2001 From: blsaws Date: Wed, 27 Jul 2016 17:43:48 -0700 Subject: Fix use of floating IP, add delays to avoid errors... JIRA: COPPER-4 Change-Id: I738131f9b0b4ca0a25cd87c90bb29a452a708616 Signed-off-by: blsaws --- tests/adhoc/smoke01-clean.sh | 26 +++++++++++---- tests/adhoc/smoke01.sh | 38 +++++++++++++++++----- tests/dmz-clean.sh | 34 ++++++++++--------- tests/dmz.sh | 67 ++++++++++++++++++++++++++++++-------- tests/reserved_subnet-clean.sh | 3 +- tests/reserved_subnet.sh | 3 +- tests/smtp_ingress-clean.sh | 33 ++++++++++--------- tests/smtp_ingress.sh | 74 ++++++++++++++++++++++++++++++++++-------- 8 files changed, 203 insertions(+), 75 deletions(-) diff --git a/tests/adhoc/smoke01-clean.sh b/tests/adhoc/smoke01-clean.sh index c951911..3c4ebf3 100644 --- a/tests/adhoc/smoke01-clean.sh +++ b/tests/adhoc/smoke01-clean.sh @@ -27,9 +27,6 @@ wget https://git.opnfv.org/cgit/copper/plain/components/congress/install/bash/setenv.sh -O ~/setenv.sh source ~/setenv.sh -echo "Disassociate cirros1 floating IP address" -nova floating-ip-disassociate cirros1 192.168.10.6 - echo "Delete cirros1 instance" instance=$(nova list | awk "/ cirros1 / { print \$2 }") if [ "$instance" != "" ]; then nova delete $instance; fi @@ -38,14 +35,31 @@ echo "Delete cirros2 instance" instance=$(nova list | awk "/ cirros2 / { print \$2 }") if [ "$instance" != "" ]; then nova delete $instance; fi -echo "Delete smoke01 key pair" -nova keypair-delete smoke01 -rm /tmp/smoke01 +echo "Wait for cirros1 and cirros2 to terminate" +COUNTER=5 +RESULT="Wait!" +until [[ $COUNTER -eq 0 || $RESULT == "Go!" ]]; do + cirros1_id=$(openstack server list | awk "/ cirros1 / { print \$4 }") + cirros2_id=$(openstack server list | awk "/ cirros2 / { print \$4 }") + if [[ "$cirros1_id" == "" && "$cirros2_id" == "" ]]; then RESULT="Go!"; fi + let COUNTER-=1 + sleep 5 +done echo "Delete 'smoke01' security group" sg=$(neutron security-group-list | awk "/ smoke01 / { print \$2 }") neutron security-group-delete $sg +echo "Delete floating ip" +# FLOATING_IP_ID was saved by smoke01.sh +source /tmp/TEST_VARS.sh +rm /tmp/TEST_VARS.sh +neutron floatingip-delete $FLOATING_IP_ID + +echo "Delete smoke01 key pair" +nova keypair-delete smoke01 +rm /tmp/smoke01 + echo "Get 'public_router' ID" router=$(neutron router-list | awk "/ public_router / { print \$2 }") diff --git a/tests/adhoc/smoke01.sh b/tests/adhoc/smoke01.sh index 899b4f1..5c264f4 100644 --- a/tests/adhoc/smoke01.sh +++ b/tests/adhoc/smoke01.sh @@ -45,6 +45,12 @@ unclean() { fail } +if [ $# -eq 1 ]; then + if [ $1 == "debug" ]; then + set -x #echo on + fi +fi + # Find external network if any, and details function get_external_net () { echo "Find external network" @@ -59,7 +65,6 @@ function get_external_net () { if [[ $ID ]]; then EXTERNAL_NETWORK_NAME=$(openstack network show $ID | awk "/ name / { print \$4 }") EXTERNAL_SUBNET_ID=$(openstack network show $EXTERNAL_NETWORK_NAME | awk "/ subnets / { print \$4 }") - FLOATING_IP=$(openstack subnet show $EXTERNAL_SUBNET_ID | awk "/ allocation_pools / { print \$4 }" | cut -d - -f 1) else echo "External network not found" echo "Create external network" @@ -68,7 +73,6 @@ function get_external_net () { echo "Create external subnet" neutron subnet-create public 192.168.10.0/24 --name public --enable_dhcp=False --allocation_pool start=192.168.10.6,end=192.168.10.49 --gateway 192.168.10.1 EXTERNAL_SUBNET_ID=$(openstack subnet show public | awk "/ id / { print \$4 }") - FLOATING_IP="192.168.10.6" fi } @@ -83,7 +87,10 @@ fi get_external_net echo "Create floating IP for external subnet" -neutron floatingip-create $EXTERNAL_NETWORK_NAME +FLOATING_IP_ID=$(neutron floatingip-create $EXTERNAL_NETWORK_NAME | awk "/ id / { print \$4 }") +FLOATING_IP=$(neutron floatingip-show $FLOATING_IP_ID | awk "/ floating_ip_address / { print \$4 }" | cut -d - -f 1) +# Save ID to pass to cleanup script +echo "FLOATING_IP_ID=$FLOATING_IP_ID" >/tmp/TEST_VARS.sh echo "Create internal network" neutron net-create internal @@ -129,18 +136,31 @@ chmod 600 /tmp/smoke01 echo "Boot cirros1" nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=$internal_NET --security-groups smoke01 --key-name smoke01 cirros1 -echo "Boot cirros2" -nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=$internal_NET --security-groups smoke01 cirros2 +echo "Get cirros1 instance ID" +test_cirros1_ID=$(openstack server list | awk "/ cirros1 / { print \$2 }") + +echo "Wait for cirros1 to go ACTIVE" +COUNTER=5 +RESULT="Test Failed!" +until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do + status=$(openstack server show $test_cirros1_ID | awk "/ status / { print \$4 }") + if [[ "$status" == "ACTIVE" ]]; then RESULT="Test Success!"; fi + let COUNTER-=1 + sleep 5 +done +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Associate floating IP to cirros1" nova floating-ip-associate cirros1 $FLOATING_IP -# add a delay to allow cirros1 to come up completely +echo "Boot cirros2" +nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=$internal_NET --security-groups smoke01 cirros2 + COUNTER=1 RESULT="Failed!" until [[ "$COUNTER" -gt 6 || "$RESULT" == "Success!" ]]; do echo "Verify internal network connectivity" - RESULT=$(ssh -i /tmp/smoke01 -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no cirros@192.168.10.6 "ping -c 3 10.0.0.4; exit" | awk "/ 0% packet loss/ { print \$1 }") + RESULT=$(ssh -i /tmp/smoke01 -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no cirros@$FLOATING_IP "ping -c 3 10.0.0.4; exit" | awk "/ 0% packet loss/ { print \$1 }") if [ "$RESULT" == "3" ]; then RESULT="Success!"; fi let COUNTER+=1 sleep 10 @@ -148,7 +168,9 @@ done if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Verify public network connectivity" -RESULT=$(ssh -i /tmp/smoke01 -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no cirros@192.168.10.6 "ping -c 3 8.8.8.8; exit" | awk "/ 0% packet loss/ { print \$1 }") +RESULT=$(ssh -i /tmp/smoke01 -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no cirros@$FLOATING_IP "ping -c 3 8.8.8.8; exit" | awk "/ 0% packet loss/ { print \$1 }") if [ "$RESULT" != "3" ]; then fail; fi +set +x #echo off + pass diff --git a/tests/dmz-clean.sh b/tests/dmz-clean.sh index 0823cad..dcb53b8 100644 --- a/tests/dmz-clean.sh +++ b/tests/dmz-clean.sh @@ -24,7 +24,7 @@ # Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy # $ bash dmz.sh -# After test, cleanup +# # After test, cleanup # $ bash dmz-clean.sh if [ $# -eq 1 ]; then @@ -46,10 +46,27 @@ echo "Delete cirros1 instance" instance=$(nova list | awk "/ cirros1 / { print \$2 }") if [ "$instance" != "" ]; then nova delete $instance; fi +# FLOATING_IP_ID was saved by dmz.sh +source /tmp/TEST_VARS.sh +rm /tmp/TEST_VARS.sh +echo "Delete floating ip" +neutron floatingip-delete $FLOATING_IP_ID + echo "Delete cirros2 instance" instance=$(nova list | awk "/ cirros2 / { print \$2 }") if [ "$instance" != "" ]; then nova delete $instance; fi +echo "Wait for cirros1 and cirros2 to terminate" +COUNTER=5 +RESULT="Wait!" +until [[ $COUNTER -eq 0 || $RESULT == "Go!" ]]; do + cirros1_id=$(openstack server list | awk "/ cirros1 / { print \$4 }") + cirros2_id=$(openstack server list | awk "/ cirros2 / { print \$4 }") + if [[ "$cirros1_id" == "" && "$cirros2_id" == "" ]]; then RESULT="Go!"; fi + let COUNTER-=1 + sleep 5 +done + echo "Delete 'dmz' security group" sg=$(neutron security-group-list | awk "/ dmz / { print \$2 }") neutron security-group-delete $sg @@ -63,15 +80,6 @@ test_internal_interface=$(neutron router-port-list $router | grep 10.0.0.1 | awk echo "If found, delete the port with subnet 10.0.0.1 on 'test_router'" if [ "$test_internal_interface" != "" ]; then neutron router-interface-delete $router port=$test_internal_interface; fi -echo "Get public port ID with fixed_ip 192.168.10.2 on 'test_router'" -test_public_interface=$(neutron router-port-list $router | grep 192.168.10.2 | awk '{print $2}') - -echo "If found, delete the port with fixed_ip 192.168.10.2 on 'test_router'" -if [ "$test_public_interface" != "" ]; then neutron router-interface-delete $router port=$test_public_interface; fi - -echo "Delete the router internal interface" -neutron router-interface-delete $router $test_internal_interface - echo "Clear the router gateway" neutron router-gateway-clear test_router @@ -92,9 +100,5 @@ neutron subnet-delete test_internal echo "Delete internal network" neutron net-delete test_internal -echo "Delete public subnet" -neutron subnet-delete test_public - -echo "Delete public network" -neutron net-delete test_public +set +x #echo off diff --git a/tests/dmz.sh b/tests/dmz.sh index b644e0e..191d6d3 100644 --- a/tests/dmz.sh +++ b/tests/dmz.sh @@ -29,10 +29,9 @@ # Prequisite: OPFNV installed per JOID or Apex installer # - OpenStack CLI environment variables setup # How to use: -# Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy # $ bash dmz.sh -# After test, cleanup +# # After test, cleanup # $ bash dmz-clean.sh pass() { @@ -60,6 +59,31 @@ if [ $# -eq 1 ]; then fi fi +# Find external network if any, and details +function get_external_net () { + echo "Find external network" + LINE=4 + ID=$(openstack network list | awk "NR==$LINE{print \$2}") + while [[ $ID ]] + do + if [[ $(openstack network show $ID | awk "/ router:external / { print \$4 }") == "External" ]]; then break; fi + ((LINE+=1)) + ID=$(openstack network list | awk "NR==$LINE{print \$2}") + done + if [[ $ID ]]; then + EXTERNAL_NETWORK_NAME=$(openstack network show $ID | awk "/ name / { print \$4 }") + EXTERNAL_SUBNET_ID=$(openstack network show $EXTERNAL_NETWORK_NAME | awk "/ subnets / { print \$4 }") + else + echo "External network not found" + echo "Create external network" + neutron net-create public --router:external + EXTERNAL_NETWORK_NAME="public" + echo "Create external subnet" + neutron subnet-create public 192.168.10.0/24 --name public --enable_dhcp=False --allocation_pool start=192.168.10.6,end=192.168.10.49 --gateway 192.168.10.1 + EXTERNAL_SUBNET_ID=$(openstack subnet show public | awk "/ id / { print \$4 }") + fi +} + echo "Create Congress policy 'test'" if [ $(openstack congress policy show test | awk "/ id / { print \$4 }") ]; then unclean; fi openstack congress policy create test @@ -86,12 +110,13 @@ IMAGE_ID=$(glance image-list | awk "/ cirros-0.3.3-x86_64-dmz / { print \$2 }") echo "Add 'dmz' image tag to the cirros dmz image" glance --os-image-api-version 2 image-tag-update $IMAGE_ID "dmz" -echo "Create external network" -if [ $(neutron net-list | awk "/ test_public / { print \$2 }") ]; then unclean; fi -neutron net-create test_public --router:external=true +get_external_net -echo "Create external subnet" -neutron subnet-create --disable-dhcp test_public 192.168.10.0/24 +echo "Create floating IP for external subnet" +FLOATING_IP_ID=$(neutron floatingip-create $EXTERNAL_NETWORK_NAME | awk "/ id / { print \$4 }") +FLOATING_IP=$(neutron floatingip-show $FLOATING_IP_ID | awk "/ floating_ip_address / { print \$4 }" | cut -d - -f 1) +# Save ID to pass to cleanup script +echo "FLOATING_IP_ID=$FLOATING_IP_ID" >/tmp/TEST_VARS.sh echo "Create internal network" if [ $(neutron net-list | awk "/ test_internal / { print \$2 }") ]; then unclean; fi @@ -105,7 +130,7 @@ if [ $(neutron router-list | awk "/ test_router / { print \$2 }") ]; then unclea neutron router-create test_router echo "Create router gateway" -neutron router-gateway-set test_router test_public +neutron router-gateway-set test_router $EXTERNAL_NETWORK_NAME echo "Add router internal for internal network" neutron router-interface-add test_router subnet=test_internal @@ -119,6 +144,7 @@ until [[ "$COUNTER" -gt 6 || "$RESULT" == "Success!" ]]; do let COUNTER+=1 sleep 10 done +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Create a security group 'dmz'" if [ $(neutron security-group-list | awk "/ dmz / { print \$2 }") ]; then unclean; fi @@ -133,11 +159,23 @@ neutron security-group-rule-create --direction ingress dmz echo "Boot cirros1 with non-dmz image" nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=$test_internal_NET --security-groups dmz cirros1 -test_cirros1_ID=$(nova list | awk "/ cirros1 / { print \$2 }") -if [ -z $test_cirros1_ID ]; then - echo "Unable to boot cirros1" - fail -fi + +echo "Get cirros1 instance ID" +test_cirros1_ID=$(openstack server list | awk "/ cirros1 / { print \$2 }") + +echo "Wait for cirros1 to go ACTIVE" +COUNTER=5 +RESULT="Test Failed!" +until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do + status=$(openstack server show $test_cirros1_ID | awk "/ status / { print \$4 }") + if [[ "$status" == "ACTIVE" ]]; then RESULT="Test Success!"; fi + let COUNTER-=1 + sleep 5 +done +if [ "$RESULT" == "Test Failed!" ]; then fail; fi + +echo "Associate floating IP to cirros1" +nova floating-ip-associate cirros1 $FLOATING_IP echo "Boot cirros2 with dmz image" nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64-dmz --nic net-id=$test_internal_NET --security-groups dmz cirros2 @@ -192,4 +230,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do done echo "Verify cirros1 is paused:" $RESULT if [ "$RESULT" == "Test Failed!" ]; then fail; fi + +set +x #echo off + pass diff --git a/tests/reserved_subnet-clean.sh b/tests/reserved_subnet-clean.sh index 56c6c5a..f502ee4 100644 --- a/tests/reserved_subnet-clean.sh +++ b/tests/reserved_subnet-clean.sh @@ -24,10 +24,9 @@ # Prequisite: OPFNV installed per JOID or Apex installer # - OpenStack CLI environment variables setup # How to use: -# Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy # $ bash reserved_subnet.sh -# After test, cleanup +# # After test, cleanup # $ bash reserved_subnet-clean.sh if [ $# -eq 1 ]; then diff --git a/tests/reserved_subnet.sh b/tests/reserved_subnet.sh index 7fb7da1..3718c94 100644 --- a/tests/reserved_subnet.sh +++ b/tests/reserved_subnet.sh @@ -24,10 +24,9 @@ # Prequisite: OPFNV installed per JOID or Apex installer # - OpenStack CLI environment variables setup # How to use: -# Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy # $ bash reserved_subnet.sh -# After test, cleanup +# # After test, cleanup # $ bash reserved_subnet-clean.sh pass() { diff --git a/tests/smtp_ingress-clean.sh b/tests/smtp_ingress-clean.sh index 08f788e..42e6042 100644 --- a/tests/smtp_ingress-clean.sh +++ b/tests/smtp_ingress-clean.sh @@ -21,9 +21,9 @@ # Prequisite: OPFNV installed per JOID or Apex installer # - OpenStack CLI environment variables setup # How to use: -# Install Congress test server per https://wiki.opnfv.org/copper/academy +# # Create Congress policy and resources that exercise policy # $ bash dmz.sh -# After test, cleanup with +# # After test, cleanup with # $ bash dmz-clean.sh if [ $# -eq 1 ]; then @@ -46,10 +46,26 @@ instance=$(nova list | awk "/ cirros1 / { print \$2 }") if [ "$instance" != "" ]; then nova delete $instance fi +echo "Wait for cirros1 to terminate" +COUNTER=5 +RESULT="Wait!" +until [[ $COUNTER -eq 0 || $RESULT == "Go!" ]]; do + cirros1_id=$(openstack server list | awk "/ cirros1 / { print \$4 }") + if [[ "$cirros1_id" == "" ]]; then RESULT="Go!"; fi + let COUNTER-=1 + sleep 5 +done + echo "Delete 'smtp_ingress' security group" sg=$(neutron security-group-list | awk "/ smtp_ingress / { print \$2 }") neutron security-group-delete $sg +# FLOATING_IP_ID was saved by smtp_ingress.sh +source /tmp/TEST_VARS.sh +rm /tmp/TEST_VARS.sh +echo "Delete floating ip" +neutron floatingip-delete $FLOATING_IP_ID + echo "Get 'test_router' ID" router=$(neutron router-list | awk "/ test_router / { print \$2 }") @@ -60,16 +76,6 @@ echo "If found, delete the port with fixed_ip 10.0.0.1 on 'test_router'" if [ "$test_internal_interface" != "" ]; then neutron router-interface-delete $router port=$test_internal_interface fi -echo "Get public port ID with fixed_ip 192.168.10.2 on 'test_router'" -test_public_interface=$(neutron router-port-list $router | grep 192.168.10.2 | awk '{print $2}') - -echo "If found, delete the port with fixed_ip 192.168.10.2 on 'test_router'" -if [ "$test_public_interface" != "" ]; then neutron router-interface-delete $router port=$test_public_interface -fi - -echo "Delete the router internal interface" -neutron router-interface-delete $router $test_internal_interface - echo "Clear the router gateway" neutron router-gateway-clear test_router @@ -82,7 +88,4 @@ neutron subnet-delete test_internal echo "Delete internal network" neutron net-delete test_internal -echo "Delete public network" -neutron net-delete test_public - set +x #echo off diff --git a/tests/smtp_ingress.sh b/tests/smtp_ingress.sh index 9497276..5c0e766 100644 --- a/tests/smtp_ingress.sh +++ b/tests/smtp_ingress.sh @@ -23,10 +23,9 @@ # Prequisite: OPFNV installed per JOID or Apex installer # - OpenStack CLI environment variables setup # How to use: -# Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy # $ bash smtp_ingress.sh -# After test, cleanup +# # After test, cleanup # $ bash smtp_ingress-clean.sh pass() { @@ -54,6 +53,31 @@ if [ $# -eq 1 ]; then fi fi +# Find external network if any, and details +function get_external_net () { + echo "Find external network" + LINE=4 + ID=$(openstack network list | awk "NR==$LINE{print \$2}") + while [[ $ID ]] + do + if [[ $(openstack network show $ID | awk "/ router:external / { print \$4 }") == "External" ]]; then break; fi + ((LINE+=1)) + ID=$(openstack network list | awk "NR==$LINE{print \$2}") + done + if [[ $ID ]]; then + EXTERNAL_NETWORK_NAME=$(openstack network show $ID | awk "/ name / { print \$4 }") + EXTERNAL_SUBNET_ID=$(openstack network show $EXTERNAL_NETWORK_NAME | awk "/ subnets / { print \$4 }") + else + echo "External network not found" + echo "Create external network" + neutron net-create public --router:external + EXTERNAL_NETWORK_NAME="public" + echo "Create external subnet" + neutron subnet-create public 192.168.10.0/24 --name public --enable_dhcp=False --allocation_pool start=192.168.10.6,end=192.168.10.49 --gateway 192.168.10.1 + EXTERNAL_SUBNET_ID=$(openstack subnet show public | awk "/ id / { print \$4 }") + fi +} + echo "Create Congress policy 'test'" if [[ $(openstack congress policy show test | awk "/ id / { print \$4 }") ]]; then unclean; fi openstack congress policy create test @@ -66,12 +90,13 @@ image=$(openstack image list | awk "/ cirros-0.3.3-x86_64 / { print \$2 }") if [ "$image" == "" ]; then glance --os-image-api-version 1 image-create --name cirros-0.3.3-x86_64 --disk-format qcow2 --location http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img --container-format bare fi -echo "Create external network" -if [[ $(neutron net-list | awk "/ test_public / { print \$2 }") ]]; then unclean; fi -neutron net-create test_public --router:external=true +get_external_net -echo "Create external subnet" -neutron subnet-create --disable-dhcp test_public 192.168.10.0/24 +echo "Create floating IP for external subnet" +FLOATING_IP_ID=$(neutron floatingip-create $EXTERNAL_NETWORK_NAME | awk "/ id / { print \$4 }") +FLOATING_IP=$(neutron floatingip-show $FLOATING_IP_ID | awk "/ floating_ip_address / { print \$4 }" | cut -d - -f 1) +# Save ID to pass to cleanup script +echo "FLOATING_IP_ID=$FLOATING_IP_ID" >/tmp/TEST_VARS.sh echo "Create internal network" if [[ $(neutron net-list | awk "/ test_internal / { print \$2 }") ]]; then unclean; fi @@ -85,17 +110,21 @@ if [[ $(neutron router-list | awk "/ test_router / { print \$2 }") ]]; then uncl neutron router-create test_router echo "Create router gateway" -neutron router-gateway-set test_router test_public +neutron router-gateway-set test_router $EXTERNAL_NETWORK_NAME echo "Add router internal for internal network" neutron router-interface-add test_router subnet=test_internal -echo "Wait 30 seconds as the previous command interrupts the neutron-api for some time..." -# add a delay since the previous command takes the neutron-api offline for a while (?) -sleep 30 - -echo "Get the internal network ID" -test_internal_NET=$(neutron net-list | awk "/ test_internal / { print \$2 }") +COUNTER=1 +RESULT="Failed!" +until [[ "$COUNTER" -gt 6 || "$RESULT" == "Success!" ]]; do + echo "Get the internal network ID: try" $COUNTER + test_internal_NET=$(neutron net-list | awk "/ test_internal / { print \$2 }") + if [ "$test_internal_NET" != "" ]; then RESULT="Success!"; fi + let COUNTER+=1 + sleep 10 +done +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Create a security group 'smtp_ingress'" if [[ $(neutron security-group-list | awk "/ smtp_ingress / { print \$2 }") ]]; then unclean; fi @@ -110,6 +139,20 @@ nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=$test_intern echo "Get cirros1 instance ID" test_cirros1_ID=$(openstack server list | awk "/ cirros1 / { print \$2 }") +echo "Wait for cirros1 to go ACTIVE" +COUNTER=5 +RESULT="Test Failed!" +until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do + status=$(openstack server show $test_cirros1_ID | awk "/ status / { print \$4 }") + if [[ "$status" == "ACTIVE" ]]; then RESULT="Test Success!"; fi + let COUNTER-=1 + sleep 5 +done +if [ "$RESULT" == "Test Failed!" ]; then fail; fi + +echo "Associate floating IP to cirros1" +nova floating-ip-associate cirros1 $FLOATING_IP + echo "Verify cirros1 is in the Congress policy 'test' table 'smtp_ingress'" COUNTER=5 RESULT="Test Failed!" @@ -123,4 +166,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do done echo $RESULT if [ "$RESULT" == "Test Failed!" ]; then fail; fi + +set +x #echo off + pass -- cgit 1.2.3-korg