Merge "Fix instance boot when metadata exists"
[sdnvpn.git] / sdnvpn / test / functest / testcase_10.py
index 5c0e99b..02956c4 100644 (file)
@@ -8,12 +8,10 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 #
 
-import argparse
 import logging
 import re
 import sys
 import time
-import traceback
 
 from functest.utils import openstack_utils as os_utils
 from multiprocessing import Process, Manager, Lock
@@ -21,13 +19,6 @@ from sdnvpn.lib import config as sdnvpn_config
 from sdnvpn.lib import utils as test_utils
 from sdnvpn.lib.results import Results
 
-parser = argparse.ArgumentParser()
-
-parser.add_argument("-r", "--report",
-                    help="Create json result file",
-                    action="store_true")
-
-args = parser.parse_args()
 
 logger = logging.getLogger('__name__')
 
@@ -151,11 +142,11 @@ def main():
     instance_ids.extend([vm_1.id, vm_3.id])
 
     # Wait for VMs to get ips.
-    instances_up = test_utils.wait_for_instances_up(vm_1, vm_2,
-                                                    vm_3)
+    instances_up = test_utils.wait_for_instances_up(vm_2)
+    instances_dhcp_up = test_utils.wait_for_instances_get_dhcp(vm_1, vm_3)
 
-    if not instances_up:
-        logger.error("One or more instances is down")
+    if (not instances_up or not instances_dhcp_up):
+        logger.error("One or more instances are down")
         # TODO: Handle this appropriately
     # Create monitor threads to monitor traffic between vm_1, vm_2 and vm_3
     m = Manager()
@@ -217,9 +208,10 @@ def main():
             compute_node=av_zone_1,
             userdata=u4)
         instance_ids.append(vm_4.id)
+
         # Wait for VMs to get ips.
-        instances_up = test_utils.wait_for_instances_up(vm_4)
-        if not instances_up:
+        instances_dhcp_up = test_utils.wait_for_instances_get_dhcp(vm_4)
+        if not instances_dhcp_up:
             logger.error("Instance vm_4 failed to start.")
             # TODO: Handle this appropriately
         # Create and start a new monitor thread for vm_4
@@ -249,10 +241,9 @@ def main():
         else:
             results.add_failure(monitor_err_msg)
 
-    except:
-        logging.exception("======== EXCEPTION =========")
-        exc_type, exc_value, exc_tb = sys.exc_info()
-        traceback.print_exception(exc_type, exc_value, exc_tb)
+    except Exception as e:
+        logger.error("exception occurred while executing testcase_10: %s", e)
+        raise
     finally:
         # Give a stop signal to all threads
         logging.info("Sending stop signal to monitor thread")
@@ -262,10 +253,11 @@ def main():
         for thread in threads:
             thread.join()
 
-    test_utils.cleanup_nova(nova_client, instance_ids, image_ids)
-    test_utils.cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids,
-                               interfaces, subnet_ids, router_ids,
-                               network_ids)
+        test_utils.cleanup_nova(nova_client, instance_ids)
+        test_utils.cleanup_glance(glance_client, image_ids)
+        test_utils.cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids,
+                                   interfaces, subnet_ids, router_ids,
+                                   network_ids)
 
     return results.compile_summary()