diff options
-rw-r--r-- | tests/dmz-clean.sh | 20 | ||||
-rw-r--r-- | tests/dmz.sh | 2 | ||||
-rw-r--r-- | tests/network_bridging-clean.sh | 26 | ||||
-rw-r--r-- | tests/network_bridging.sh | 2 | ||||
-rw-r--r-- | tests/reserved_subnet-clean.sh | 18 | ||||
-rw-r--r-- | tests/smtp_ingress-clean.sh | 18 | ||||
-rw-r--r-- | tests/smtp_ingress.sh | 2 |
7 files changed, 72 insertions, 16 deletions
diff --git a/tests/dmz-clean.sh b/tests/dmz-clean.sh index b13ef7e..9161d69 100644 --- a/tests/dmz-clean.sh +++ b/tests/dmz-clean.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015-2016 AT&T Intellectual Property, Inc +# Copyright 2015-2017 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. @@ -28,6 +28,22 @@ # # After test, cleanup # $ bash dmz-clean.sh +trap 'fail' ERR + +pass() { + echo "Hooray!" + set +x #echo off + exit 0 +} + +# Use this to trigger fail() at the right places +# if [ "$RESULT" == "Test Failed!" ]; then fail; fi +fail() { + echo "Test Failed!" + set +x + exit 1 +} + if [ $# -eq 1 ]; then if [ $1 == "debug" ]; then set -x #echo on @@ -101,5 +117,5 @@ neutron subnet-delete test_internal echo "Delete internal network" neutron net-delete test_internal -set +x #echo off +pass diff --git a/tests/dmz.sh b/tests/dmz.sh index e95a7ea..ab16ef6 100644 --- a/tests/dmz.sh +++ b/tests/dmz.sh @@ -209,6 +209,4 @@ done echo "Verify cirros1 is paused:" $RESULT if [ "$RESULT" == "Test Failed!" ]; then fail; fi -set +x #echo off - pass diff --git a/tests/network_bridging-clean.sh b/tests/network_bridging-clean.sh index a9bd909..477918d 100644 --- a/tests/network_bridging-clean.sh +++ b/tests/network_bridging-clean.sh @@ -24,12 +24,26 @@ # How to use: # $ bash network_bridging-clean.sh +trap 'fail' ERR -if [ $# -eq 1 ]; then - if [ $1 == "debug" ]; then - set -x #echo on - fi -fi +pass() { + echo "Hooray!" + set +x #echo off + exit 0 +} + +# 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 +} echo "Get Congress policy 'test' ID" test_policy_ID=$(openstack congress policy show test | awk "/ id / { print \$4 }") @@ -71,5 +85,5 @@ neutron subnet-delete test_admin echo "Delete test_admin network" neutron net-delete test_admin -set +x #echo off +pass diff --git a/tests/network_bridging.sh b/tests/network_bridging.sh index 7edd8f9..214ae87 100644 --- a/tests/network_bridging.sh +++ b/tests/network_bridging.sh @@ -191,6 +191,4 @@ done echo "$0: $(date) 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 abc4e7e..778a027 100644 --- a/tests/reserved_subnet-clean.sh +++ b/tests/reserved_subnet-clean.sh @@ -30,6 +30,22 @@ # # After test, cleanup # $ bash reserved_subnet-clean.sh +trap 'fail' ERR + +pass() { + echo "Hooray!" + set +x #echo off + exit 0 +} + +# Use this to trigger fail() at the right places +# if [ "$RESULT" == "Test Failed!" ]; then fail; fi +fail() { + echo "Test Failed!" + set +x + exit 1 +} + if [ $# -eq 1 ]; then if [ $1 == "debug" ]; then set -x #echo on @@ -57,4 +73,4 @@ neutron subnet-delete test_public echo "Delete public network" neutron net-delete test_public -set +x #echo off +pass diff --git a/tests/smtp_ingress-clean.sh b/tests/smtp_ingress-clean.sh index 0cf7943..791a979 100644 --- a/tests/smtp_ingress-clean.sh +++ b/tests/smtp_ingress-clean.sh @@ -27,6 +27,22 @@ # # After test, cleanup with # $ bash dmz-clean.sh +trap 'fail' ERR + +pass() { + echo "Hooray!" + set +x #echo off + exit 0 +} + +# Use this to trigger fail() at the right places +# if [ "$RESULT" == "Test Failed!" ]; then fail; fi +fail() { + echo "Test Failed!" + set +x + exit 1 +} + if [ $# -eq 1 ]; then if [ $1 == "debug" ]; then set -x #echo on @@ -89,4 +105,4 @@ neutron subnet-delete test_internal echo "Delete internal network" neutron net-delete test_internal -set +x #echo off +pass diff --git a/tests/smtp_ingress.sh b/tests/smtp_ingress.sh index a6ee632..0e6f1ce 100644 --- a/tests/smtp_ingress.sh +++ b/tests/smtp_ingress.sh @@ -165,6 +165,4 @@ done echo $RESULT if [ "$RESULT" == "Test Failed!" ]; then fail; fi -set +x #echo off - pass |