Integrate with asyncio tests

pull/20838/head
Richard Belleville 5 years ago
parent bf7accb2db
commit 349d79cae9
  1. 22
      src/python/grpcio_tests/tests_aio/unit/BUILD.bazel
  2. 16
      src/python/grpcio_tests/tests_aio/unit/test_base.py

@ -19,8 +19,27 @@ package(
GRPC_ASYNC_TESTS = [
"server_test.py",
"init_test.py",
"channel_test.py",
]
py_library(
name = "test_base",
srcs = ["test_base.py"],
srcs_version = "PY3",
)
py_library(
name = "sync_server",
srcs = ["sync_server.py"],
deps = [
"//src/proto/grpc/testing:empty_py_pb2",
"//src/proto/grpc/testing:py_messages_proto",
"//src/proto/grpc/testing:test_py_pb2_grpc",
],
srcs_version = "PY3",
)
[
py_test(
name=test_file_name[:-3],
@ -33,6 +52,9 @@ GRPC_ASYNC_TESTS = [
"//src/proto/grpc/testing:py_messages_proto",
"//src/proto/grpc/testing:benchmark_service_py_pb2_grpc",
"//src/proto/grpc/testing:benchmark_service_py_pb2",
"//src/python/grpcio_tests/tests/unit/framework/common",
":test_base",
":sync_server",
"//external:six"
],
imports=["../../",],

@ -22,21 +22,11 @@ import socket
from grpc.experimental import aio
from tests_aio.unit import sync_server
from tests.unit.framework.common import get_socket
def _get_free_loopback_tcp_port():
if socket.has_ipv6:
tcp_socket = socket.socket(socket.AF_INET6)
host = "::1"
host_target = "[::1]"
else:
tcp_socket = socket.socket(socket.AF_INET)
host = "127.0.0.1"
host_target = host
tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
tcp_socket.bind((host, 0))
address_tuple = tcp_socket.getsockname()
return tcp_socket, "%s:%s" % (host_target, address_tuple[1])
host, port, sock = get_socket(listen=False)
return sock, "{}:{}".format(host, port)
class _Server:

Loading…
Cancel
Save