Incorporate review comments

pull/20838/head
Richard Belleville 5 years ago
parent 90ee052cb8
commit 026d0e6af6
  1. 2
      src/python/grpcio_tests/tests/unit/_metadata_flags_test.py
  2. 36
      src/python/grpcio_tests/tests/unit/_reconnect_test.py
  3. 4
      src/python/grpcio_tests/tests/unit/test_common.py

@ -228,7 +228,7 @@ class MetadataFlagsTest(unittest.TestCase):
# Start the server after the connections are waiting
wg.wait()
server = test_common.test_server()
server = test_common.test_server(reuse_port=True)
server.add_generic_rpc_handlers((_GenericHandler(
weakref.proxy(self)),))
server.add_insecure_port(addr)

@ -42,24 +42,26 @@ class ReconnectTest(unittest.TestCase):
'UnaryUnary':
grpc.unary_unary_rpc_method_handler(_handle_unary_unary)
})
with bound_socket() as (_, port):
server = grpc.server(server_pool, (handler,))
server.add_insecure_port('[::]:{}'.format(port))
options=(('grpc.so_reuseport', 0),)
with bound_socket() as (host, port):
addr = '{}:{}'.format(host, port)
server = grpc.server(server_pool, (handler,), options=options)
server.add_insecure_port(addr)
server.start()
channel = grpc.insecure_channel('localhost:%d' % port)
multi_callable = channel.unary_unary(_UNARY_UNARY)
self.assertEqual(_RESPONSE, multi_callable(_REQUEST))
server.stop(None)
# By default, the channel connectivity is checked every 5s
# GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS can be set to change
# this.
time.sleep(5.1)
server = grpc.server(server_pool, (handler,))
server.add_insecure_port('[::]:{}'.format(port))
server.start()
self.assertEqual(_RESPONSE, multi_callable(_REQUEST))
server.stop(None)
channel.close()
channel = grpc.insecure_channel(addr)
multi_callable = channel.unary_unary(_UNARY_UNARY)
self.assertEqual(_RESPONSE, multi_callable(_REQUEST))
server.stop(None)
# By default, the channel connectivity is checked every 5s
# GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS can be set to change
# this.
time.sleep(5.1)
server = grpc.server(server_pool, (handler,), options=options)
server.add_insecure_port(addr)
server.start()
self.assertEqual(_RESPONSE, multi_callable(_REQUEST))
server.stop(None)
channel.close()
if __name__ == '__main__':

@ -100,14 +100,14 @@ def test_secure_channel(target, channel_credentials, server_host_override):
return channel
def test_server(max_workers=10):
def test_server(max_workers=10, reuse_port=False):
"""Creates an insecure grpc server.
These servers have SO_REUSEPORT disabled to prevent cross-talk.
"""
return grpc.server(
futures.ThreadPoolExecutor(max_workers=max_workers),
options=(('grpc.so_reuseport', 0),))
options=(('grpc.so_reuseport', int(reuse_port)),))
class WaitGroup(object):

Loading…
Cancel
Save