diff options
author | blsaws <bryan.sullivan@att.com> | 2016-05-19 16:53:23 -0700 |
---|---|---|
committer | blsaws <bryan.sullivan@att.com> | 2016-05-19 16:53:23 -0700 |
commit | eae00dcc98ed5d2c9fa81f76e6d4008a44f96bf4 (patch) | |
tree | 3bb609598b9cdd9e700a1f4a80c130fe3a7f22c9 /tests | |
parent | fd37f6fb6a6ba6e961ef05c73a6bd788bfddc090 (diff) |
Update tests and create test runner.
JIRA: COPPER-4
Change-Id: Ic83f123a370e307bf946e69f73e1a16ac366fb61
Signed-off-by: blsaws <bryan.sullivan@att.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dmz-clean.sh (renamed from tests/adhoc/dmz01-clean.sh) | 9 | ||||
-rw-r--r-- | tests/dmz.sh (renamed from tests/adhoc/dmz01.sh) | 51 | ||||
-rw-r--r-- | tests/reserved_subnet-clean.sh (renamed from tests/adhoc/reserved_subnet-clean.sh) | 10 | ||||
-rw-r--r-- | tests/reserved_subnet.sh (renamed from tests/adhoc/reserved_subnet.sh) | 51 | ||||
-rwxr-xr-x | tests/run.sh | 44 | ||||
-rw-r--r-- | tests/smtp_ingress-clean.sh (renamed from tests/adhoc/smtp_ingress-clean.sh) | 4 | ||||
-rw-r--r-- | tests/smtp_ingress.sh (renamed from tests/adhoc/smtp_ingress.sh) | 49 |
7 files changed, 161 insertions, 57 deletions
diff --git a/tests/adhoc/dmz01-clean.sh b/tests/dmz-clean.sh index d6482c6..3635ebb 100644 --- a/tests/adhoc/dmz01-clean.sh +++ b/tests/dmz-clean.sh @@ -20,11 +20,14 @@ # # How to use: # Install Congress test server per https://wiki.opnfv.org/copper/academy -# $ source ~/git/copper/tests/adhoc/dmz01.sh +# $ source ~/git/copper/tests/adhoc/dmz.sh # After test, cleanup with -# $ source ~/git/copper/tests/adhoc/dmz01-clean.sh +# $ sh ~/git/copper/tests/adhoc/dmz-clean.sh -if [ $1 == "debug" ]; then set -x #echo on +if [ $# -eq 1 ]; then + if [ $1 == "debug" ]; then + set -x #echo on + fi fi source /opt/copper/admin-openrc.sh diff --git a/tests/adhoc/dmz01.sh b/tests/dmz.sh index 1796b27..1b5ff95 100644 --- a/tests/adhoc/dmz01.sh +++ b/tests/dmz.sh @@ -29,25 +29,37 @@ # How to use: # Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy -# $ source ~/git/copper/tests/adhoc/dmz01.sh +# $ sh dmz.sh # After test, cleanup -# $ source ~/git/copper/tests/adhoc/dmz01-clean.sh - -if [ $1 == "debug" ]; then set -x #echo on +# $ sh dmz-clean.sh + +pass() { + echo "Hooray!" +} + +# Use this to trigger fail() at the right places +# if [ "$RESULT" == "Test Failed!" ]; then fail; fi +fail() { + echo "Test Failed!" + set +x + exit 1 +} + +unclean() { + echo "Unclean environment!" + fail +} + +if [ $# -eq 1 ]; then + if [ $1 == "debug" ]; then + set -x #echo on + fi fi source /opt/copper/admin-openrc.sh -echo "Delete Congress policy 'test' if it exists" -test_policy_ID=$(openstack congress policy show test | awk "/ id / { print \$4 }") - -if [ "$test_policy_ID" != "" ]; then -# TODO: report bug - should be able to delete by name - openstack congress policy delete $test_policy_ID - echo "Existing policy 'test' deleted" -fi - echo "Create Congress policy 'test'" +if [[ $(openstack congress policy show test | awk "/ id / { print \$4 }") ]]; then unclean; fi openstack congress policy create test echo "Create dmz_server rule in policy 'test'" @@ -73,18 +85,21 @@ 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" -neutron net-create test_public --router:external=true --provider:network_type=flat --provider:physical_network=physnet1 +if [[ $(neutron net-list | awk "/ test_public / { print \$2 }") ]]; then unclean; fi +neutron net-create test_public --router:external=true echo "Create external subnet" neutron subnet-create --disable-dhcp test_public 192.168.10.0/24 echo "Create internal network" +if [[ $(neutron net-list | awk "/ test_internal / { print \$2 }") ]]; then unclean; fi neutron net-create test_internal echo "Create internal subnet" neutron subnet-create test_internal 10.0.0.0/24 --name test_internal --gateway 10.0.0.1 --enable-dhcp --allocation-pool start=10.0.0.2,end=10.0.0.254 --dns-nameserver 8.8.8.8 echo "Create router" +if [[ $(neutron router-list | awk "/ test_router / { print \$2 }") ]]; then unclean; fi neutron router-create test_router echo "Create router gateway" @@ -100,13 +115,14 @@ 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!" + if [ "$test_internal_NET" != "" ]; then RESULT="c0546c94-436e-4624-aa1a-4393e2981c15Success!" fi let COUNTER+=1 sleep 10 done echo "Create a security group 'dmz'" +if [[ $(neutron security-group-list | awk "/ dmz / { print \$2 }") ]]; then unclean; fi neutron security-group-create dmz echo "Create security group ingress rule for 'dmz'" @@ -139,6 +155,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do sleep 5 done echo "dmz_server table entries present for cirros1, cirros2:" $RESULT +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Verify cirros1 ID is in the Congress policy 'test' table 'dmz_placement_error'" COUNTER=5 @@ -151,6 +168,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do sleep 5 done echo "dmz_placement_error table entry present for cirros2:" $RESULT +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Create reactive 'paused_dmz_placement_error' rule in policy 'test'" openstack congress policy rule create test "execute[nova:servers.pause(id)] :- dmz_placement_error(id), nova:servers(id,status='ACTIVE')" --name paused_dmz_placement_error @@ -166,5 +184,6 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do sleep 5 done echo "Verify cirros1 is paused:" $RESULT - +if [ "$RESULT" == "Test Failed!" ]; then fail; fi +pass set +x #echo off diff --git a/tests/adhoc/reserved_subnet-clean.sh b/tests/reserved_subnet-clean.sh index 4f149ba..c4c46f6 100644 --- a/tests/adhoc/reserved_subnet-clean.sh +++ b/tests/reserved_subnet-clean.sh @@ -24,13 +24,15 @@ # How to use: # Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy -# $ source reserved_subnet.sh +# $ sh reserved_subnet.sh # After test, cleanup -# $ source reserved_subnet-clean.sh +# $ sh reserved_subnet-clean.sh -if [ $1 == "debug" ]; then set -x #echo on +if [ $# -eq 1 ]; then + if [ $1 == "debug" ]; then + set -x #echo on + fi fi - source /opt/copper/admin-openrc.sh echo "Get Congress policy 'test' ID" diff --git a/tests/adhoc/reserved_subnet.sh b/tests/reserved_subnet.sh index 7b3ac12..6152a1b 100644 --- a/tests/adhoc/reserved_subnet.sh +++ b/tests/reserved_subnet.sh @@ -24,25 +24,37 @@ # How to use: # Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy -# $ source reserved_subnet.sh +# $ sh reserved_subnet.sh # After test, cleanup -# $ source reserved_subnet-clean.sh - -if [ $1 == "debug" ]; then set -x #echo on +# $ sh reserved_subnet-clean.sh + +pass() { + echo "Hooray!" +} + +# Use this to trigger fail() at the right places +# if [ "$RESULT" == "Test Failed!" ]; then fail; fi +fail() { + echo "Test Failed!" + set +x + exit 1 +} + +unclean() { + echo "Unclean environment!" + fail +} + +if [ $# -eq 1 ]; then + if [ $1 == "debug" ]; then + set -x #echo on + fi fi source /opt/copper/admin-openrc.sh -echo "Delete Congress policy 'test' if it exists" -test_policy_ID=$(openstack congress policy show test | awk "/ id / { print \$4 }") - -if [ "$test_policy_ID" != "" ]; then -# TODO: report bug - should be able to delete by name - openstack congress policy delete $test_policy_ID - echo "Existing policy 'test' deleted" -fi - echo "Create Congress policy 'test'" +if [[ $(openstack congress policy show test | awk "/ id / { print \$4 }") ]]; then unclean; fi openstack congress policy create test echo "Create smtp_ingress rule in policy 'test'" @@ -52,7 +64,9 @@ openstack congress policy rule create test "reserved_subnet_error(x) :- neutronv openstack congress policy rule create test "reserved_subnet_error(x) :- neutronv2:subnets(id=x, cidr='10.7.14.0/24')" --name rsv_subnet_mgm echo "Create external network" -neutron net-create test_public --router:external=true --provider:network_type=flat --provider:physical_network=physnet1 +if [[ $(neutron net-list | awk "/ test_public / { print \$2 }") ]]; then unclean; fi +neutron net-create test_public --router:external=true +#neutron net-create test_public --router:external=true --provider:network_type=flat --provider:physical_network=physnet1 echo "Create external subnet" neutron subnet-create --disable-dhcp test_public 10.7.1.0/24 --name test_public @@ -61,6 +75,7 @@ echo "Get the external subnet ID" test_public_SUBNET=$(neutron subnet-list | awk "/ test_public / { print \$2 }") echo "Create internal network" +if [[ $(neutron net-list | awk "/ test_internal / { print \$2 }") ]]; then unclean; fi neutron net-create test_internal echo "Create internal subnet" @@ -80,6 +95,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do sleep 5 done echo "Verify test_public subnet ID is in the Congress policy 'test' table 'reserved_subnet_error':" $RESULT +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Verify test_internal subnet ID is in the Congress policy 'test' table 'reserved_subnet_error'" COUNTER=5 @@ -92,6 +108,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do sleep 5 done echo "Verify test_internal subnet ID is in the Congress policy 'test' table 'reserved_subnet_error':" $RESULT +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Create reactive 'deleted_reserved_subnet_error' rule in policy 'test'" openstack congress policy rule create test "execute[neutronv2:delete_subnet(x)] :- reserved_subnet_error(x)" --name deleted_reserved_subnet_error @@ -107,6 +124,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do sleep 5 done echo "Verify test_internal subnet is deleted:" $RESULT +if [ "$RESULT" == "Test Failed!" ]; then fail; fi echo "Verify test_public subnet is deleted" COUNTER=5 @@ -118,6 +136,7 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do let COUNTER-=1 sleep 5 done -echo "Verify test_internal subnet is deleted:" $RESULT - +echo "Verify test_public subnet is deleted:" $RESULT +if [ "$RESULT" == "Test Failed!" ]; then fail; fi +pass set +x #echo off diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..2257d88 --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Copyright 2015-2016 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: function test driver for the OPNFV Copper project. +# Status: this is a work in progress, under test. +# Prequisite: +# - OPFNV installed per JOID or Apex installer +# On jumphost: +# - Congress installed through install_congress_1.sh +# - Copper test environment installed per +# How to use: +# $ source install_congress_testserver_1.sh +# + +echo "============" +echo "Test: dmz.sh" +echo "============" +sh dmz.sh +sh dmz-clean.sh + +echo "========================" +echo "Test: reserved_subnet.sh" +echo "========================" +sh reserved_subnet.sh +sh reserved_subnet-clean.sh + +echo "=====================" +echo "Test: smtp_ingress.sh" +echo "=====================" +sh smtp_ingress.sh +sh smtp_ingress-clean.sh + diff --git a/tests/adhoc/smtp_ingress-clean.sh b/tests/smtp_ingress-clean.sh index 0791125..f224ae6 100644 --- a/tests/adhoc/smtp_ingress-clean.sh +++ b/tests/smtp_ingress-clean.sh @@ -20,9 +20,9 @@ # # How to use: # Install Congress test server per https://wiki.opnfv.org/copper/academy -# $ source ~/git/copper/tests/adhoc/dmz01.sh +# $ sh dmz.sh # After test, cleanup with -# $ source ~/git/copper/tests/adhoc/dmz01-clean.sh +# $ sh dmz-clean.sh if [ $1 == "debug" ]; then set -x #echo on fi diff --git a/tests/adhoc/smtp_ingress.sh b/tests/smtp_ingress.sh index b787691..45f685e 100644 --- a/tests/adhoc/smtp_ingress.sh +++ b/tests/smtp_ingress.sh @@ -23,25 +23,37 @@ # How to use: # Install Congress test server per https://wiki.opnfv.org/copper/academy # # Create Congress policy and resources that exercise policy -# $ source smtp_ingress.sh +# $ sh smtp_ingress.sh # After test, cleanup -# $ source smtp_ingress-clean.sh - -if [ $1 == "debug" ]; then set -x #echo on +# $ sh smtp_ingress-clean.sh + +pass() { + echo "Hooray!" +} + +# Use this to trigger fail() at the right places +# if [ "$RESULT" == "Test Failed!" ]; then fail; fi +fail() { + echo "Test Failed!" + set +x + exit 1 +} + +unclean() { + echo "Unclean environment!" + fail +} + +if [ $# -eq 1 ]; then + if [ $1 == "debug" ]; then + set -x #echo on + fi fi source /opt/copper/admin-openrc.sh -echo "Delete Congress policy 'test' if it exists" -test_policy_ID=$(openstack congress policy show test | awk "/ id / { print \$4 }") - -if [ "$test_policy_ID" != "" ]; then -# TODO: report bug - should be able to delete by name - openstack congress policy delete $test_policy_ID - echo "Existing policy 'test' deleted" -fi - echo "Create Congress policy 'test'" +if [[ $(openstack congress policy show test | awk "/ id / { print \$4 }") ]]; then unclean; fi openstack congress policy create test echo "Create smtp_ingress rule in policy 'test'" @@ -53,18 +65,21 @@ if [ "$image" == "" ]; then glance --os-image-api-version 1 image-create --name fi echo "Create external network" -neutron net-create test_public --router:external=true --provider:network_type=flat --provider:physical_network=physnet1 +if [[ $(neutron net-list | awk "/ test_public / { print \$2 }") ]]; then unclean; fi +neutron net-create test_public --router:external=true echo "Create external subnet" neutron subnet-create --disable-dhcp test_public 192.168.10.0/24 echo "Create internal network" +if [[ $(neutron net-list | awk "/ test_internal / { print \$2 }") ]]; then unclean; fi neutron net-create test_internal echo "Create internal subnet" neutron subnet-create test_internal 10.0.0.0/24 --name test_internal --gateway 10.0.0.1 --enable-dhcp --allocation-pool start=10.0.0.2,end=10.0.0.254 --dns-nameserver 8.8.8.8 echo "Create router" +if [[ $(neutron router-list | awk "/ test_router / { print \$2 }") ]]; then unclean; fi neutron router-create test_router echo "Create router gateway" @@ -81,9 +96,10 @@ echo "Get the internal network ID" test_internal_NET=$(neutron net-list | awk "/ test_internal / { print \$2 }") echo "Create a security group 'smtp_ingress'" +if [[ $(neutron security-group-list | awk "/ smtp_ingress / { print \$2 }") ]]; then unclean; fi neutron security-group-create smtp_ingress -echo "Create security group ingress rule for 'ingress'" +echo "Create security group ingress rule for 'smtp_ingress'" neutron security-group-rule-create --direction ingress --protocol=TCP --port-range-min=25 --port-range-max=25 smtp_ingress echo "Boot cirros1 with smtp_ingress security group" @@ -107,5 +123,6 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do sleep 10 done echo $RESULT - +if [ "$RESULT" == "Test Failed!" ]; then fail; fi +pass set +x #echo off |