Add test assertions 83/25383/1
authorBryan Sullivan <bryan.sullivan@att.com>
Fri, 2 Dec 2016 02:02:13 +0000 (18:02 -0800)
committerBryan Sullivan <bryan.sullivan@att.com>
Fri, 2 Dec 2016 02:02:13 +0000 (18:02 -0800)
JIRA: MODELS-23

Change-Id: Iaea8be6026f18d8530c4b274d86b99cfbddf2e98
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
tests/vHello_Tacker.sh

index 0efa978..71107bf 100644 (file)
@@ -115,7 +115,7 @@ setup () {
     sudo docker exec -i -t $CONTAINER /bin/bash /tmp/tacker/tacker-setup.sh $1 setup
   fi
 
-  assert "models-tacker-001: Tacker is successfully installed in a docker container on the jumphost." true 
+  assert "models-tacker-001 (Tacker installation in a docker container on the jumphost)" true 
 
   echo "$0: $(date) reset blueprints folder"
   if [[ -d /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker ]]; then rm -rf /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker; fi
@@ -131,7 +131,8 @@ setup () {
   if [[ -f /tmp/tacker/vHello ]]; then rm /tmp/tacker/vHello; fi
   ssh-keygen -t rsa -N "" -f /tmp/tacker/vHello -C ubuntu@vHello
   chmod 600 /tmp/tacker/vHello
-  openstack keypair create --public-key /tmp/tacker/vHello.pub vHello 
+  openstack keypair create --public-key /tmp/tacker/vHello.pub vHello
+  assert "models-nova-001 (Keypair creation)" true 
 
   echo "$0: $(date) Inject public key into blueprint"
   pubkey=$(cat /tmp/tacker/vHello.pub)
@@ -142,21 +143,17 @@ start() {
   echo "$0: $(date) setup OpenStack CLI environment"
   source /tmp/tacker/admin-openrc.sh
 
-  if [[ "$1" == "tacker-api" ]]; then
-    echo "$0: $(date) Tacker API use is not yet implemented"
-  else
-    # Tacker CLI use
-    echo "$0: $(date) Get external network for Floating IP allocations"
+  echo "$0: $(date) Get external network for Floating IP allocations"
 
-    echo "$0: $(date) create VNFD"
-    cd /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker
-    tacker vnfd-create --vnfd-file blueprint.yaml --name hello-world-tacker
-    if [ $? -eq 1 ]; then fail; fi
+  echo "$0: $(date) create VNFD"
+  cd /tmp/tacker/blueprints/tosca-vnfd-hello-world-tacker
+  tacker vnfd-create --vnfd-file blueprint.yaml --name hello-world-tacker
+  if [ $? -eq 1 ]; then fail; fi
+  assert "models-tacker-002 (VNFD creation)" true 
 
-    echo "$0: $(date) create VNF"
-    tacker vnf-create --vnfd-name hello-world-tacker --name hello-world-tacker
-    if [ $? -eq 1 ]; then fail; fi
-  fi
+  echo "$0: $(date) create VNF"
+  tacker vnf-create --vnfd-name hello-world-tacker --name hello-world-tacker
+  if [ $? -eq 1 ]; then fail; fi
 
   echo "$0: $(date) wait for hello-world-tacker to go ACTIVE"
   active=""
@@ -170,10 +167,13 @@ start() {
     sleep 10
     echo "$0: $(date) wait for hello-world-tacker to go ACTIVE"
   done
+  assert "models-tacker-002 (VNF creation)" true 
 
-  echo "$0: $(date) directly set port security on ports (bug/unsupported in Mitaka Tacker?)"
-#  HEAT_ID=$(tacker vnf-show hello-world-tacker | awk "/instance_id/ { print \$4 }")
-#  SERVER_ID=$(openstack stack resource list $HEAT_ID | awk "/VDU1 / { print \$4 }")
+  # Setup for workarounds
+  echo "$0: $(date) directly set port security on ports (unsupported in Mitaka Tacker)"
+  # Alternate method
+  #  HEAT_ID=$(tacker vnf-show hello-world-tacker | awk "/instance_id/ { print \$4 }")
+  #  SERVER_ID=$(openstack stack resource list $HEAT_ID | awk "/VDU1 / { print \$4 }")
   SERVER_ID=$(openstack server list | awk "/VDU1/ { print \$2 }")
   id=($(neutron port-list|grep -v "+"|grep -v name|awk '{print $2}'))
   for id in ${id[@]}; do
@@ -192,6 +192,7 @@ start() {
   get_floating_net
   FIP=$(openstack floating ip create $FLOATING_NETWORK_NAME | awk "/floating_ip_address/ { print \$4 }")
   nova floating-ip-associate $SERVER_ID $FIP
+  # End setup for workarounds
 
   echo "$0: $(date) get vHello server address"
   SERVER_IP=$(openstack server show $SERVER_ID | awk "/ addresses / { print \$6 }")
@@ -203,29 +204,36 @@ start() {
   echo "$0: $(date) verify vHello server is running"
   apt-get install -y curl
   if [[ $(curl $SERVER_URL | grep -c "Hello World") == 0 ]]; then fail; fi
+  assert "models-vhello-001 (vHello VNF creation)" true 
+  assert "models-tacker-003 (VNF creation)" true
+  assert "models-tacker-vnfd-002 (artifacts creation)" true
+  assert "models-tacker-vnfd-003 (user_data creation)" true
 
   echo "$0: $(date) verify contents of config drive are included in web page"
   id=$(curl $SERVER_URL | awk "/uuid/ { print \$2 }")
   if [[ -z "$id" ]]; then fail; fi
-
+  assert "models-tacker-vnfd-001 (config_drive creation)" true 
 }
 
 stop() {
   echo "$0: $(date) setup OpenStack CLI environment"
   source /tmp/tacker/admin-openrc.sh
 
-  if [[ "$1" == "tacker-api" ]]; then
-    echo "$0: $(date) Tacker API use is not yet implemented"
-  else
-    echo "$0: $(date) uninstall vHello blueprint via CLI"
-    vid=($(tacker vnf-list|grep hello-world-tacker|awk '{print $2}')); for id in ${vid[@]}; do tacker vnf-delete ${id};  done
-    vid=($(tacker vnfd-list|grep hello-world-tacker|awk '{print $2}')); for id in ${vid[@]}; do tacker vnfd-delete ${id};  done
-    fip=($(neutron floatingip-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${fip[@]}; do neutron floatingip-delete ${id};  done
-    sg=($(openstack security group list|grep vHello|awk '{print $2}'))
-    for id in ${sg[@]}; do try 5 5 "openstack security group delete ${id}";  done
-    iid=($(openstack image list|grep VNFImage|awk '{print $2}')); for id in ${iid[@]}; do openstack image delete ${id};  done
-    kid=($(openstack keypair list|grep vHello|awk '{print $2}')); for id in ${kid[@]}; do openstack keypair delete ${id};  done
-  fi
+  echo "$0: $(date) uninstall vHello blueprint via CLI"
+  vid=($(tacker vnf-list|grep hello-world-tacker|awk '{print $2}')); for id in ${vid[@]}; do tacker vnf-delete ${id}; done
+  assert "models-tacker-004 (VNF deletion)" [[ -z "$(tacker vnf-list|grep hello-world-tacker|awk '{print $2}'))" ]]
+
+  vid=($(tacker vnfd-list|grep hello-world-tacker|awk '{print $2}')); for id in ${vid[@]}; do tacker vnfd-delete ${id};  done
+  assert "models-tacker-005 (VNFD deletion)" [[ -z "$(tacker vnfd-list|grep hello-world-tacker|awk '{print $2}'))" ]]
+
+  iid=($(openstack image list|grep VNFImage|awk '{print $2}')); for id in ${iid[@]}; do openstack image delete ${id};  done
+  assert "models-tacker-vnfd-004 (artifacts deletion)" [[ -z "$(openstack image list|grep VNFImage|awk '{print $2}'))" ]]
+
+  # Cleanup for workarounds
+  fip=($(neutron floatingip-list|grep -v "+"|grep -v id|awk '{print $2}')); for id in ${fip[@]}; do neutron floatingip-delete ${id};  done
+  sg=($(openstack security group list|grep vHello|awk '{print $2}'))
+  for id in ${sg[@]}; do try 5 5 "openstack security group delete ${id}";  done
+  kid=($(openstack keypair list|grep vHello|awk '{print $2}')); for id in ${kid[@]}; do openstack keypair delete ${id};  done
 }
 
 forward_to_container () {
@@ -237,6 +245,12 @@ forward_to_container () {
 
 test_start=`date +%s`
 dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
+
+if [[ "$1" == "tacker-api" ]]; then
+  echo "$0: $(date) Tacker API use is not yet implemented"
+  fail
+fi
+
 case "$2" in
   setup)
     setup $1
@@ -259,6 +273,7 @@ case "$2" in
     pass
     ;;
   clean)
+    forward_to_container stop $2
     echo "$0: $(date) Uninstall Tacker and test environment"
     bash utils/tacker-setup.sh $1 clean
     if [ $? -eq 1 ]; then fail; fi