|
|
|
@ -17,6 +17,7 @@ import asyncio |
|
|
|
|
import logging |
|
|
|
|
import platform |
|
|
|
|
import random |
|
|
|
|
import errno |
|
|
|
|
import unittest |
|
|
|
|
|
|
|
|
|
import grpc |
|
|
|
@ -37,11 +38,13 @@ _OPTIONS = ( |
|
|
|
|
(_DISABLE_REUSE_PORT, ((_SOCKET_OPT_SO_REUSEPORT, 0),)), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
_NUM_SERVER_CREATED = 100 |
|
|
|
|
_NUM_SERVER_CREATED = 10 |
|
|
|
|
|
|
|
|
|
_GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH = 'grpc.max_receive_message_length' |
|
|
|
|
_MAX_MESSAGE_LENGTH = 1024 |
|
|
|
|
|
|
|
|
|
_ADDRESS_TOKEN_ERRNO = errno.EADDRINUSE, errno.ENOSR |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _TestPointerWrapper(object): |
|
|
|
|
|
|
|
|
@ -78,8 +81,11 @@ async def test_if_reuse_port_enabled(server: aio.Server): |
|
|
|
|
) as (unused_host, bound_port): |
|
|
|
|
assert bound_port == port |
|
|
|
|
except OSError as e: |
|
|
|
|
assert 'Address already in use' in str(e) |
|
|
|
|
return False |
|
|
|
|
if e.errno in _ADDRESS_TOKEN_ERRNO: |
|
|
|
|
return False |
|
|
|
|
else: |
|
|
|
|
logging.exception(e) |
|
|
|
|
raise |
|
|
|
|
else: |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|