summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblsaws <bryan.sullivan@att.com>2016-09-22 04:44:42 -0700
committerblsaws <bryan.sullivan@att.com>2016-09-22 04:44:42 -0700
commita6b4e3954814582d79ceae537030d32932e8e8e1 (patch)
treeddafd99050fd8452995a515f1c67bf6edf76712c
parent0f7d7dd344ee8dc364664712f5f4c307d9a0a7be (diff)
Add script name to echo
JIRA: COPPER-4 Change-Id: Ibb9dfb60eeafa21ea1454f8d4fac4da824c2b5de Signed-off-by: blsaws <bryan.sullivan@att.com>
-rwxr-xr-x[-rw-r--r--]tests/adhoc/smoke01-clean.sh34
-rwxr-xr-x[-rw-r--r--]tests/adhoc/smoke01.sh72
2 files changed, 55 insertions, 51 deletions
diff --git a/tests/adhoc/smoke01-clean.sh b/tests/adhoc/smoke01-clean.sh
index 3c4ebf3..a846dbb 100644..100755
--- a/tests/adhoc/smoke01-clean.sh
+++ b/tests/adhoc/smoke01-clean.sh
@@ -27,15 +27,15 @@
wget https://git.opnfv.org/cgit/copper/plain/components/congress/install/bash/setenv.sh -O ~/setenv.sh
source ~/setenv.sh
-echo "Delete cirros1 instance"
+echo "$0: Delete cirros1 instance"
instance=$(nova list | awk "/ cirros1 / { print \$2 }")
if [ "$instance" != "" ]; then nova delete $instance; fi
-echo "Delete cirros2 instance"
+echo "$0: 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"
+echo "$0: Wait for cirros1 and cirros2 to terminate"
COUNTER=5
RESULT="Wait!"
until [[ $COUNTER -eq 0 || $RESULT == "Go!" ]]; do
@@ -46,46 +46,46 @@ until [[ $COUNTER -eq 0 || $RESULT == "Go!" ]]; do
sleep 5
done
-echo "Delete 'smoke01' security group"
+echo "$0: Delete 'smoke01' security group"
sg=$(neutron security-group-list | awk "/ smoke01 / { print \$2 }")
neutron security-group-delete $sg
-echo "Delete floating ip"
+echo "$0: Delete floating ip"
# FLOATING_IP_ID was saved by smoke01.sh
-source /tmp/TEST_VARS.sh
-rm /tmp/TEST_VARS.sh
+source /tmp/SMOKE01_VARS.sh
+rm /tmp/SMOKE01_VARS.sh
neutron floatingip-delete $FLOATING_IP_ID
-echo "Delete smoke01 key pair"
+echo "$0: Delete smoke01 key pair"
nova keypair-delete smoke01
rm /tmp/smoke01
-echo "Get 'public_router' ID"
+echo "$0: Get 'public_router' ID"
router=$(neutron router-list | awk "/ public_router / { print \$2 }")
-echo "Get internal port ID with subnet 10.0.0.1 on 'public_router'"
+echo "$0: Get internal port ID with subnet 10.0.0.1 on 'public_router'"
internal_interface=$(neutron router-port-list $router | grep 10.0.0.1 | awk '{print $2}')
-echo "If found, delete the port with subnet 10.0.0.1 on 'public_router'"
+echo "$0: If found, delete the port with subnet 10.0.0.1 on 'public_router'"
if [ "$internal_interface" != "" ]; then neutron router-interface-delete $router port=$internal_interface; fi
-echo "Clear the router gateway"
+echo "$0: Clear the router gateway"
neutron router-gateway-clear public_router
-echo "Delete the router"
+echo "$0: Delete the router"
neutron router-delete public_router
-echo "Delete neutron port with fixed_ip 10.0.0.1"
+echo "$0: Delete neutron port with fixed_ip 10.0.0.1"
port=$(neutron port-list | awk "/ 10.0.0.1 / { print \$2 }")
if [ "$port" != "" ]; then neutron port-delete $port; fi
-echo "Delete neutron port with fixed_ip 10.0.0.2"
+echo "$0: Delete neutron port with fixed_ip 10.0.0.2"
port=$(neutron port-list | awk "/ 10.0.0.2 / { print \$2 }")
if [ "$port" != "" ]; then neutron port-delete $port; fi
-echo "Delete internal subnet"
+echo "$0: Delete internal subnet"
neutron subnet-delete internal
-echo "Delete internal network"
+echo "$0: Delete internal network"
neutron net-delete internal
diff --git a/tests/adhoc/smoke01.sh b/tests/adhoc/smoke01.sh
index c8ace71..81684e1 100644..100755
--- a/tests/adhoc/smoke01.sh
+++ b/tests/adhoc/smoke01.sh
@@ -27,7 +27,7 @@
# $ bash ~/git/copper/tests/adhoc/smoke01-clean.sh
pass() {
- echo "Hooray!"
+ echo "$0: Hooray!"
set +x #echo off
exit 0
}
@@ -35,13 +35,13 @@ pass() {
# Use this to trigger fail() at the right places
# if [ "$RESULT" == "Test Failed!" ]; then fail; fi
fail() {
- echo "Test Failed!"
+ echo "$0: Test Failed!"
set +x
exit 1
}
unclean() {
- echo "Unclean environment!"
+ echo "$0: Unclean environment!"
fail
}
@@ -61,11 +61,11 @@ function get_external_net () {
EXTERNAL_NETWORK_NAME=$(openstack network show $ext_net_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"
+ echo "$0: External network not found"
+ echo "$0: Create external network"
neutron net-create public --router:external
EXTERNAL_NETWORK_NAME="public"
- echo "Create external subnet"
+ echo "$0: 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
@@ -74,39 +74,43 @@ function get_external_net () {
wget https://git.opnfv.org/cgit/copper/plain/components/congress/install/bash/setenv.sh -O ~/setenv.sh
source ~/setenv.sh
-echo "Create cirros-0.3.3-x86_64 image"
-image=$(openstack image list | awk "/ cirros-0.3.3-x86_64 / { print \$2 }")
-if [ -z $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
+echo "$0: Create cirros-0.3.3-x86_64 image"
+if [[ -z $(openstack image list | awk "/ cirros-0.3.3-x86_64 / { print \$2 }") ]]; 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
get_external_net
-echo "Create floating IP for external subnet"
+echo "$0: 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 "FLOATING_IP_ID=$FLOATING_IP_ID" >/tmp/SMOKE01_VARS.sh
-echo "Create internal network"
-neutron net-create internal
+if [[ -z $(neutron net-list | awk "/ internal / { print \$2 }") ]]; then
+ echo "$0: Create internal network"
+ neutron net-create internal
-echo "Create internal subnet"
-neutron subnet-create internal 10.0.0.0/24 --name 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 "$0: Create internal subnet"
+ neutron subnet-create internal 10.0.0.0/24 --name 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
+fi
-echo "Create router"
-neutron router-create public_router
+if [[ -z $(neutron router-list | awk "/ public_router / { print \$2 }") ]]; then
+ echo "$0: Create router"
+ neutron router-create public_router
-echo "Create router gateway"
-neutron router-gateway-set public_router $EXTERNAL_NETWORK_NAME
+ echo "$0: Create router gateway"
+ neutron router-gateway-set public_router $EXTERNAL_NETWORK_NAME
-echo "Add router interface for internal network"
-neutron router-interface-add public_router subnet=internal
+ echo "$0: Add router interface for internal network"
+ neutron router-interface-add public_router subnet=internal
+fi
-echo "Wait up to a minute as 'neutron router-interface-add' blocks the neutron-api for some time..."
+echo "$0: Wait up to a minute as 'neutron router-interface-add' blocks the neutron-api for some time..."
COUNTER=1
RESULT="Failed!"
until [[ "$COUNTER" -gt 6 || "$RESULT" == "Success!" ]]; do
- echo "Get the internal network ID: try" $COUNTER
+ echo "$0: Get the internal network ID: try" $COUNTER
internal_NET=$(neutron net-list | awk "/ internal / { print \$2 }")
if [ "$internal_NET" != "" ]; then RESULT="Success!"; fi
let COUNTER+=1
@@ -114,21 +118,21 @@ until [[ "$COUNTER" -gt 6 || "$RESULT" == "Success!" ]]; do
done
if [ "$RESULT" == "Test Failed!" ]; then fail; fi
-echo "Create smoke01 security group"
+echo "$0: Create smoke01 security group"
neutron security-group-create smoke01
-echo "Add rule to smoke01 security group"
+echo "$0: Add rule to smoke01 security group"
neutron security-group-rule-create --direction ingress --protocol=TCP --remote-ip-prefix 0.0.0.0/0 --port-range-min=22 --port-range-max=22 smoke01
neutron security-group-rule-create --direction ingress --protocol=ICMP --remote-ip-prefix 0.0.0.0/0 smoke01
neutron security-group-rule-create --direction egress --protocol=TCP --remote-ip-prefix 0.0.0.0/0 --port-range-min=22 --port-range-max=22 smoke01
neutron security-group-rule-create --direction egress --protocol=ICMP --remote-ip-prefix 0.0.0.0/0 smoke01
-echo "Create Nova key pair"
-ssh-keygen -f "$HOME/.ssh/known_hosts" -R 192.168.10.6
+echo "$0: Create Nova key pair"
+ssh-keygen -f "$HOME/.ssh/known_hosts" -R $FLOATING_IP
nova keypair-add smoke01 > /tmp/smoke01
chmod 600 /tmp/smoke01
-echo "Boot cirros1"
+echo "$0: Boot cirros1"
openstack server create --config-drive True --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=$internal_NET --security-group smoke01 --key-name smoke01 cirros1
# metadata is accessible by logging into cirros1 after floating IP assignment
# ssh -i /tmp/smoke01 -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no cirros@$FLOATING_IP
@@ -137,10 +141,10 @@ openstack server create --config-drive True --flavor m1.tiny --image cirros-0.3.
# sudo mount /dev/sr0 /mnt/
# find /mnt/openstack/latest -name *.json -exec grep -H { {} + | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
-echo "Get cirros1 instance ID"
+echo "$0: Get cirros1 instance ID"
test_cirros1_ID=$(openstack server list | awk "/ cirros1 / { print \$2 }")
-echo "Wait for cirros1 to go ACTIVE"
+echo "$0: Wait for cirros1 to go ACTIVE"
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
@@ -151,16 +155,16 @@ until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
done
if [ "$RESULT" == "Test Failed!" ]; then fail; fi
-echo "Associate floating IP to cirros1"
+echo "$0: Associate floating IP to cirros1"
nova floating-ip-associate cirros1 $FLOATING_IP
-echo "Boot cirros2"
+echo "$0: 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"
+ echo "$0: Verify internal network connectivity"
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
@@ -168,7 +172,7 @@ until [[ "$COUNTER" -gt 6 || "$RESULT" == "Success!" ]]; do
done
if [ "$RESULT" == "Test Failed!" ]; then fail; fi
-echo "Verify public network connectivity"
+echo "$0: Verify public network connectivity"
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