summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
4245d81)
The way that a instance is considered as UP is pretty
strict and returns ERROR in case of instances with userdata
This patch differentiates the instances that are supposed to
boot till login prompt and those with userdata parameter
JIRA: SDNVPN-177
Change-Id: Ic4755366df006669475c90cc0693ac802256f379
Signed-off-by: tomsou <soth@intracom-telecom.com>
-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
tries = 40
sleep_time = 2
expected_regex = re.compile(pattern)
console_log = ""
while tries > 0 and not expected_regex.search(console_log):
expected_regex = re.compile(pattern)
console_log = ""
while tries > 0 and not expected_regex.search(console_log):
tries -= 1
if not expected_regex.search(console_log):
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
% 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]
test_utils.create_network_association(
neutron_client, bgpvpn_id, network_1_id)
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)
# TODO: Handle this appropriately
results.get_ping_status(vm_1, vm_2, expected="PASS", timeout=200)
instance_ids.extend([vm_1.id, vm_3.id])
# Wait for VMs to get ips.
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()
# TODO: Handle this appropriately
# Create monitor threads to monitor traffic between vm_1, vm_2 and vm_3
m = Manager()
compute_node=av_zone_1,
userdata=u4)
instance_ids.append(vm_4.id)
compute_node=av_zone_1,
userdata=u4)
instance_ids.append(vm_4.id)
# Wait for VMs to get ips.
# 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
logger.error("Instance vm_4 failed to start.")
# TODO: Handle this appropriately
# Create and start a new monitor thread for vm_4
neutron_client, bgpvpn1_id, network_1_id)
# Wait for VMs to get ips.
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")
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
neutron_client, bgpvpn_id, router_1_id)
# Wait for VMs to get ips.
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)
results.get_ping_status(vm_1, vm_2, expected="PASS", timeout=200)
results.get_ping_status(vm_1, vm_3, expected="PASS", timeout=30)
test_utils.wait_for_bgp_net_assoc(
neutron_client, bgpvpn_id, network_2_id)
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")
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")
test_utils.wait_for_bgp_net_assoc(
neutron_client, bgpvpn_id, network_2_id)
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")
logger.info("Waiting for the VMs to connect to each other using the"
" updated network configuration")