aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_tests/tests
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2017-01-10 11:58:40 -0800
committerGravatar ncteisen <ncteisen@gmail.com>2017-01-10 11:59:28 -0800
commitd70c8bb871c68d8d8fd96660236c96e48d71c00a (patch)
tree60087e5fa9e37d76f8c3a9729828c78e3ed59111 /src/python/grpcio_tests/tests
parenta3960b98d6a1b85a1e3b89cd7797a509505fa207 (diff)
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.
Diffstat (limited to 'src/python/grpcio_tests/tests')
-rw-r--r--src/python/grpcio_tests/tests/qps/benchmark_client.py8
-rw-r--r--src/python/grpcio_tests/tests/stress/client.py9
2 files changed, 8 insertions, 9 deletions
diff --git a/src/python/grpcio_tests/tests/qps/benchmark_client.py b/src/python/grpcio_tests/tests/qps/benchmark_client.py
index 83b46c914e..650e4756e7 100644
--- a/src/python/grpcio_tests/tests/qps/benchmark_client.py
+++ b/src/python/grpcio_tests/tests/qps/benchmark_client.py
@@ -68,12 +68,8 @@ class BenchmarkClient:
else:
channel = grpc.insecure_channel(server)
- connected_event = threading.Event()
- def wait_for_ready(connectivity):
- if connectivity == grpc.ChannelConnectivity.READY:
- connected_event.set()
- channel.subscribe(wait_for_ready, try_to_connect=True)
- connected_event.wait()
+ # waits for the channel to be ready before we start sending messages
+ grpc.channel_ready_future(channel).result()
if config.payload_config.WhichOneof('payload') == 'simple_params':
self._generic = False
diff --git a/src/python/grpcio_tests/tests/stress/client.py b/src/python/grpcio_tests/tests/stress/client.py
index 390ea13021..b8116729b5 100644
--- a/src/python/grpcio_tests/tests/stress/client.py
+++ b/src/python/grpcio_tests/tests/stress/client.py
@@ -110,10 +110,13 @@ def _get_channel(target, args):
channel_credentials = grpc.ssl_channel_credentials(
root_certificates=root_certificates)
options = (('grpc.ssl_target_name_override', args.server_host_override,),)
- return grpc.secure_channel(
- target, channel_credentials, options=options)
+ channel = grpc.secure_channel(target, channel_credentials, options=options)
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):
test_cases = _parse_weighted_test_cases(args.test_cases)