diff options
author | Naresh <ghostwriternr@gmail.com> | 2018-10-03 11:11:27 +0000 |
---|---|---|
committer | Naresh <ghostwriternr@gmail.com> | 2018-10-03 11:11:27 +0000 |
commit | e80230ae6f6c77e9450e766c3741378318ab13d5 (patch) | |
tree | 1e055264009beb3509b323555ef6c8406acfc473 | |
parent | e916e79cb88b007559e079a8cac2250105a76954 (diff) |
Add Bazel targets for Python unit tests
There are exactly 50 tests under grpcio_tests/tests/testing and
grpcio_tests/tests/unit for gRPC Python. Add Bazel targets for 44 of
them. unit._reconnect_test has been left out for now due to an
unexpected RuntimeError (#16336) and unit._server_ssl_cert_config_test
because of changes needed to the import path within
src/python/grpcio_tests/tests/testing/proto/services.proto (will
possibly be included as a fix to #15370).
The count of tests here is reported the way unittest counts tests, which
is the number of individual unit test classes it sees. This will be
different from Bazel's count, which counts the number of Bazel test
targets, which (by convention mostly) is one per test module.
6 files changed, 255 insertions, 0 deletions
diff --git a/src/python/grpcio_tests/tests/testing/BUILD.bazel b/src/python/grpcio_tests/tests/testing/BUILD.bazel new file mode 100644 index 0000000000..9bdd616c56 --- /dev/null +++ b/src/python/grpcio_tests/tests/testing/BUILD.bazel @@ -0,0 +1,30 @@ +package(default_visibility = ["//visibility:public"]) + +py_library( + name = "testing", + srcs = ["__init__.py",], + deps = [ + # ":_application_common", + ":_server_application", + ], +) + +# TODO(ghostwriternr): To be added later. +# py_library( +# name = "_application_common", +# srcs = ["_application_common.py",], +# deps = [ +# "//src/python/grpcio_tests/tests/testing/proto:requests", +# "//src/python/grpcio_tests/tests/testing/proto:services", +# ], +# imports = ["../../",], +# ) + +py_library( + name = "_server_application", + srcs = ["_server_application.py",], + imports = ["../../",], +) + + + diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel new file mode 100644 index 0000000000..dcd6d9fbb2 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -0,0 +1,83 @@ +load("@grpc_python_dependencies//:requirements.bzl", "requirement") + +package(default_visibility = ["//visibility:public"]) + +GRPCIO_TESTS_UNIT = [ + "_api_test.py", + "_auth_context_test.py", + "_auth_test.py", + "_channel_args_test.py", + "_channel_close_test.py", + "_channel_connectivity_test.py", + "_channel_ready_future_test.py", + "_compression_test.py", + "_credentials_test.py", + "_empty_message_test.py", + "_exit_test.py", + "_interceptor_test.py", + "_invalid_metadata_test.py", + "_invocation_defects_test.py", + "_metadata_code_details_test.py", + "_metadata_test.py", + # TODO: Issue 16336 + # "_reconnect_test.py", + "_resource_exhausted_test.py", + "_rpc_test.py", + # TODO(ghostwriternr): To be added later. + # "_server_ssl_cert_config_test.py", + "_server_test.py", + "_session_cache_test.py", +] + +py_library( + name = "resources", + srcs = ["resources.py"], + data=[ + "//src/python/grpcio_tests/tests/unit/credentials", + ], +) + +py_library( + name = "test_common", + srcs = ["test_common.py"], +) + +py_library( + name = "_exit_scenarios", + srcs = ["_exit_scenarios.py"], +) + +py_library( + name = "_thread_pool", + srcs = ["_thread_pool.py"], +) + +py_library( + name = "_from_grpc_import_star", + srcs = ["_from_grpc_import_star.py"], +) + +[ + py_test( + name=test_file_name[:-3], + size="small", + srcs=[test_file_name], + main=test_file_name, + deps=[ + "//src/python/grpcio/grpc:grpcio", + ":resources", + ":test_common", + ":_exit_scenarios", + ":_thread_pool", + ":_from_grpc_import_star", + "//src/python/grpcio_tests/tests/unit/framework/common", + "//src/python/grpcio_tests/tests/testing", + requirement('six'), + ], + imports=["../../",], + data=[ + "//src/python/grpcio_tests/tests/unit/credentials", + ], + ) for test_file_name in GRPCIO_TESTS_UNIT +] + diff --git a/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel new file mode 100644 index 0000000000..458a6b1fb8 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_cython/BUILD.bazel @@ -0,0 +1,46 @@ +load("@grpc_python_dependencies//:requirements.bzl", "requirement") + +package(default_visibility = ["//visibility:public"]) + +GRPCIO_TESTS_UNIT_CYTHON = [ + "_cancel_many_calls_test.py", + "_channel_test.py", + "_no_messages_server_completion_queue_per_call_test.py", + "_no_messages_single_server_completion_queue_test.py", + "_read_some_but_not_all_responses_test.py", + "_server_test.py", + "cygrpc_test.py", +] + +py_library( + name = "common", + srcs = ["_common.py"], +) + +py_library( + name = "test_utilities", + srcs = ["test_utilities.py"], +) + +[ + py_test( + name=test_file_name[:-3], + size="small", + srcs=[test_file_name], + main=test_file_name, + deps=[ + "//src/python/grpcio/grpc:grpcio", + ":common", + ":test_utilities", + "//src/python/grpcio_tests/tests/unit/framework/common", + "//src/python/grpcio_tests/tests/unit:test_common", + "//src/python/grpcio_tests/tests/unit:resources", + ], + imports=["../../../",], + data=[ + "//src/python/grpcio_tests/tests/unit/credentials", + ], + ) for test_file_name in GRPCIO_TESTS_UNIT_CYTHON +] + + diff --git a/src/python/grpcio_tests/tests/unit/beta/BUILD.bazel b/src/python/grpcio_tests/tests/unit/beta/BUILD.bazel new file mode 100644 index 0000000000..d3e0fe20eb --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/beta/BUILD.bazel @@ -0,0 +1,75 @@ +load("@grpc_python_dependencies//:requirements.bzl", "requirement") + +package(default_visibility = ["//visibility:public"]) + +py_library( + name = "test_utilities", + srcs = ["test_utilities.py"], + deps = [ + "//src/python/grpcio/grpc:grpcio", + ], +) + +py_test( + name = "_beta_features_test", + srcs = ["_beta_features_test.py"], + main = "_beta_features_test.py", + size = "small", + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_tests/tests/unit:resources", + "//src/python/grpcio_tests/tests/unit/framework/common", + ":test_utilities", + ], + imports=["../../../",], +) + +py_test( + name = "_connectivity_channel_test", + srcs = ["_connectivity_channel_test.py"], + main = "_connectivity_channel_test.py", + size = "small", + deps = [ + "//src/python/grpcio/grpc:grpcio", + ], +) + +# TODO(ghostwriternr): To be added later. +#py_test( +# name = "_implementations_test", +# srcs = ["_implementations_test.py"], +# main = "_implementations_test.py", +# size = "small", +# deps = [ +# "//src/python/grpcio/grpc:grpcio", +# "//src/python/grpcio_tests/tests/unit:resources", +# requirement('oauth2client'), +# ], +# imports=["../../../",], +#) + +py_test( + name = "_not_found_test", + srcs = ["_not_found_test.py"], + main = "_not_found_test.py", + size = "small", + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_tests/tests/unit/framework/common", + ], + imports=["../../../",], +) + +py_test( + name = "_utilities_test", + srcs = ["_utilities_test.py"], + main = "_utilities_test.py", + size = "small", + deps = [ + "//src/python/grpcio/grpc:grpcio", + "//src/python/grpcio_tests/tests/unit/framework/common", + ], + imports=["../../../",], +) + + diff --git a/src/python/grpcio_tests/tests/unit/credentials/BUILD.bazel b/src/python/grpcio_tests/tests/unit/credentials/BUILD.bazel new file mode 100644 index 0000000000..358216db58 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/credentials/BUILD.bazel @@ -0,0 +1,10 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name="credentials", + srcs=glob([ + "**", + ]), +) + + diff --git a/src/python/grpcio_tests/tests/unit/framework/common/BUILD.bazel b/src/python/grpcio_tests/tests/unit/framework/common/BUILD.bazel new file mode 100644 index 0000000000..c206a04fad --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/framework/common/BUILD.bazel @@ -0,0 +1,11 @@ +package(default_visibility = ["//visibility:public"]) + +py_library( + name = "common", + srcs = [ + "test_constants.py", + "test_control.py", + "test_coverage.py", + ], +) + |