fix for sdnvpn testsuite execution stops abruptly
[sdnvpn.git] / sdnvpn / test / functest / testcase_1.py
index 1b51f00..74105de 100644 (file)
 
 import logging
 import sys
+import time
 
-from functest.utils import openstack_utils as os_utils
 from random import randint
 from sdnvpn.lib import config as sdnvpn_config
+from sdnvpn.lib import openstack_utils as os_utils
 from sdnvpn.lib import utils as test_utils
 from sdnvpn.lib.results import Results
 
@@ -154,13 +155,12 @@ def main():
         test_utils.create_network_association(
             neutron_client, bgpvpn_id, network_1_id)
 
-        # Wait for VMs to get ips.
-        instances_up = test_utils.wait_for_instances_up(vm_1, vm_2,
-                                                        vm_3, vm_4,
-                                                        vm_5)
+        # Wait for VMs to be ready.
+        instances_up = test_utils.wait_for_instances_up(vm_2, vm_3, vm_5)
+        instances_dhcp_up = test_utils.wait_for_instances_get_dhcp(vm_1, vm_4)
 
-        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
 
         results.get_ping_status(vm_1, vm_2, expected="PASS", timeout=200)
@@ -193,11 +193,46 @@ def main():
         results.add_to_summary(0, "-")
         results.record_action(msg)
         results.add_to_summary(0, "-")
-        kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
-                  "export_targets": TESTCASE_CONFIG.targets1,
-                  "name": vpn_name}
-        bgpvpn = test_utils.update_bgpvpn(neutron_client,
-                                          bgpvpn_id, **kwargs)
+
+        # use bgpvpn-create instead of update till NETVIRT-1067 bug is fixed
+        # kwargs = {"import_targets": TESTCASE_CONFIG.targets1,
+        #           "export_targets": TESTCASE_CONFIG.targets1,
+        #           "name": vpn_name}
+        # bgpvpn = test_utils.update_bgpvpn(neutron_client,
+        #                                   bgpvpn_id, **kwargs)
+
+        test_utils.delete_bgpvpn(neutron_client, bgpvpn_id)
+        bgpvpn_ids.remove(bgpvpn_id)
+        kwargs = {
+            "import_targets": TESTCASE_CONFIG.targets1,
+            "export_targets": TESTCASE_CONFIG.targets1,
+            "route_distinguishers": TESTCASE_CONFIG.route_distinguishers,
+            "name": vpn_name
+        }
+
+        test_utils.wait_before_subtest()
+
+        bgpvpn = test_utils.create_bgpvpn(neutron_client, **kwargs)
+        bgpvpn_id = bgpvpn['bgpvpn']['id']
+        logger.debug("VPN re-created details: %s" % bgpvpn)
+        bgpvpn_ids.append(bgpvpn_id)
+
+        msg = ("Associate network '%s' to the VPN." %
+               TESTCASE_CONFIG.net_1_name)
+        results.record_action(msg)
+        results.add_to_summary(0, "-")
+
+        test_utils.create_network_association(
+            neutron_client, bgpvpn_id, network_1_id)
+
+        test_utils.create_network_association(
+            neutron_client, bgpvpn_id, network_2_id)
+
+        test_utils.wait_for_bgp_net_assocs(neutron_client,
+                                           bgpvpn_id,
+                                           network_1_id,
+                                           network_2_id)
+        # The above code has to be removed after re-enabling bgpvpn-update
 
         logger.info("Waiting for the VMs to connect to each other using the"
                     " updated network configuration")