Use validate-for-proxyless

pull/22547/head
Eric Gribkoff 5 years ago
parent bc831fec51
commit d9c6b001c0
  1. 64
      tools/run_tests/run_xds_tests.py

@ -126,23 +126,18 @@ argp.add_argument(
'--alpha_compute_discovery_document', '--alpha_compute_discovery_document',
default=None, default=None,
type=str, type=str,
help= help='If provided, uses this file instead of retrieving via the alpha GCP '
'If provided, uses this file instead of retrieving via the alpha GCP '
'discovery API') 'discovery API')
argp.add_argument('--network', argp.add_argument('--network',
default='global/networks/default', default='global/networks/default',
help='GCP network to use') help='GCP network to use')
argp.add_argument('--service_port_range', argp.add_argument('--service_port_range',
default='80', default='8080:8110',
type=parse_port_range, type=parse_port_range,
help='Listening port for created gRPC backends. Specified as ' help='Listening port for created gRPC backends. Specified as '
'either a single int or as a range in the format min:max, in ' 'either a single int or as a range in the format min:max, in '
'which case an available port p will be chosen s.t. min <= p ' 'which case an available port p will be chosen s.t. min <= p '
'<= max') '<= max')
argp.add_argument('--forwarding_rule_ip_prefix',
default='172.16.0.',
help='If set, an available IP with this prefix followed by '
'0-255 will be used for the generated forwarding rule.')
argp.add_argument( argp.add_argument(
'--stats_port', '--stats_port',
default=8079, default=8079,
@ -651,12 +646,25 @@ def create_url_map(gcp, name, backend_service, host_name):
gcp.url_map = GcpResource(config['name'], result['targetLink']) gcp.url_map = GcpResource(config['name'], result['targetLink'])
def patch_url_map_host_rule(gcp, name, backend_service, host_name):
config = {
'hostRules': [{
'hosts': ['%s:%d' % (host_name, gcp.service_port)],
'pathMatcher': _PATH_MATCHER_NAME
}]
}
logger.debug('Sending GCP request with body=%s', config)
result = gcp.compute.urlMaps().patch(project=gcp.project,
urlMap=name,
body=config).execute()
wait_for_global_operation(gcp, result['name'])
def create_target_grpc_proxy(gcp, name): def create_target_grpc_proxy(gcp, name):
config = { config = {
'name': name, 'name': name,
'url_map': gcp.url_map.url, 'url_map': gcp.url_map.url,
# TODO(ericgribkoff) This requires forwarding rule's ip=0.0.0.0 'validate_for_proxyless': True,
# 'validate_for_proxyless': True,
} }
logger.debug('Sending GCP request with body=%s', config) logger.debug('Sending GCP request with body=%s', config)
result = gcp.alpha_compute.targetGrpcProxies().insert( result = gcp.alpha_compute.targetGrpcProxies().insert(
@ -665,15 +673,14 @@ def create_target_grpc_proxy(gcp, name):
gcp.target_grpc_proxy = GcpResource(config['name'], result['targetLink']) gcp.target_grpc_proxy = GcpResource(config['name'], result['targetLink'])
def create_global_forwarding_rule(gcp, name, potential_ips, potential_ports): def create_global_forwarding_rule(gcp, name, potential_ports):
for port in potential_ports: for port in potential_ports:
for ip in potential_ips:
try: try:
config = { config = {
'name': name, 'name': name,
'loadBalancingScheme': 'INTERNAL_SELF_MANAGED', 'loadBalancingScheme': 'INTERNAL_SELF_MANAGED',
'portRange': str(port), 'portRange': str(port),
'IPAddress': ip, 'IPAddress': '0.0.0.0',
'network': args.network, 'network': args.network,
'target': gcp.target_grpc_proxy.url, 'target': gcp.target_grpc_proxy.url,
} }
@ -681,15 +688,14 @@ def create_global_forwarding_rule(gcp, name, potential_ips, potential_ports):
result = gcp.alpha_compute.globalForwardingRules().insert( result = gcp.alpha_compute.globalForwardingRules().insert(
project=gcp.project, body=config).execute() project=gcp.project, body=config).execute()
wait_for_global_operation(gcp, result['name']) wait_for_global_operation(gcp, result['name'])
gcp.global_forwarding_rule = GcpResource( gcp.global_forwarding_rule = GcpResource(config['name'],
config['name'], result['targetLink']) result['targetLink'])
gcp.service_port = port gcp.service_port = port
return return
except googleapiclient.errors.HttpError as http_error: except googleapiclient.errors.HttpError as http_error:
logger.warning( logger.warning(
'Got error %s when attempting to create forwarding rule to ' 'Got error %s when attempting to create forwarding rule to '
'%s:%d. Retrying with another ip:port.' % '0.0.0.0:%d. Retrying with another port.' % (http_error, port))
(http_error, ip, port))
def delete_global_forwarding_rule(gcp): def delete_global_forwarding_rule(gcp):
@ -911,21 +917,6 @@ def get_instance_names(gcp, instance_group):
return instance_names return instance_names
def start_xds_client(cmd):
bootstrap_path = None
with tempfile.NamedTemporaryFile(delete=False) as bootstrap_file:
bootstrap_file.write(
_BOOTSTRAP_TEMPLATE.format(
node_id=socket.gethostname()).encode('utf-8'))
bootstrap_path = bootstrap_file.name
client_process = subprocess.Popen(shlex.split(cmd),
env=dict(
os.environ,
GRPC_XDS_BOOTSTRAP=bootstrap_path))
return client_process
def clean_up(gcp): def clean_up(gcp):
if gcp.global_forwarding_rule: if gcp.global_forwarding_rule:
delete_global_forwarding_rule(gcp) delete_global_forwarding_rule(gcp)
@ -1011,18 +1002,13 @@ try:
create_target_grpc_proxy(gcp, target_grpc_proxy_name) create_target_grpc_proxy(gcp, target_grpc_proxy_name)
potential_service_ports = list(args.service_port_range) potential_service_ports = list(args.service_port_range)
random.shuffle(potential_service_ports) random.shuffle(potential_service_ports)
if args.forwarding_rule_ip_prefix == '': create_global_forwarding_rule(gcp, forwarding_rule_name,
potential_ips = ['0.0.0.0']
else:
potential_ips = [
args.forwarding_rule_ip_prefix + str(x) for x in range(256)
]
random.shuffle(potential_ips)
create_global_forwarding_rule(gcp, forwarding_rule_name, potential_ips,
potential_service_ports) potential_service_ports)
if not gcp.service_port: if not gcp.service_port:
raise Exception( raise Exception(
'Failed to find a valid ip:port for the forwarding rule') 'Failed to find a valid ip:port for the forwarding rule')
patch_url_map_host_rule(gcp, url_map_name, backend_service,
service_host_name)
startup_script = get_startup_script(args.path_to_server_binary, startup_script = get_startup_script(args.path_to_server_binary,
gcp.service_port) gcp.service_port)
create_instance_template(gcp, template_name, args.network, create_instance_template(gcp, template_name, args.network,

Loading…
Cancel
Save