8000 Add `helloworld.proto` and re-generate files (#3091) · nginx/kubernetes-ingress@8c4d8e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c4d8e9

Browse files
authored
Add helloworld.proto and re-generate files (#3091)
1 parent 1f48588 commit 8c4d8e9

File tree

8 files changed

+153
-159
lines changed

8 files changed

+153
-159
lines changed

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,27 @@ skip_gitignore = true
1111
balanced_wrapping = true
1212
filter_files = true
1313
skip_glob = ['*pb2*']
14+
15+
[tool.pytest.ini_options]
16+
pythonpath = [
17+
".",
18+
"tests/suite",
19+
"tests/suite/grpc",
20+
]
21+
addopts = "--tb=native -ra --disable-warnings -x -l --profile -v"
22+
log_cli = true
23+
markers =[
24+
"smoke",
25+
"vsr",
26+
"policies",
27+
"vs",
28+
"ts",
29+
"ingresses",
30+
"appprotect",
31+
"rewrite",
32+
"skip_for_nginx_oss",
33+
]
34+
testpaths = [
35+
"tests",
36+
"perf-tests",
37+
]

tests/docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s
2121

2222 8000
COPY --link tests /workspace/tests
2323

24+
COPY --link pyproject.toml /workspace/
25+
2426
ENTRYPOINT ["python3", "-m", "pytest"]

tests/pytest.ini

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/suite/__init__.py

Whitespace-only changes.

tests/suite/grpc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The files here are generated using `helloworld.proto` from the grpc [repo](https://github.com/grpc/grpc-go/tree/master/examples/helloworld/helloworld).
2+
3+
To update the files run the following command:
4+
5+
```bash
6+
python3 -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. helloworld.proto
7+
```

tests/suite/grpc/helloworld.proto

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2015 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
option go_package = "google.golang.org/grpc/examples/helloworld/helloworld";
18+
option java_multiple_files = true;
19+
option java_package = "io.grpc.examples.helloworld";
20+
option java_outer_classname = "HelloWorldProto";
21+
22+
package helloworld;
23+
24+
// The greeting service definition.
25+
service Greeter {
26+
// Sends a greeting
27+
rpc SayHello (HelloRequest) returns (HelloReply) {}
28+
}
29+
30+
// The request message containing the user's name.
31+
message HelloRequest {
32+
string name = 1;
33+
}
34+
35+
// The response message containing the greetings
36+
message HelloReply {
37+
string message = 1;
38+
}

tests/suite/grpc/helloworld_pb2.py

Lines changed: 26 additions & 112 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,70 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2+
"""Client and server classes corresponding to protobuf-defined services."""
23
import grpc
34

4-
from suite.grpc.helloworld_pb2 import (
5-
HelloRequest,
6-
HelloReply,
7-
)
5+
import helloworld_pb2 as helloworld__pb2
86

97

108
class GreeterStub(object):
11-
"""The greeting service definition.
12-
"""
13-
14-
def __init__(self, channel):
15-
"""Constructor.
16-
Args:
17-
channel: A grpc.Channel.
9+
"""The greeting service definition.
1810
"""
19-
self.SayHello = channel.unary_unary(
20-
'/helloworld.Greeter/SayHello',
21-
request_serializer=HelloRequest.SerializeToString,
22-
response_deserializer=HelloReply.FromString,
23-
)
2411

12+
def __init__(self, channel):
13+
"""Constructor.
14+
15+
Args:
16+
channel: A grpc.Channel.
17+
"""
18+
self.SayHello = channel.unary_unary(
19+
'/helloworld.Greeter/SayHello',
20+
request_serializer=helloworld__pb2.HelloRequest.SerializeToString,
21+
response_deserializer=helloworld__pb2.HelloReply.FromString,
22+
)
2523

26-
class GreeterServicer(object):
27-
"""The greeting service definition.
28-
"""
2924

30-
def SayHello(self, request, context):
31-
"""Sends a greeting
25+
class GreeterServicer(object):
26+
"""The greeting service definition.
3227
"""
33-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
34-
context.set_details('Method not implemented!')
35-
raise NotImplementedError('Method not implemented!')
28+
29+
def SayHello(self, request, context):
30+
"""Sends a greeting
31+
"""
32+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
33+
context.set_details('Method not implemented!')
34+
raise NotImplementedError('Method not implemented!')
3635

3736

3837
def add_GreeterServicer_to_server(servicer, server):
39-
rpc_method_handlers = {
40-
'SayHello': grpc.unary_unary_rpc_method_handler(
41- 67DE
servicer.SayHello,
42-
request_deserializer=HelloRequest.FromString,
43-
response_serializer=HelloReply.SerializeToString,
44-
),
45-
}
46-
generic_handler = grpc.method_handlers_generic_handler(
47-
'helloworld.Greeter', rpc_method_handlers)
48-
server.add_generic_rpc_handlers((generic_handler,))
38+
rpc_method_handlers = {
39+
'SayHello': grpc.unary_unary_rpc_method_handler(
40+
servicer.SayHello,
41+
request_deserializer=helloworld__pb2.HelloRequest.FromString,
42+
response_serializer=helloworld__pb2.HelloReply.SerializeToString,
43+
),
44+
}
45+
generic_handler = grpc.method_handlers_generic_handler(
46+
'helloworld.Greeter', rpc_method_handlers)
47+
server.add_generic_rpc_handlers((generic_handler,))
48+
49+
50+
# This class is part of an EXPERIMENTAL API.
51+
class Greeter(object):
52+
"""The greeting service definition.
53+
"""
54+
55+
@staticmethod
56+
def SayHello(request,
57+
target,
58+
options=(),
59+
channel_credentials=None,
60+
call_credentials=None,
61+
insecure=False,
62+
compression=None,
63+
wait_for_ready=None,
64+
timeout=None,
65+
metadata=None):
66+
return grpc.experimental.unary_unary(request, target, '/helloworld.Greeter/SayHello',
67+
helloworld__pb2.HelloRequest.SerializeToString,
68+
helloworld__pb2.HelloReply.FromString,
69+
options, channel_credentials,
70+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

0 commit comments

Comments
 (0)
0