grpc 1.31.0.pre1-universal-darwin → 1.33.0.pre1-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/src/ruby/bin/math_services_pb.rb +4 -4
- data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +7 -7
- data/src/ruby/lib/grpc/2.3/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.4/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.5/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.6/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.7/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +2 -2
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +5 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +28 -12
- data/src/ruby/pb/test/xds_client.rb +101 -17
- data/src/ruby/spec/channel_credentials_spec.rb +10 -0
- data/src/ruby/spec/generic/active_call_spec.rb +19 -8
- data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +20 -0
- data/src/ruby/spec/user_agent_spec.rb +74 -0
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ad50a4b3de7e69a38cfc98b75324cb248e5f3dd89848cff380b5a472b45491
|
4
|
+
data.tar.gz: b558af679649f0d44216dbf5515c5b1e2c579b0e5c7f62c83a3c032fbdd7bdbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f50818e26577420d0e7d47f4ab695183497b86d47381ad11420485087be91b4bd386ede1b67639420bbc6949cd0a4aeb3d1a6755127d855a0c0ee533d40ec6ee
|
7
|
+
data.tar.gz: f484aed98f2553d6fdf2fa582e164802e333432c482addea49b5670a6c69556011ab92e8212e9e5ed3e07a5cb535d8ad8738463e0b6de7261328575817dc7ff3
|
@@ -31,19 +31,19 @@ module Math
|
|
31
31
|
|
32
32
|
# Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient
|
33
33
|
# and remainder.
|
34
|
-
rpc :Div, DivArgs, DivReply
|
34
|
+
rpc :Div, ::Math::DivArgs, ::Math::DivReply
|
35
35
|
# DivMany accepts an arbitrary number of division args from the client stream
|
36
36
|
# and sends back the results in the reply stream. The stream continues until
|
37
37
|
# the client closes its end; the server does the same after sending all the
|
38
38
|
# replies. The stream ends immediately if either end aborts.
|
39
|
-
rpc :DivMany, stream(DivArgs), stream(DivReply)
|
39
|
+
rpc :DivMany, stream(::Math::DivArgs), stream(::Math::DivReply)
|
40
40
|
# Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib
|
41
41
|
# generates up to limit numbers; otherwise it continues until the call is
|
42
42
|
# canceled. Unlike Fib above, Fib has no final FibReply.
|
43
|
-
rpc :Fib, FibArgs, stream(Num)
|
43
|
+
rpc :Fib, ::Math::FibArgs, stream(::Math::Num)
|
44
44
|
# Sum sums a stream of numbers, returning the final result once the stream
|
45
45
|
# is closed.
|
46
|
-
rpc :Sum, stream(Num), Num
|
46
|
+
rpc :Sum, stream(::Math::Num), ::Math::Num
|
47
47
|
end
|
48
48
|
|
49
49
|
Stub = Service.rpc_stub_class
|
@@ -165,6 +165,15 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE* argv,
|
|
165
165
|
if (pem_private_key == Qnil && pem_cert_chain == Qnil) {
|
166
166
|
creds = grpc_ssl_credentials_create(pem_root_certs_cstr, NULL, NULL, NULL);
|
167
167
|
} else {
|
168
|
+
if (pem_private_key == Qnil) {
|
169
|
+
rb_raise(
|
170
|
+
rb_eRuntimeError,
|
171
|
+
"could not create a credentials because pem_private_key is NULL");
|
172
|
+
}
|
173
|
+
if (pem_cert_chain == Qnil) {
|
174
|
+
rb_raise(rb_eRuntimeError,
|
175
|
+
"could not create a credentials because pem_cert_chain is NULL");
|
176
|
+
}
|
168
177
|
key_cert_pair.private_key = RSTRING_PTR(pem_private_key);
|
169
178
|
key_cert_pair.cert_chain = RSTRING_PTR(pem_cert_chain);
|
170
179
|
creds = grpc_ssl_credentials_create(pem_root_certs_cstr, &key_cert_pair,
|
@@ -58,7 +58,6 @@ grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_c
|
|
58
58
|
grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
|
59
59
|
grpc_channel_support_connectivity_watcher_type grpc_channel_support_connectivity_watcher_import;
|
60
60
|
grpc_channel_create_call_type grpc_channel_create_call_import;
|
61
|
-
grpc_channel_ping_type grpc_channel_ping_import;
|
62
61
|
grpc_channel_register_call_type grpc_channel_register_call_import;
|
63
62
|
grpc_channel_create_registered_call_type grpc_channel_create_registered_call_import;
|
64
63
|
grpc_call_arena_alloc_type grpc_call_arena_alloc_import;
|
@@ -120,12 +119,12 @@ grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_pee
|
|
120
119
|
grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import;
|
121
120
|
grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import;
|
122
121
|
grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
|
122
|
+
grpc_call_credentials_release_type grpc_call_credentials_release_import;
|
123
123
|
grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
|
124
124
|
grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
|
125
125
|
grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
|
126
126
|
grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
|
127
127
|
grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import;
|
128
|
-
grpc_call_credentials_release_type grpc_call_credentials_release_import;
|
129
128
|
grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
|
130
129
|
grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import;
|
131
130
|
grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import;
|
@@ -171,6 +170,7 @@ grpc_tls_key_materials_config_set_version_type grpc_tls_key_materials_config_set
|
|
171
170
|
grpc_tls_key_materials_config_get_version_type grpc_tls_key_materials_config_get_version_import;
|
172
171
|
grpc_tls_credential_reload_config_create_type grpc_tls_credential_reload_config_create_import;
|
173
172
|
grpc_tls_server_authorization_check_config_create_type grpc_tls_server_authorization_check_config_create_import;
|
173
|
+
grpc_xds_credentials_create_type grpc_xds_credentials_create_import;
|
174
174
|
grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import;
|
175
175
|
grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import;
|
176
176
|
grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import;
|
@@ -332,7 +332,6 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
332
332
|
grpc_channel_watch_connectivity_state_import = (grpc_channel_watch_connectivity_state_type) GetProcAddress(library, "grpc_channel_watch_connectivity_state");
|
333
333
|
grpc_channel_support_connectivity_watcher_import = (grpc_channel_support_connectivity_watcher_type) GetProcAddress(library, "grpc_channel_support_connectivity_watcher");
|
334
334
|
grpc_channel_create_call_import = (grpc_channel_create_call_type) GetProcAddress(library, "grpc_channel_create_call");
|
335
|
-
grpc_channel_ping_import = (grpc_channel_ping_type) GetProcAddress(library, "grpc_channel_ping");
|
336
335
|
grpc_channel_register_call_import = (grpc_channel_register_call_type) GetProcAddress(library, "grpc_channel_register_call");
|
337
336
|
grpc_channel_create_registered_call_import = (grpc_channel_create_registered_call_type) GetProcAddress(library, "grpc_channel_create_registered_call");
|
338
337
|
grpc_call_arena_alloc_import = (grpc_call_arena_alloc_type) GetProcAddress(library, "grpc_call_arena_alloc");
|
@@ -394,12 +393,12 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
394
393
|
grpc_ssl_session_cache_create_lru_import = (grpc_ssl_session_cache_create_lru_type) GetProcAddress(library, "grpc_ssl_session_cache_create_lru");
|
395
394
|
grpc_ssl_session_cache_destroy_import = (grpc_ssl_session_cache_destroy_type) GetProcAddress(library, "grpc_ssl_session_cache_destroy");
|
396
395
|
grpc_ssl_session_cache_create_channel_arg_import = (grpc_ssl_session_cache_create_channel_arg_type) GetProcAddress(library, "grpc_ssl_session_cache_create_channel_arg");
|
396
|
+
grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
|
397
397
|
grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release");
|
398
398
|
grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create");
|
399
399
|
grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback");
|
400
400
|
grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create");
|
401
401
|
grpc_ssl_credentials_create_ex_import = (grpc_ssl_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_credentials_create_ex");
|
402
|
-
grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
|
403
402
|
grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create");
|
404
403
|
grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create");
|
405
404
|
grpc_google_compute_engine_credentials_create_import = (grpc_google_compute_engine_credentials_create_type) GetProcAddress(library, "grpc_google_compute_engine_credentials_create");
|
@@ -445,6 +444,7 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
445
444
|
grpc_tls_key_materials_config_get_version_import = (grpc_tls_key_materials_config_get_version_type) GetProcAddress(library, "grpc_tls_key_materials_config_get_version");
|
446
445
|
grpc_tls_credential_reload_config_create_import = (grpc_tls_credential_reload_config_create_type) GetProcAddress(library, "grpc_tls_credential_reload_config_create");
|
447
446
|
grpc_tls_server_authorization_check_config_create_import = (grpc_tls_server_authorization_check_config_create_type) GetProcAddress(library, "grpc_tls_server_authorization_check_config_create");
|
447
|
+
grpc_xds_credentials_create_import = (grpc_xds_credentials_create_type) GetProcAddress(library, "grpc_xds_credentials_create");
|
448
448
|
grpc_raw_byte_buffer_create_import = (grpc_raw_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_byte_buffer_create");
|
449
449
|
grpc_raw_compressed_byte_buffer_create_import = (grpc_raw_compressed_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_compressed_byte_buffer_create");
|
450
450
|
grpc_byte_buffer_copy_import = (grpc_byte_buffer_copy_type) GetProcAddress(library, "grpc_byte_buffer_copy");
|
@@ -149,9 +149,6 @@ extern grpc_channel_support_connectivity_watcher_type grpc_channel_support_conne
|
|
149
149
|
typedef grpc_call*(*grpc_channel_create_call_type)(grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, grpc_completion_queue* completion_queue, grpc_slice method, const grpc_slice* host, gpr_timespec deadline, void* reserved);
|
150
150
|
extern grpc_channel_create_call_type grpc_channel_create_call_import;
|
151
151
|
#define grpc_channel_create_call grpc_channel_create_call_import
|
152
|
-
typedef void(*grpc_channel_ping_type)(grpc_channel* channel, grpc_completion_queue* cq, void* tag, void* reserved);
|
153
|
-
extern grpc_channel_ping_type grpc_channel_ping_import;
|
154
|
-
#define grpc_channel_ping grpc_channel_ping_import
|
155
152
|
typedef void*(*grpc_channel_register_call_type)(grpc_channel* channel, const char* method, const char* host, void* reserved);
|
156
153
|
extern grpc_channel_register_call_type grpc_channel_register_call_import;
|
157
154
|
#define grpc_channel_register_call grpc_channel_register_call_import
|
@@ -335,10 +332,13 @@ extern grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import
|
|
335
332
|
typedef grpc_arg(*grpc_ssl_session_cache_create_channel_arg_type)(grpc_ssl_session_cache* cache);
|
336
333
|
extern grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
|
337
334
|
#define grpc_ssl_session_cache_create_channel_arg grpc_ssl_session_cache_create_channel_arg_import
|
335
|
+
typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds);
|
336
|
+
extern grpc_call_credentials_release_type grpc_call_credentials_release_import;
|
337
|
+
#define grpc_call_credentials_release grpc_call_credentials_release_import
|
338
338
|
typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials* creds);
|
339
339
|
extern grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
|
340
340
|
#define grpc_channel_credentials_release grpc_channel_credentials_release_import
|
341
|
-
typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(
|
341
|
+
typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(grpc_call_credentials* call_credentials);
|
342
342
|
extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
|
343
343
|
#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import
|
344
344
|
typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb);
|
@@ -350,9 +350,6 @@ extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
|
|
350
350
|
typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const grpc_ssl_verify_peer_options* verify_options, void* reserved);
|
351
351
|
extern grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import;
|
352
352
|
#define grpc_ssl_credentials_create_ex grpc_ssl_credentials_create_ex_import
|
353
|
-
typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds);
|
354
|
-
extern grpc_call_credentials_release_type grpc_call_credentials_release_import;
|
355
|
-
#define grpc_call_credentials_release grpc_call_credentials_release_import
|
356
353
|
typedef grpc_channel_credentials*(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, void* reserved);
|
357
354
|
extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
|
358
355
|
#define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import
|
@@ -488,6 +485,9 @@ extern grpc_tls_credential_reload_config_create_type grpc_tls_credential_reload_
|
|
488
485
|
typedef grpc_tls_server_authorization_check_config*(*grpc_tls_server_authorization_check_config_create_type)(const void* config_user_data, int (*schedule)(void* config_user_data, grpc_tls_server_authorization_check_arg* arg), void (*cancel)(void* config_user_data, grpc_tls_server_authorization_check_arg* arg), void (*destruct)(void* config_user_data));
|
489
486
|
extern grpc_tls_server_authorization_check_config_create_type grpc_tls_server_authorization_check_config_create_import;
|
490
487
|
#define grpc_tls_server_authorization_check_config_create grpc_tls_server_authorization_check_config_create_import
|
488
|
+
typedef grpc_channel_credentials*(*grpc_xds_credentials_create_type)(grpc_channel_credentials* fallback_credentials);
|
489
|
+
extern grpc_xds_credentials_create_type grpc_xds_credentials_create_import;
|
490
|
+
#define grpc_xds_credentials_create grpc_xds_credentials_create_import
|
491
491
|
typedef grpc_byte_buffer*(*grpc_raw_byte_buffer_create_type)(grpc_slice* slices, size_t nslices);
|
492
492
|
extern grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import;
|
493
493
|
#define grpc_raw_byte_buffer_create grpc_raw_byte_buffer_create_import
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -100,7 +100,7 @@ module GRPC
|
|
100
100
|
channel_args: {},
|
101
101
|
interceptors: [])
|
102
102
|
@ch = ClientStub.setup_channel(channel_override, host, creds,
|
103
|
-
channel_args)
|
103
|
+
channel_args.dup)
|
104
104
|
alt_host = channel_args[Core::Channel::SSL_TARGET]
|
105
105
|
@host = alt_host.nil? ? host : alt_host
|
106
106
|
@propagate_mask = propagate_mask
|
@@ -36,7 +36,7 @@ module Grpc
|
|
36
36
|
|
37
37
|
# If the requested service is unknown, the call will fail with status
|
38
38
|
# NOT_FOUND.
|
39
|
-
rpc :Check, HealthCheckRequest, HealthCheckResponse
|
39
|
+
rpc :Check, ::Grpc::Health::V1::HealthCheckRequest, ::Grpc::Health::V1::HealthCheckResponse
|
40
40
|
# Performs a watch for the serving status of the requested service.
|
41
41
|
# The server will immediately send back a message indicating the current
|
42
42
|
# serving status. It will then subsequently send a new message whenever
|
@@ -52,7 +52,7 @@ module Grpc
|
|
52
52
|
# should assume this method is not supported and should not retry the
|
53
53
|
# call. If the call terminates with any other status (including OK),
|
54
54
|
# clients should retry the call with appropriate exponential backoff.
|
55
|
-
rpc :Watch, HealthCheckRequest, stream(HealthCheckResponse)
|
55
|
+
rpc :Watch, ::Grpc::Health::V1::HealthCheckRequest, stream(::Grpc::Health::V1::HealthCheckResponse)
|
56
56
|
end
|
57
57
|
|
58
58
|
Stub = Service.rpc_stub_class
|
@@ -71,6 +71,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
71
71
|
add_message "grpc.testing.LoadBalancerStatsResponse" do
|
72
72
|
map :rpcs_by_peer, :string, :int32, 1
|
73
73
|
optional :num_failures, :int32, 2
|
74
|
+
map :rpcs_by_method, :string, :message, 3, "grpc.testing.LoadBalancerStatsResponse.RpcsByPeer"
|
75
|
+
end
|
76
|
+
add_message "grpc.testing.LoadBalancerStatsResponse.RpcsByPeer" do
|
77
|
+
map :rpcs_by_peer, :string, :int32, 1
|
74
78
|
end
|
75
79
|
add_enum "grpc.testing.PayloadType" do
|
76
80
|
value :COMPRESSABLE, 0
|
@@ -99,6 +103,7 @@ module Grpc
|
|
99
103
|
ReconnectInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ReconnectInfo").msgclass
|
100
104
|
LoadBalancerStatsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadBalancerStatsRequest").msgclass
|
101
105
|
LoadBalancerStatsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadBalancerStatsResponse").msgclass
|
106
|
+
LoadBalancerStatsResponse::RpcsByPeer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadBalancerStatsResponse.RpcsByPeer").msgclass
|
102
107
|
PayloadType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PayloadType").enummodule
|
103
108
|
GrpclbRouteType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.GrpclbRouteType").enummodule
|
104
109
|
end
|
@@ -36,31 +36,31 @@ module Grpc
|
|
36
36
|
self.service_name = 'grpc.testing.TestService'
|
37
37
|
|
38
38
|
# One empty request followed by one empty response.
|
39
|
-
rpc :EmptyCall, Empty, Empty
|
39
|
+
rpc :EmptyCall, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
|
40
40
|
# One request followed by one response.
|
41
|
-
rpc :UnaryCall, SimpleRequest, SimpleResponse
|
41
|
+
rpc :UnaryCall, ::Grpc::Testing::SimpleRequest, ::Grpc::Testing::SimpleResponse
|
42
42
|
# One request followed by one response. Response has cache control
|
43
43
|
# headers set such that a caching HTTP proxy (such as GFE) can
|
44
44
|
# satisfy subsequent requests.
|
45
|
-
rpc :CacheableUnaryCall, SimpleRequest, SimpleResponse
|
45
|
+
rpc :CacheableUnaryCall, ::Grpc::Testing::SimpleRequest, ::Grpc::Testing::SimpleResponse
|
46
46
|
# One request followed by a sequence of responses (streamed download).
|
47
47
|
# The server returns the payload with client desired type and sizes.
|
48
|
-
rpc :StreamingOutputCall, StreamingOutputCallRequest, stream(StreamingOutputCallResponse)
|
48
|
+
rpc :StreamingOutputCall, ::Grpc::Testing::StreamingOutputCallRequest, stream(::Grpc::Testing::StreamingOutputCallResponse)
|
49
49
|
# A sequence of requests followed by one response (streamed upload).
|
50
50
|
# The server returns the aggregated size of client payload as the result.
|
51
|
-
rpc :StreamingInputCall, stream(StreamingInputCallRequest), StreamingInputCallResponse
|
51
|
+
rpc :StreamingInputCall, stream(::Grpc::Testing::StreamingInputCallRequest), ::Grpc::Testing::StreamingInputCallResponse
|
52
52
|
# A sequence of requests with each request served by the server immediately.
|
53
53
|
# As one request could lead to multiple responses, this interface
|
54
54
|
# demonstrates the idea of full duplexing.
|
55
|
-
rpc :FullDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
|
55
|
+
rpc :FullDuplexCall, stream(::Grpc::Testing::StreamingOutputCallRequest), stream(::Grpc::Testing::StreamingOutputCallResponse)
|
56
56
|
# A sequence of requests followed by a sequence of responses.
|
57
57
|
# The server buffers all the client requests and then serves them in order. A
|
58
58
|
# stream of responses are returned to the client when the server starts with
|
59
59
|
# first request.
|
60
|
-
rpc :HalfDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
|
60
|
+
rpc :HalfDuplexCall, stream(::Grpc::Testing::StreamingOutputCallRequest), stream(::Grpc::Testing::StreamingOutputCallResponse)
|
61
61
|
# The test server will not implement this method. It will be used
|
62
62
|
# to test the behavior when clients call unimplemented methods.
|
63
|
-
rpc :UnimplementedCall, Empty, Empty
|
63
|
+
rpc :UnimplementedCall, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
|
64
64
|
end
|
65
65
|
|
66
66
|
Stub = Service.rpc_stub_class
|
@@ -77,7 +77,7 @@ module Grpc
|
|
77
77
|
self.service_name = 'grpc.testing.UnimplementedService'
|
78
78
|
|
79
79
|
# A call that no server should implement
|
80
|
-
rpc :UnimplementedCall, Empty, Empty
|
80
|
+
rpc :UnimplementedCall, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
|
81
81
|
end
|
82
82
|
|
83
83
|
Stub = Service.rpc_stub_class
|
@@ -92,8 +92,8 @@ module Grpc
|
|
92
92
|
self.unmarshal_class_method = :decode
|
93
93
|
self.service_name = 'grpc.testing.ReconnectService'
|
94
94
|
|
95
|
-
rpc :Start, ReconnectParams, Empty
|
96
|
-
rpc :Stop, Empty, ReconnectInfo
|
95
|
+
rpc :Start, ::Grpc::Testing::ReconnectParams, ::Grpc::Testing::Empty
|
96
|
+
rpc :Stop, ::Grpc::Testing::Empty, ::Grpc::Testing::ReconnectInfo
|
97
97
|
end
|
98
98
|
|
99
99
|
Stub = Service.rpc_stub_class
|
@@ -109,7 +109,23 @@ module Grpc
|
|
109
109
|
self.service_name = 'grpc.testing.LoadBalancerStatsService'
|
110
110
|
|
111
111
|
# Gets the backend distribution for RPCs sent by a test client.
|
112
|
-
rpc :GetClientStats, LoadBalancerStatsRequest, LoadBalancerStatsResponse
|
112
|
+
rpc :GetClientStats, ::Grpc::Testing::LoadBalancerStatsRequest, ::Grpc::Testing::LoadBalancerStatsResponse
|
113
|
+
end
|
114
|
+
|
115
|
+
Stub = Service.rpc_stub_class
|
116
|
+
end
|
117
|
+
module XdsUpdateHealthService
|
118
|
+
# A service to remotely control health status of an xDS test server.
|
119
|
+
class Service
|
120
|
+
|
121
|
+
include GRPC::GenericService
|
122
|
+
|
123
|
+
self.marshal_class_method = :encode
|
124
|
+
self.unmarshal_class_method = :decode
|
125
|
+
self.service_name = 'grpc.testing.XdsUpdateHealthService'
|
126
|
+
|
127
|
+
rpc :SetServing, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
|
128
|
+
rpc :SetNotServing, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
|
113
129
|
end
|
114
130
|
|
115
131
|
Stub = Service.rpc_stub_class
|
@@ -81,6 +81,7 @@ class TestTarget < Grpc::Testing::LoadBalancerStatsService::Service
|
|
81
81
|
watcher = {}
|
82
82
|
$watchers_mutex.synchronize do
|
83
83
|
watcher = {
|
84
|
+
"rpcs_by_method" => Hash.new(),
|
84
85
|
"rpcs_by_peer" => Hash.new(0),
|
85
86
|
"rpcs_needed" => req['num_rpcs'],
|
86
87
|
"no_remote_peer" => 0
|
@@ -95,17 +96,45 @@ class TestTarget < Grpc::Testing::LoadBalancerStatsService::Service
|
|
95
96
|
end
|
96
97
|
$watchers.delete_at($watchers.index(watcher))
|
97
98
|
end
|
99
|
+
# convert results into proper proto object
|
100
|
+
rpcs_by_method = {}
|
101
|
+
watcher['rpcs_by_method'].each do |rpc_name, rpcs_by_peer|
|
102
|
+
rpcs_by_method[rpc_name] = LoadBalancerStatsResponse::RpcsByPeer.new(
|
103
|
+
rpcs_by_peer: rpcs_by_peer
|
104
|
+
)
|
105
|
+
end
|
98
106
|
LoadBalancerStatsResponse.new(
|
107
|
+
rpcs_by_method: rpcs_by_method,
|
99
108
|
rpcs_by_peer: watcher['rpcs_by_peer'],
|
100
109
|
num_failures: watcher['no_remote_peer'] + watcher['rpcs_needed']
|
101
110
|
);
|
102
111
|
end
|
103
112
|
end
|
104
113
|
|
114
|
+
# execute 1 RPC and return remote hostname
|
115
|
+
def execute_rpc(op, fail_on_failed_rpcs)
|
116
|
+
remote_peer = ""
|
117
|
+
begin
|
118
|
+
op.execute
|
119
|
+
if op.metadata.key?('hostname')
|
120
|
+
remote_peer = op.metadata['hostname']
|
121
|
+
end
|
122
|
+
rescue GRPC::BadStatus => e
|
123
|
+
GRPC.logger.info("ruby xds: rpc failed:|#{e.message}|, " \
|
124
|
+
"this may or may not be expected")
|
125
|
+
if fail_on_failed_rpcs
|
126
|
+
raise e
|
127
|
+
end
|
128
|
+
end
|
129
|
+
remote_peer
|
130
|
+
end
|
131
|
+
|
105
132
|
# send 1 rpc every 1/qps second
|
106
|
-
def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs
|
133
|
+
def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs,
|
134
|
+
rpcs_to_send, metadata_to_send)
|
107
135
|
include Grpc::Testing
|
108
|
-
|
136
|
+
simple_req = SimpleRequest.new()
|
137
|
+
empty_req = Empty.new()
|
109
138
|
target_next_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
110
139
|
while !$shutdown
|
111
140
|
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
@@ -121,25 +150,42 @@ def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs)
|
|
121
150
|
target_next_start += target_seconds_between_rpcs
|
122
151
|
sleep(sleep_seconds)
|
123
152
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
153
|
+
deadline = GRPC::Core::TimeConsts::from_relative_time(30) # 30 seconds
|
154
|
+
results = {}
|
155
|
+
rpcs_to_send.each do |rpc|
|
156
|
+
metadata = metadata_to_send.key?(rpc) ? metadata_to_send[rpc] : {}
|
157
|
+
if rpc == 'UnaryCall'
|
158
|
+
op = stub.unary_call(simple_req,
|
159
|
+
metadata: metadata,
|
160
|
+
deadline: deadline,
|
161
|
+
return_op: true)
|
162
|
+
elsif rpc == 'EmptyCall'
|
163
|
+
op = stub.empty_call(empty_req,
|
164
|
+
metadata: metadata,
|
165
|
+
deadline: deadline,
|
166
|
+
return_op: true)
|
167
|
+
else
|
168
|
+
raise "Unsupported rpc %s" % [rpc]
|
134
169
|
end
|
170
|
+
results[rpc] = execute_rpc(op, fail_on_failed_rpcs)
|
135
171
|
end
|
136
172
|
$watchers_mutex.synchronize do
|
137
173
|
$watchers.each do |watcher|
|
174
|
+
# this is counted once when each group of all rpcs_to_send were done
|
138
175
|
watcher['rpcs_needed'] -= 1
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
176
|
+
results.each do |rpc_name, remote_peer|
|
177
|
+
if remote_peer.strip.empty?
|
178
|
+
# error is counted per individual RPC
|
179
|
+
watcher['no_remote_peer'] += 1
|
180
|
+
else
|
181
|
+
if not watcher['rpcs_by_method'].key?(rpc_name)
|
182
|
+
watcher['rpcs_by_method'][rpc_name] = Hash.new(0)
|
183
|
+
end
|
184
|
+
# increment the remote hostname distribution histogram
|
185
|
+
# both by overall, and broken down per RPC
|
186
|
+
watcher['rpcs_by_method'][rpc_name][remote_peer] += 1
|
187
|
+
watcher['rpcs_by_peer'][remote_peer] += 1
|
188
|
+
end
|
143
189
|
end
|
144
190
|
end
|
145
191
|
$watchers_cv.broadcast
|
@@ -149,6 +195,7 @@ end
|
|
149
195
|
|
150
196
|
# Args is used to hold the command line info.
|
151
197
|
Args = Struct.new(:fail_on_failed_rpcs, :num_channels,
|
198
|
+
:rpc, :metadata,
|
152
199
|
:server, :stats_port, :qps)
|
153
200
|
|
154
201
|
# validates the command line options, returning them as a Hash.
|
@@ -156,6 +203,8 @@ def parse_args
|
|
156
203
|
args = Args.new
|
157
204
|
args['fail_on_failed_rpcs'] = false
|
158
205
|
args['num_channels'] = 1
|
206
|
+
args['rpc'] = 'UnaryCall'
|
207
|
+
args['metadata'] = ''
|
159
208
|
OptionParser.new do |opts|
|
160
209
|
opts.on('--fail_on_failed_rpcs BOOL', ['false', 'true']) do |v|
|
161
210
|
args['fail_on_failed_rpcs'] = v == 'true'
|
@@ -163,6 +212,12 @@ def parse_args
|
|
163
212
|
opts.on('--num_channels CHANNELS', 'number of channels') do |v|
|
164
213
|
args['num_channels'] = v.to_i
|
165
214
|
end
|
215
|
+
opts.on('--rpc RPCS_TO_SEND', 'list of RPCs to send') do |v|
|
216
|
+
args['rpc'] = v
|
217
|
+
end
|
218
|
+
opts.on('--metadata METADATA_TO_SEND', 'metadata to send per RPC') do |v|
|
219
|
+
args['metadata'] = v
|
220
|
+
end
|
166
221
|
opts.on('--server SERVER_HOST', 'server hostname') do |v|
|
167
222
|
GRPC.logger.info("ruby xds: server address is #{v}")
|
168
223
|
args['server'] = v
|
@@ -195,11 +250,40 @@ def main
|
|
195
250
|
# The client just sends unary rpcs continuously in a regular interval
|
196
251
|
stub = create_stub(opts)
|
197
252
|
target_seconds_between_rpcs = (1.0 / opts['qps'].to_f)
|
253
|
+
rpcs_to_send = []
|
254
|
+
if opts['rpc']
|
255
|
+
rpcs_to_send = opts['rpc'].split(',')
|
256
|
+
end
|
257
|
+
# Convert 'metadata' input in the form of
|
258
|
+
# rpc1:k1:v1,rpc2:k2:v2,rpc1:k3:v3
|
259
|
+
# into
|
260
|
+
# {
|
261
|
+
# 'rpc1' => {
|
262
|
+
# 'k1' => 'v1',
|
263
|
+
# 'k3' => 'v3',
|
264
|
+
# },
|
265
|
+
# 'rpc2' => {
|
266
|
+
# 'k2' => 'v2'
|
267
|
+
# },
|
268
|
+
# }
|
269
|
+
metadata_to_send = {}
|
270
|
+
if opts['metadata']
|
271
|
+
metadata_entries = opts['metadata'].split(',')
|
272
|
+
metadata_entries.each do |e|
|
273
|
+
(rpc_name, metadata_key, metadata_value) = e.split(':')
|
274
|
+
# initialize if we haven't seen this rpc_name yet
|
275
|
+
if !metadata_to_send.key?(rpc_name)
|
276
|
+
metadata_to_send[rpc_name] = {}
|
277
|
+
end
|
278
|
+
metadata_to_send[rpc_name][metadata_key] = metadata_value
|
279
|
+
end
|
280
|
+
end
|
198
281
|
client_threads = Array.new
|
199
282
|
opts['num_channels'].times {
|
200
283
|
client_threads << Thread.new {
|
201
284
|
run_test_loop(stub, target_seconds_between_rpcs,
|
202
|
-
opts['fail_on_failed_rpcs']
|
285
|
+
opts['fail_on_failed_rpcs'],
|
286
|
+
rpcs_to_send, metadata_to_send)
|
203
287
|
}
|
204
288
|
}
|
205
289
|
|
@@ -50,6 +50,16 @@ describe GRPC::Core::ChannelCredentials do
|
|
50
50
|
blk = proc { ChannelCredentials.new(nil) }
|
51
51
|
expect(&blk).not_to raise_error
|
52
52
|
end
|
53
|
+
|
54
|
+
it 'fails gracefully with constructed with a nil private key' do
|
55
|
+
blk = proc { GRPC::Core::ChannelCredentials.new(nil, nil, '') }
|
56
|
+
expect(&blk).to raise_error
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'fails gracefully with constructed with a nil cert chain' do
|
60
|
+
blk = proc { GRPC::Core::ChannelCredentials.new(nil, '', nil) }
|
61
|
+
expect(&blk).to raise_error
|
62
|
+
end
|
53
63
|
end
|
54
64
|
|
55
65
|
describe '#compose' do
|
@@ -43,6 +43,16 @@ describe GRPC::ActiveCall do
|
|
43
43
|
@server = new_core_server_for_testing(nil)
|
44
44
|
server_port = @server.add_http2_port(host, :this_port_is_insecure)
|
45
45
|
@server.start
|
46
|
+
@received_rpcs_queue = Queue.new
|
47
|
+
@server_thread = Thread.new do
|
48
|
+
begin
|
49
|
+
received_rpc = @server.request_call
|
50
|
+
rescue GRPC::Core::CallError, StandardError => e
|
51
|
+
# enqueue the exception in this case as a way to indicate the error
|
52
|
+
received_rpc = e
|
53
|
+
end
|
54
|
+
@received_rpcs_queue.push(received_rpc)
|
55
|
+
end
|
46
56
|
@ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
|
47
57
|
:this_channel_is_insecure)
|
48
58
|
end
|
@@ -50,6 +60,7 @@ describe GRPC::ActiveCall do
|
|
50
60
|
after(:each) do
|
51
61
|
@server.shutdown_and_notify(deadline)
|
52
62
|
@server.close
|
63
|
+
@server_thread.join
|
53
64
|
end
|
54
65
|
|
55
66
|
describe 'restricted view methods' do
|
@@ -105,7 +116,7 @@ describe GRPC::ActiveCall do
|
|
105
116
|
client_call.remote_send(msg)
|
106
117
|
|
107
118
|
# check that server rpc new was received
|
108
|
-
recvd_rpc = @
|
119
|
+
recvd_rpc = @received_rpcs_queue.pop
|
109
120
|
expect(recvd_rpc).to_not eq nil
|
110
121
|
recvd_call = recvd_rpc.call
|
111
122
|
|
@@ -130,7 +141,7 @@ describe GRPC::ActiveCall do
|
|
130
141
|
client_call.remote_send(msg)
|
131
142
|
|
132
143
|
# confirm that the message was marshalled
|
133
|
-
recvd_rpc = @
|
144
|
+
recvd_rpc = @received_rpcs_queue.pop
|
134
145
|
recvd_call = recvd_rpc.call
|
135
146
|
server_ops = {
|
136
147
|
CallOps::SEND_INITIAL_METADATA => nil
|
@@ -160,7 +171,7 @@ describe GRPC::ActiveCall do
|
|
160
171
|
call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil) if f == 1
|
161
172
|
|
162
173
|
# confirm that the message was marshalled
|
163
|
-
recvd_rpc = @
|
174
|
+
recvd_rpc = @received_rpcs_queue.pop
|
164
175
|
recvd_call = recvd_rpc.call
|
165
176
|
server_ops = {
|
166
177
|
CallOps::SEND_INITIAL_METADATA => nil
|
@@ -321,7 +332,7 @@ describe GRPC::ActiveCall do
|
|
321
332
|
call = make_test_call
|
322
333
|
metadata = { k1: 'v1', k2: 'v2' }
|
323
334
|
ActiveCall.client_invoke(call, metadata)
|
324
|
-
recvd_rpc = @
|
335
|
+
recvd_rpc = @received_rpcs_queue.pop
|
325
336
|
recvd_call = recvd_rpc.call
|
326
337
|
expect(recvd_call).to_not be_nil
|
327
338
|
expect(recvd_rpc.metadata).to_not be_nil
|
@@ -339,7 +350,7 @@ describe GRPC::ActiveCall do
|
|
339
350
|
call = make_test_call
|
340
351
|
ActiveCall.client_invoke(call)
|
341
352
|
|
342
|
-
recvd_rpc = @
|
353
|
+
recvd_rpc = @received_rpcs_queue.pop
|
343
354
|
server_call = ActiveCall.new(
|
344
355
|
recvd_rpc.call,
|
345
356
|
@pass_through,
|
@@ -405,7 +416,7 @@ describe GRPC::ActiveCall do
|
|
405
416
|
client_call = make_test_call
|
406
417
|
ActiveCall.client_invoke(client_call)
|
407
418
|
|
408
|
-
recvd_rpc = @
|
419
|
+
recvd_rpc = @received_rpcs_queue.pop
|
409
420
|
recvd_call = recvd_rpc.call
|
410
421
|
|
411
422
|
server_call = ActiveCall.new(
|
@@ -575,7 +586,7 @@ describe GRPC::ActiveCall do
|
|
575
586
|
@client_call = make_test_call
|
576
587
|
@client_call.run_batch(CallOps::SEND_INITIAL_METADATA => {})
|
577
588
|
|
578
|
-
recvd_rpc = @
|
589
|
+
recvd_rpc = @received_rpcs_queue.pop
|
579
590
|
recvd_call = recvd_rpc.call
|
580
591
|
@server_call = ActiveCall.new(
|
581
592
|
recvd_call,
|
@@ -654,7 +665,7 @@ describe GRPC::ActiveCall do
|
|
654
665
|
end
|
655
666
|
|
656
667
|
def expect_server_to_be_invoked(**kw)
|
657
|
-
recvd_rpc = @
|
668
|
+
recvd_rpc = @received_rpcs_queue.pop
|
658
669
|
expect(recvd_rpc).to_not eq nil
|
659
670
|
recvd_call = recvd_rpc.call
|
660
671
|
recvd_call.run_batch(CallOps::SEND_INITIAL_METADATA => kw)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// Copyright 2020 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
|
+
package same_name;
|
18
|
+
|
19
|
+
service SameName {
|
20
|
+
rpc Health(Request) returns (Status);
|
21
|
+
}
|
22
|
+
|
23
|
+
message Status {
|
24
|
+
string msg = 1;
|
25
|
+
}
|
26
|
+
|
27
|
+
message Request {}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// Copyright 2020 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
|
+
package other_name;
|
18
|
+
|
19
|
+
option ruby_package = "SameName2";
|
20
|
+
|
21
|
+
service SameName2 {
|
22
|
+
rpc Health(Request) returns (Status);
|
23
|
+
}
|
24
|
+
|
25
|
+
message Status {
|
26
|
+
string msg = 1;
|
27
|
+
}
|
28
|
+
|
29
|
+
message Request {}
|
@@ -48,6 +48,26 @@ describe 'Code Generation Options' do
|
|
48
48
|
expect(services[:NestedMessageTest].output).to eq(RPC::Test::New::Package::Options::Bar::Baz)
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
it 'should generate when package and service has same name' do
|
53
|
+
with_protos(['grpc/testing/same_package_service_name.proto']) do
|
54
|
+
expect { SameName::SameName::Service }.to raise_error(NameError)
|
55
|
+
expect(require('grpc/testing/same_package_service_name_services_pb')).to be_truthy
|
56
|
+
expect { SameName::SameName::Service }.to_not raise_error
|
57
|
+
expect { SameName::Request }.to_not raise_error
|
58
|
+
expect { SameName::Status }.to_not raise_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should generate when ruby_package and service has same name' do
|
63
|
+
with_protos(['grpc/testing/same_ruby_package_service_name.proto']) do
|
64
|
+
expect { SameName2::SameName2::Service }.to raise_error(NameError)
|
65
|
+
expect(require('grpc/testing/same_ruby_package_service_name_services_pb')).to be_truthy
|
66
|
+
expect { SameName2::SameName2::Service }.to_not raise_error
|
67
|
+
expect { SameName2::Request }.to_not raise_error
|
68
|
+
expect { SameName2::Status }.to_not raise_error
|
69
|
+
end
|
70
|
+
end
|
51
71
|
end
|
52
72
|
|
53
73
|
def with_protos(file_paths)
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright 2020 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
|
+
require 'spec_helper'
|
16
|
+
|
17
|
+
# a test service that checks the cert of its peer
|
18
|
+
class UserAgentEchoService
|
19
|
+
include GRPC::GenericService
|
20
|
+
rpc :an_rpc, EchoMsg, EchoMsg
|
21
|
+
|
22
|
+
def an_rpc(_req, call)
|
23
|
+
EchoMsg.new(msg: call.metadata['user-agent'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
UserAgentEchoServiceStub = UserAgentEchoService.rpc_stub_class
|
28
|
+
|
29
|
+
describe 'user agent' do
|
30
|
+
RpcServer = GRPC::RpcServer
|
31
|
+
|
32
|
+
before(:all) do
|
33
|
+
server_opts = {
|
34
|
+
poll_period: 1
|
35
|
+
}
|
36
|
+
@srv = new_rpc_server_for_testing(**server_opts)
|
37
|
+
@port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
|
38
|
+
@srv.handle(UserAgentEchoService)
|
39
|
+
@srv_thd = Thread.new { @srv.run }
|
40
|
+
@srv.wait_till_running
|
41
|
+
end
|
42
|
+
|
43
|
+
after(:all) do
|
44
|
+
expect(@srv.stopped?).to be(false)
|
45
|
+
@srv.stop
|
46
|
+
@srv_thd.join
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'client sends expected user agent' do
|
50
|
+
stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
|
51
|
+
:this_channel_is_insecure,
|
52
|
+
{})
|
53
|
+
response = stub.an_rpc(EchoMsg.new)
|
54
|
+
expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
|
55
|
+
expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
|
56
|
+
# check that the expected user agent prefix occurs in the real user agent exactly once
|
57
|
+
expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'user agent header does not grow when the same channel args hash is used across multiple stubs' do
|
61
|
+
shared_channel_args_hash = {}
|
62
|
+
10.times do
|
63
|
+
stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
|
64
|
+
:this_channel_is_insecure,
|
65
|
+
channel_args: shared_channel_args_hash)
|
66
|
+
response = stub.an_rpc(EchoMsg.new)
|
67
|
+
puts "got echo response: #{response.msg}"
|
68
|
+
expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
|
69
|
+
expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
|
70
|
+
# check that the expected user agent prefix occurs in the real user agent exactly once
|
71
|
+
expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.33.0.pre1
|
5
5
|
platform: universal-darwin
|
6
6
|
authors:
|
7
7
|
- gRPC Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: src/ruby/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.13'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: googleapis-common-protos-types
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -308,6 +308,8 @@ files:
|
|
308
308
|
- src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto
|
309
309
|
- src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto
|
310
310
|
- src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto
|
311
|
+
- src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto
|
312
|
+
- src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto
|
311
313
|
- src/ruby/spec/pb/codegen/package_option_spec.rb
|
312
314
|
- src/ruby/spec/pb/duplicate/codegen_spec.rb
|
313
315
|
- src/ruby/spec/pb/health/checker_spec.rb
|
@@ -323,6 +325,7 @@ files:
|
|
323
325
|
- src/ruby/spec/testdata/server1.key
|
324
326
|
- src/ruby/spec/testdata/server1.pem
|
325
327
|
- src/ruby/spec/time_consts_spec.rb
|
328
|
+
- src/ruby/spec/user_agent_spec.rb
|
326
329
|
homepage: https://github.com/google/grpc/tree/master/src/ruby
|
327
330
|
licenses:
|
328
331
|
- Apache-2.0
|
@@ -353,6 +356,7 @@ specification_version: 4
|
|
353
356
|
summary: GRPC system in Ruby
|
354
357
|
test_files:
|
355
358
|
- src/ruby/spec/time_consts_spec.rb
|
359
|
+
- src/ruby/spec/user_agent_spec.rb
|
356
360
|
- src/ruby/spec/spec_helper.rb
|
357
361
|
- src/ruby/spec/testdata/server1.key
|
358
362
|
- src/ruby/spec/testdata/server1.pem
|
@@ -362,7 +366,9 @@ test_files:
|
|
362
366
|
- src/ruby/spec/testdata/client.key
|
363
367
|
- src/ruby/spec/pb/health/checker_spec.rb
|
364
368
|
- src/ruby/spec/pb/codegen/grpc/testing/package_options.proto
|
369
|
+
- src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto
|
365
370
|
- src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto
|
371
|
+
- src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto
|
366
372
|
- src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto
|
367
373
|
- src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto
|
368
374
|
- src/ruby/spec/pb/codegen/package_option_spec.rb
|