Skip to content

Commit cd93175

Browse files
Bazel rules for gRPC Python interop tests
Add interop tests for gRPC Python. py_proto_library rules are added to src/proto/grpc/testing/BUILD since grpc_proto_library is not compatible with py_* rules. 'requests' python module is added to requirements.bazel.txt as it is a dependency for google-auth. Previously, this was installed through tools/run_tests/helper_scripts/build_python.sh before running tests.
1 parent e4382ab commit cd93175

4 files changed

Lines changed: 130 additions & 0 deletions

File tree

requirements.bazel.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ wheel>=0.29
88
futures>=2.2.0
99
google-auth>=1.0.0
1010
oauth2client==4.1.0
11+
requests>=2.14.2

src/proto/grpc/testing/BUILD

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ grpc_proto_library(
7575
has_services = False,
7676
)
7777

78+
py_proto_library(
79+
name = "py_messages_proto",
80+
protos = ["messages.proto",],
81+
with_grpc = True,
82+
deps = [
83+
requirement('protobuf'),
84+
],
85+
)
86+
7887
grpc_proto_library(
7988
name = "metrics_proto",
8089
srcs = ["metrics.proto"],
@@ -127,3 +136,17 @@ grpc_proto_library(
127136
"messages_proto",
128137
],
129138
)
139+
140+
py_proto_library(
141+
name = "py_test_proto",
142+
protos = ["test.proto",],
143+
with_grpc = True,
144+
deps = [
145+
requirement('protobuf'),
146+
],
147+
proto_deps = [
148+
":py_empty_proto",
149+
":py_messages_proto",
150+
]
151+
)
152+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
load("@grpc_python_dependencies//:requirements.bzl", "requirement")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
py_library(
6+
name = "_intraop_test_case",
7+
srcs = ["_intraop_test_case.py"],
8+
deps = [
9+
":methods",
10+
],
11+
imports=["../../",],
12+
)
13+
14+
py_library(
15+
name = "client",
16+
srcs = ["client.py"],
17+
deps = [
18+
"//src/python/grpcio/grpc:grpcio",
19+
":methods",
20+
":resources",
21+
"//src/proto/grpc/testing:py_test_proto",
22+
requirement('google-auth'),
23+
],
24+
imports=["../../",],
25+
)
26+
27+
py_library(
28+
name = "methods",
29+
srcs = ["methods.py"],
30+
deps = [
31+
"//src/python/grpcio/grpc:grpcio",
32+
"//src/proto/grpc/testing:py_empty_proto",
33+
"//src/proto/grpc/testing:py_messages_proto",
34+
"//src/proto/grpc/testing:py_test_proto",
35+
requirement('google-auth'),
36+
requirement('requests'),
37+
requirement('enum34'),
38+
],
39+
imports=["../../",],
40+
)
41+
42+
py_library(
43+
name = "resources",
44+
srcs = ["resources.py"],
45+
data = [
46+
"//src/python/grpcio_tests/tests/interop/credentials",
47+
],
48+
)
49+
50+
py_library(
51+
name = "server",
52+
srcs = ["server.py"],
53+
deps = [
54+
"//src/python/grpcio/grpc:grpcio",
55+
":methods",
56+
":resources",
57+
"//src/python/grpcio_tests/tests/unit:test_common",
58+
"//src/proto/grpc/testing:py_test_proto",
59+
],
60+
imports=["../../",],
61+
)
62+
63+
py_test(
64+
name="_insecure_intraop_test",
65+
size="small",
66+
srcs=["_insecure_intraop_test.py",],
67+
main="_insecure_intraop_test.py",
68+
deps=[
69+
"//src/python/grpcio/grpc:grpcio",
70+
":_intraop_test_case",
71+
":methods",
72+
":server",
73+
"//src/python/grpcio_tests/tests/unit:test_common",
74+
"//src/proto/grpc/testing:py_test_proto",
75+
],
76+
imports=["../../",],
77+
data=[
78+
"//src/python/grpcio_tests/tests/unit/credentials",
79+
],
80+
)
81+
82+
py_test(
83+
name="_secure_intraop_test",
84+
size="small",
85+
srcs=["_secure_intraop_test.py",],
86+
main="_secure_intraop_test.py",
87+
deps=[
88+
"//src/python/grpcio/grpc:grpcio",
89+
":_intraop_test_case",
90+
":methods",
91+
":server",
92+
"//src/python/grpcio_tests/tests/unit:test_common",
93+
"//src/proto/grpc/testing:py_test_proto",
94+
],
95+
imports=["../../",],
96+
)
97+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
filegroup(
4+
name="credentials",
5+
srcs=glob([
6+
"**",
7+
]),
8+
)
9+

0 commit comments

Comments
 (0)