summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sdnvpn/lib/utils.py19
-rw-r--r--sdnvpn/test/functest/testcase_1.py11
-rw-r--r--sdnvpn/test/functest/testcase_10.py13
-rw-r--r--sdnvpn/test/functest/testcase_2.py16
-rw-r--r--sdnvpn/test/functest/testcase_4.py11
-rw-r--r--sdnvpn/test/functest/testcase_7.py10
-rw-r--r--sdnvpn/test/functest/testcase_8.py10
7 files changed, 48 insertions, 42 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 371f3ed..57cf722 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 718f305..2c4ddbe 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 557b658..5a88603 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 bc37c5c..928656e 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 f6748f9..9b1c1fa 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 65a77b6..e018022 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 abb111f..b166362 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")