Add wait_for_instance_group_to_reach_expected_size

pull/23023/head
Eric Gribkoff 5 years ago
parent c3a464e742
commit 86a185b44a
  1. 26
      tools/run_tests/run_xds_tests.py

@ -582,6 +582,8 @@ def add_instance_group(gcp, zone, name, size):
instance_group = InstanceGroup(config['name'], result['instanceGroup'], instance_group = InstanceGroup(config['name'], result['instanceGroup'],
zone) zone)
gcp.instance_groups.append(instance_group) gcp.instance_groups.append(instance_group)
wait_for_instance_group_to_reach_expected_size(gcp, instance_group, size,
_WAIT_FOR_OPERATION_SEC)
return instance_group return instance_group
@ -936,14 +938,8 @@ def resize_instance_group(gcp,
instance_group.zone, instance_group.zone,
result['name'], result['name'],
timeout_sec=360) timeout_sec=360)
start_time = time.time() wait_for_instance_group_to_reach_expected_size(gcp, instance_group,
while True: new_size, timeout_sec)
current_size = len(get_instance_names(gcp, instance_group))
if current_size == new_size:
break
if time.time() - start_time > timeout_sec:
raise Exception('Failed to resize primary instance group')
time.sleep(2)
def patch_url_map_backend_service(gcp, backend_service): def patch_url_map_backend_service(gcp, backend_service):
@ -962,6 +958,20 @@ def patch_url_map_backend_service(gcp, backend_service):
wait_for_global_operation(gcp, result['name']) wait_for_global_operation(gcp, result['name'])
def wait_for_instance_group_to_reach_expected_size(gcp, instance_group,
expected_size, timeout_sec):
start_time = time.time()
while True:
current_size = len(get_instance_names(gcp, instance_group))
if current_size == expected_size:
break
if time.time() - start_time > timeout_sec:
raise Exception(
'Instance group had expected size %d but actual size %d' %
(expected_size, current_size))
time.sleep(2)
def wait_for_global_operation(gcp, def wait_for_global_operation(gcp,
operation, operation,
timeout_sec=_WAIT_FOR_OPERATION_SEC): timeout_sec=_WAIT_FOR_OPERATION_SEC):

Loading…
Cancel
Save