Fix potential_service_ports uninitialized variable error (#26836)

* Fix potential_service_ports uninitialized variable error

When args.use_existing_gcp_resources is true(some of our testing environments set this), potential_service_ports is never set, which breaks some tests like test_api_listener

* Fix potentiel undefined variable error
pull/26870/head
Eric Gribkoff 3 years ago committed by GitHub
parent a48067c4c8
commit aeef9aa8cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      tools/run_tests/run_xds_tests.py

@ -1169,6 +1169,7 @@ def test_api_listener(gcp, backend_service, instance_group,
alternate_backend_service):
logger.info("Running api_listener")
passed = True
new_config_suffix = ''
try:
wait_for_healthy_backends(gcp, backend_service, instance_group)
backend_instances = get_instance_names(gcp, instance_group)
@ -3139,6 +3140,8 @@ try:
instance_group_name = _BASE_INSTANCE_GROUP_NAME + gcp_suffix
same_zone_instance_group_name = _BASE_INSTANCE_GROUP_NAME + '-same-zone' + gcp_suffix
secondary_zone_instance_group_name = _BASE_INSTANCE_GROUP_NAME + '-secondary-zone' + gcp_suffix
potential_service_ports = list(args.service_port_range)
random.shuffle(potential_service_ports)
if args.use_existing_gcp_resources:
logger.info('Reusing existing GCP resources')
get_health_check(gcp, health_check_name)
@ -3164,8 +3167,6 @@ try:
gcp, alternate_backend_service_name)
create_url_map(gcp, url_map_name, backend_service, service_host_name)
create_target_proxy(gcp, target_proxy_name)
potential_service_ports = list(args.service_port_range)
random.shuffle(potential_service_ports)
create_global_forwarding_rule(gcp, forwarding_rule_name,
potential_service_ports)
if not gcp.service_port:

Loading…
Cancel
Save