pull/24547/head
Eric Gribkoff 4 years ago
parent f73d7af85d
commit 2f2abdf22a
  1. 69
      tools/run_tests/run_xds_tests.py

@ -227,10 +227,9 @@ args = argp.parse_args()
if args.verbose: if args.verbose:
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
CLIENT_HOSTS = [] CLIENT_HOSTS = []
if args.client_hosts: if args.client_hosts:
CLIENT_HOSTS = args.client_hosts.split(',') CLIENT_HOSTS = args.client_hosts.split(',')
_DEFAULT_SERVICE_PORT = 80 _DEFAULT_SERVICE_PORT = 80
_WAIT_FOR_BACKEND_SEC = args.wait_for_backend_sec _WAIT_FOR_BACKEND_SEC = args.wait_for_backend_sec
@ -293,22 +292,24 @@ _SPONGE_XML_NAME = 'sponge_log.xml'
def get_client_stats(num_rpcs, timeout_sec): def get_client_stats(num_rpcs, timeout_sec):
if CLIENT_HOSTS: if CLIENT_HOSTS:
hosts = CLIENT_HOSTS hosts = CLIENT_HOSTS
else: else:
hosts = ['localhost'] hosts = ['localhost']
for host in hosts: for host in hosts:
with grpc.insecure_channel('%s:%d' % (host, args.stats_port)) as channel: with grpc.insecure_channel('%s:%d' %
stub = test_pb2_grpc.LoadBalancerStatsServiceStub(channel) (host, args.stats_port)) as channel:
request = messages_pb2.LoadBalancerStatsRequest() stub = test_pb2_grpc.LoadBalancerStatsServiceStub(channel)
request.num_rpcs = num_rpcs request = messages_pb2.LoadBalancerStatsRequest()
request.timeout_sec = timeout_sec request.num_rpcs = num_rpcs
rpc_timeout = timeout_sec + _CONNECTION_TIMEOUT_SEC request.timeout_sec = timeout_sec
logger.debug('Invoking GetClientStats RPC to %s:%d:', host, args.stats_port) rpc_timeout = timeout_sec + _CONNECTION_TIMEOUT_SEC
response = stub.GetClientStats(request, logger.debug('Invoking GetClientStats RPC to %s:%d:', host,
wait_for_ready=True, args.stats_port)
timeout=rpc_timeout) response = stub.GetClientStats(request,
logger.debug('Invoked GetClientStats RPC to %s: %s', host, response) wait_for_ready=True,
return response timeout=rpc_timeout)
logger.debug('Invoked GetClientStats RPC to %s: %s', host, response)
return response
class RpcDistributionError(Exception): class RpcDistributionError(Exception):
@ -1667,10 +1668,10 @@ try:
health_check_name = _BASE_HEALTH_CHECK_NAME + gcp_suffix health_check_name = _BASE_HEALTH_CHECK_NAME + gcp_suffix
if not args.use_existing_gcp_resources: if not args.use_existing_gcp_resources:
if gcp_suffix: if gcp_suffix:
num_attempts = 5 num_attempts = 5
else: else:
# If not given a suffix, do not retry if already in use. # If not given a suffix, do not retry if already in use.
num_attempts = 1 num_attempts = 1
for i in range(num_attempts): for i in range(num_attempts):
try: try:
logger.info('Using GCP suffix %s', gcp_suffix) logger.info('Using GCP suffix %s', gcp_suffix)
@ -1813,22 +1814,21 @@ try:
# resources). # resources).
fail_on_failed_rpc = '' fail_on_failed_rpc = ''
try: try:
if not CLIENT_HOSTS: if not CLIENT_HOSTS:
client_cmd_formatted = args.client_cmd.format( client_cmd_formatted = args.client_cmd.format(
server_uri=server_uri, server_uri=server_uri,
stats_port=args.stats_port, stats_port=args.stats_port,
qps=args.qps, qps=args.qps,
fail_on_failed_rpc=fail_on_failed_rpc, fail_on_failed_rpc=fail_on_failed_rpc,
rpcs_to_send=rpcs_to_send, rpcs_to_send=rpcs_to_send,
metadata_to_send=metadata_to_send) metadata_to_send=metadata_to_send)
logger.debug('running client: %s', client_cmd_formatted) logger.debug('running client: %s', client_cmd_formatted)
client_cmd = shlex.split(client_cmd_formatted) client_cmd = shlex.split(client_cmd_formatted)
client_process = subprocess.Popen(client_cmd, client_process = subprocess.Popen(client_cmd,
env=client_env, env=client_env,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
stdout=test_log_file) stdout=test_log_file)
if test_case == 'backends_restart': if test_case == 'backends_restart':
test_backends_restart(gcp, backend_service, instance_group) test_backends_restart(gcp, backend_service, instance_group)
elif test_case == 'change_backend_service': elif test_case == 'change_backend_service':
@ -1884,7 +1884,8 @@ try:
finally: finally:
if client_process: if client_process:
if client_process.returncode: if client_process.returncode:
logger.info('Client exited with code %d' % client_process.returncode) logger.info('Client exited with code %d' %
client_process.returncode)
else: else:
client_process.terminate() client_process.terminate()
test_log_file.close() test_log_file.close()

Loading…
Cancel
Save