diff options
author | Tim Irnich <tim.irnich@ericsson.com> | 2017-11-09 08:05:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-11-09 08:05:15 +0000 |
commit | 9830307e679b928aae43e2b458228d0549693309 (patch) | |
tree | 5b4672ac16393ccb62c8a08e6073a80c5acf602b | |
parent | b1d450d9de366c60a4c24923b70575c600f423b3 (diff) | |
parent | a6e207c16430055eba8bcc8586b09a7081db3d04 (diff) |
Merge "Fix instance boot when metadata exists"
-rw-r--r-- | sdnvpn/lib/utils.py | 19 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_1.py | 11 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_10.py | 13 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_2.py | 16 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_4.py | 11 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_7.py | 10 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_8.py | 10 |
7 files changed, 48 insertions, 42 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index 1afccf7..67b75d0 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -247,13 +247,10 @@ def get_instance_ip(instance): return instance_ip -def wait_for_instance(instance): - logger.info("Waiting for instance %s to get a DHCP lease and " - "prompt for login..." % instance.id) - # The sleep this function replaced waited for 80s +def wait_for_instance(instance, pattern=".* login:"): + logger.info("Waiting for instance %s to boot up" % instance.id) tries = 40 sleep_time = 2 - pattern = ".* login:" expected_regex = re.compile(pattern) console_log = "" while tries > 0 and not expected_regex.search(console_log): @@ -262,14 +259,20 @@ def wait_for_instance(instance): tries -= 1 if not expected_regex.search(console_log): - logger.error("Instance %s seems not to boot up properly." + logger.error("Instance %s does not boot up properly." % instance.id) return False return True -def wait_for_instances_up(*args): - check = [wait_for_instance(instance) for instance in args] +def wait_for_instances_up(*instances): + check = [wait_for_instance(instance) for instance in instances] + return all(check) + + +def wait_for_instances_get_dhcp(*instances): + check = [wait_for_instance(instance, "Lease of .* obtained") + for instance in instances] return all(check) diff --git a/sdnvpn/test/functest/testcase_1.py b/sdnvpn/test/functest/testcase_1.py index 1b51f00..89011cd 100644 --- a/sdnvpn/test/functest/testcase_1.py +++ b/sdnvpn/test/functest/testcase_1.py @@ -154,13 +154,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) diff --git a/sdnvpn/test/functest/testcase_10.py b/sdnvpn/test/functest/testcase_10.py index 6344a17..02956c4 100644 --- a/sdnvpn/test/functest/testcase_10.py +++ b/sdnvpn/test/functest/testcase_10.py @@ -142,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() @@ -208,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 diff --git a/sdnvpn/test/functest/testcase_2.py b/sdnvpn/test/functest/testcase_2.py index 7594055..d136d8f 100644 --- a/sdnvpn/test/functest/testcase_2.py +++ b/sdnvpn/test/functest/testcase_2.py @@ -200,16 +200,12 @@ def main(): neutron_client, bgpvpn1_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 - ) - - if not instances_up: - logger.error("One or more instances is down") - sys.exit(-1) + instances_up = test_utils.wait_for_instances_up(vm_2) + instances_dhcp_up = test_utils.wait_for_instances_get_dhcp(vm_1, vm_4) + + if (not instances_up or not instances_dhcp_up): + logger.error("One or more instances are down") + # TODO: Handle this appropriately logger.info("Waiting for the VMs to connect to each other using the" " updated network configuration") diff --git a/sdnvpn/test/functest/testcase_4.py b/sdnvpn/test/functest/testcase_4.py index 5e6b2b8..cc429c3 100644 --- a/sdnvpn/test/functest/testcase_4.py +++ b/sdnvpn/test/functest/testcase_4.py @@ -162,13 +162,12 @@ def main(): neutron_client, bgpvpn_id, router_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) + 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") - # TODO Handle appropriately + 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) results.get_ping_status(vm_1, vm_3, expected="PASS", timeout=30) diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py index 2d9e713..0e3a8f5 100644 --- a/sdnvpn/test/functest/testcase_7.py +++ b/sdnvpn/test/functest/testcase_7.py @@ -132,9 +132,13 @@ def main(): test_utils.wait_for_bgp_net_assoc( neutron_client, bgpvpn_id, network_2_id) - instances_up = test_utils.wait_for_instances_up(vm_1, vm_2) - if not instances_up: - logger.error("One or more instances is down") + # Wait for VMs to get ips. + instances_up = test_utils.wait_for_instances_up(vm_2) + instances_dhcp_up = test_utils.wait_for_instances_get_dhcp(vm_1) + + if (not instances_up or not instances_dhcp_up): + logger.error("One or more instances are down") + # TODO: Handle this appropriately logger.info("Waiting for the VMs to connect to each other using the" " updated network configuration") diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py index fb54761..e372fe1 100644 --- a/sdnvpn/test/functest/testcase_8.py +++ b/sdnvpn/test/functest/testcase_8.py @@ -131,9 +131,13 @@ def main(): test_utils.wait_for_bgp_net_assoc( neutron_client, bgpvpn_id, network_2_id) - instances_up = test_utils.wait_for_instances_up(vm_1, vm_2) - if not instances_up: - logger.error("One or more instances is down") + # Wait for VMs to get ips. + instances_up = test_utils.wait_for_instances_up(vm_2) + instances_dhcp_up = test_utils.wait_for_instances_get_dhcp(vm_1) + + if (not instances_up or not instances_dhcp_up): + logger.error("One or more instances are down") + # TODO: Handle this appropriately logger.info("Waiting for the VMs to connect to each other using the" " updated network configuration") |