Skip to content
Snippets Groups Projects
Commit d70c8bb8 authored by ncteisen's avatar ncteisen
Browse files

Implement wait-for-ready behavior in Python stress and qps client

The clients now block until the channel is in the READY state. This
fixes some test flakiness issues we have had.
parent a3960b98
No related branches found
No related tags found
No related merge requests found
...@@ -68,12 +68,8 @@ class BenchmarkClient: ...@@ -68,12 +68,8 @@ class BenchmarkClient:
else: else:
channel = grpc.insecure_channel(server) channel = grpc.insecure_channel(server)
connected_event = threading.Event() # waits for the channel to be ready before we start sending messages
def wait_for_ready(connectivity): grpc.channel_ready_future(channel).result()
if connectivity == grpc.ChannelConnectivity.READY:
connected_event.set()
channel.subscribe(wait_for_ready, try_to_connect=True)
connected_event.wait()
if config.payload_config.WhichOneof('payload') == 'simple_params': if config.payload_config.WhichOneof('payload') == 'simple_params':
self._generic = False self._generic = False
......
...@@ -110,10 +110,13 @@ def _get_channel(target, args): ...@@ -110,10 +110,13 @@ def _get_channel(target, args):
channel_credentials = grpc.ssl_channel_credentials( channel_credentials = grpc.ssl_channel_credentials(
root_certificates=root_certificates) root_certificates=root_certificates)
options = (('grpc.ssl_target_name_override', args.server_host_override,),) options = (('grpc.ssl_target_name_override', args.server_host_override,),)
return grpc.secure_channel( channel = grpc.secure_channel(target, channel_credentials, options=options)
target, channel_credentials, options=options)
else: else:
return grpc.insecure_channel(target) channel = grpc.insecure_channel(target)
# waits for the channel to be ready before we start sending messages
grpc.channel_ready_future(channel).result()
return channel
def run_test(args): def run_test(args):
test_cases = _parse_weighted_test_cases(args.test_cases) test_cases = _parse_weighted_test_cases(args.test_cases)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment