aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/python/grpcio_health_checking/grpc_health/v1/health.py12
-rw-r--r--src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py32
-rw-r--r--src/python/grpcio_tests/tests/health_check/_health_servicer_test.py3
-rw-r--r--src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py4
-rw-r--r--test/cpp/qps/client.h24
-rw-r--r--tools/run_tests/performance/README.md28
6 files changed, 80 insertions, 23 deletions
diff --git a/src/python/grpcio_health_checking/grpc_health/v1/health.py b/src/python/grpcio_health_checking/grpc_health/v1/health.py
index c8498104b1..0583659428 100644
--- a/src/python/grpcio_health_checking/grpc_health/v1/health.py
+++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py
@@ -17,11 +17,13 @@ import threading
import grpc
-from grpc_health.v1 import health_pb2
-from grpc_health.v1 import health_pb2_grpc
+from grpc_health.v1 import health_pb2 as _health_pb2
+from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc
+SERVICE_NAME = _health_pb2.DESCRIPTOR.services_by_name['Health'].full_name
-class HealthServicer(health_pb2_grpc.HealthServicer):
+
+class HealthServicer(_health_pb2_grpc.HealthServicer):
"""Servicer handling RPCs for service statuses."""
def __init__(self):
@@ -33,9 +35,9 @@ class HealthServicer(health_pb2_grpc.HealthServicer):
status = self._server_status.get(request.service)
if status is None:
context.set_code(grpc.StatusCode.NOT_FOUND)
- return health_pb2.HealthCheckResponse()
+ return _health_pb2.HealthCheckResponse()
else:
- return health_pb2.HealthCheckResponse(status=status)
+ return _health_pb2.HealthCheckResponse(status=status)
def set(self, service, status):
"""Sets the status of a service.
diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
index 0c564f10e5..6df1a36426 100644
--- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
+++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
@@ -17,15 +17,17 @@ import grpc
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
-from grpc_reflection.v1alpha import reflection_pb2
-from grpc_reflection.v1alpha import reflection_pb2_grpc
+from grpc_reflection.v1alpha import reflection_pb2 as _reflection_pb2
+from grpc_reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc
_POOL = descriptor_pool.Default()
+SERVICE_NAME = _reflection_pb2.DESCRIPTOR.services_by_name[
+ 'ServerReflection'].full_name
def _not_found_error():
- return reflection_pb2.ServerReflectionResponse(
- error_response=reflection_pb2.ErrorResponse(
+ return _reflection_pb2.ServerReflectionResponse(
+ error_response=_reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.NOT_FOUND.value[0],
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
))
@@ -35,12 +37,12 @@ def _file_descriptor_response(descriptor):
proto = descriptor_pb2.FileDescriptorProto()
descriptor.CopyToProto(proto)
serialized_proto = proto.SerializeToString()
- return reflection_pb2.ServerReflectionResponse(
- file_descriptor_response=reflection_pb2.FileDescriptorResponse(
+ return _reflection_pb2.ServerReflectionResponse(
+ file_descriptor_response=_reflection_pb2.FileDescriptorResponse(
file_descriptor_proto=(serialized_proto,)),)
-class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer):
+class ReflectionServicer(_reflection_pb2_grpc.ServerReflectionServicer):
"""Servicer handling RPCs for service statuses."""
def __init__(self, service_names, pool=None):
@@ -94,17 +96,17 @@ class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer):
except KeyError:
return _not_found_error()
else:
- return reflection_pb2.ServerReflectionResponse(
- all_extension_numbers_response=reflection_pb2.
+ return _reflection_pb2.ServerReflectionResponse(
+ all_extension_numbers_response=_reflection_pb2.
ExtensionNumberResponse(
base_type_name=message_descriptor.full_name,
extension_number=extension_numbers))
def _list_services(self):
- return reflection_pb2.ServerReflectionResponse(
- list_services_response=reflection_pb2.ListServiceResponse(
+ return _reflection_pb2.ServerReflectionResponse(
+ list_services_response=_reflection_pb2.ListServiceResponse(
service=[
- reflection_pb2.ServiceResponse(name=service_name)
+ _reflection_pb2.ServiceResponse(name=service_name)
for service_name in self._service_names
]))
@@ -126,8 +128,8 @@ class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer):
elif request.HasField('list_services'):
yield self._list_services()
else:
- yield reflection_pb2.ServerReflectionResponse(
- error_response=reflection_pb2.ErrorResponse(
+ yield _reflection_pb2.ServerReflectionResponse(
+ error_response=_reflection_pb2.ErrorResponse(
error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0],
error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]
.encode(),
@@ -142,5 +144,5 @@ def enable_server_reflection(service_names, server, pool=None):
server: grpc.Server to which reflection service will be added.
pool: DescriptorPool object to use (descriptor_pool.Default() if None).
"""
- reflection_pb2_grpc.add_ServerReflectionServicer_to_server(
+ _reflection_pb2_grpc.add_ServerReflectionServicer_to_server(
ReflectionServicer(service_names, pool=pool), server)
diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
index 3cbbb8de33..350b5eebe5 100644
--- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
+++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
@@ -73,6 +73,9 @@ class HealthServicerTest(unittest.TestCase):
self.assertEqual(grpc.StatusCode.NOT_FOUND, context.exception.code())
+ def test_health_service_name(self):
+ self.assertEqual(health.SERVICE_NAME, 'grpc.health.v1.Health')
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py
index 7ffdba6a67..bcd9e14a38 100644
--- a/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py
+++ b/src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py
@@ -171,6 +171,10 @@ class ReflectionServicerTest(unittest.TestCase):
for name in _SERVICE_NAMES))),)
self.assertSequenceEqual(expected_responses, responses)
+ def testReflectionServiceName(self):
+ self.assertEqual(reflection.SERVICE_NAME,
+ 'grpc.reflection.v1alpha.ServerReflection')
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index 9d58ea8882..9d7469c9b5 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -19,6 +19,8 @@
#ifndef TEST_QPS_CLIENT_H
#define TEST_QPS_CLIENT_H
+#include <stdlib.h>
+
#include <condition_variable>
#include <mutex>
#include <unordered_map>
@@ -34,6 +36,7 @@
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
#include "src/proto/grpc/testing/payloads.pb.h"
+#include "src/core/lib/gpr/env.h"
#include "src/cpp/util/core_stats.h"
#include "test/cpp/qps/histogram.h"
#include "test/cpp/qps/interarrival.h"
@@ -441,9 +444,24 @@ class ClientImpl : public Client {
std::unique_ptr<std::thread> WaitForReady() {
return std::unique_ptr<std::thread>(new std::thread([this]() {
if (!is_inproc_) {
- GPR_ASSERT(channel_->WaitForConnected(
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(10, GPR_TIMESPAN))));
+ int connect_deadline = 10;
+ /* Allow optionally overriding connect_deadline in order
+ * to deal with benchmark environments in which the server
+ * can take a long time to become ready. */
+ char* channel_connect_timeout_str =
+ gpr_getenv("QPS_WORKER_CHANNEL_CONNECT_TIMEOUT");
+ if (channel_connect_timeout_str != nullptr &&
+ strcmp(channel_connect_timeout_str, "") != 0) {
+ connect_deadline = atoi(channel_connect_timeout_str);
+ }
+ gpr_log(GPR_INFO,
+ "Waiting for up to %d seconds for the channel %p to connect",
+ connect_deadline, channel_.get());
+ gpr_free(channel_connect_timeout_str);
+ GPR_ASSERT(channel_->WaitForConnected(gpr_time_add(
+ gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(connect_deadline, GPR_TIMESPAN))));
+ gpr_log(GPR_INFO, "Channel %p connected!", channel_.get());
}
}));
}
diff --git a/tools/run_tests/performance/README.md b/tools/run_tests/performance/README.md
index 2fc1a27c9b..791270ab38 100644
--- a/tools/run_tests/performance/README.md
+++ b/tools/run_tests/performance/README.md
@@ -104,3 +104,31 @@ Example memory profile of grpc-go server, with `go tools pprof`:
```
$ go tool pprof --text --alloc_space http://localhost:<pprof_port>/debug/heap
```
+
+### Configuration environment variables:
+
+* QPS_WORKER_CHANNEL_CONNECT_TIMEOUT
+
+ Consuming process: qps_worker
+
+ Type: integer (number of seconds)
+
+ This can be used to configure the amount of time that benchmark
+ clients wait for channels to the benchmark server to become ready.
+ This is useful in certain benchmark environments in which the
+ server can take a long time to become ready. Note: if setting
+ this to a high value, then the scenario config under test should
+ probably also have a large "warmup_seconds".
+
+* QPS_WORKERS
+
+ Consuming process: qps_json_driver
+
+ Type: comma separated list of host:port
+
+ Set this to a comma separated list of QPS worker processes/machines.
+ Each scenario in a scenario config has specifies a certain number
+ of servers, `num_servers`, and the driver will start
+ "benchmark servers"'s on the first `num_server` `host:port` pairs in
+ the comma separated list. The rest will be told to run as clients
+ against the benchmark server.