grpc 0.14.1-x86-mingw32 → 0.15.0-x86-mingw32

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.

Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/grpc_c.32.ruby +0 -0
  3. data/grpc_c.64.ruby +0 -0
  4. data/src/ruby/bin/math_services.rb +41 -2
  5. data/src/ruby/ext/grpc/rb_call.c +42 -40
  6. data/src/ruby/ext/grpc/rb_channel.c +1 -1
  7. data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
  8. data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
  9. data/src/ruby/ext/grpc/rb_grpc.c +1 -3
  10. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
  11. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
  12. data/src/ruby/ext/grpc/rb_loader.c +1 -1
  13. data/src/ruby/ext/grpc/rb_server.c +5 -3
  14. data/src/ruby/lib/grpc.rb +0 -3
  15. data/src/ruby/lib/grpc/2.0/grpc_c.so +0 -0
  16. data/src/ruby/lib/grpc/2.1/grpc_c.so +0 -0
  17. data/src/ruby/lib/grpc/2.2/grpc_c.so +0 -0
  18. data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
  19. data/src/ruby/lib/grpc/errors.rb +3 -2
  20. data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
  21. data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
  22. data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
  23. data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
  24. data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
  25. data/src/ruby/lib/grpc/generic/service.rb +8 -8
  26. data/src/ruby/lib/grpc/grpc_c.so +0 -0
  27. data/src/ruby/lib/grpc/version.rb +1 -1
  28. data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
  29. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
  30. data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
  31. data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
  32. data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
  33. data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
  34. data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
  35. data/src/ruby/pb/test/client.rb +5 -2
  36. data/src/ruby/spec/generic/active_call_spec.rb +3 -2
  37. data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
  38. data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
  39. data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
  40. data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
  41. metadata +6 -5
  42. data/src/ruby/ext/grpc/rb_signal.c +0 -70
  43. data/src/ruby/ext/grpc/rb_signal.h +0 -39
  44. data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -0,0 +1,110 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: src/proto/grpc/testing/test.proto for package 'grpc.testing'
3
+ # Original file comments:
4
+ # Copyright 2015-2016, Google Inc.
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # * Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ # * Redistributions in binary form must reproduce the above
14
+ # copyright notice, this list of conditions and the following disclaimer
15
+ # in the documentation and/or other materials provided with the
16
+ # distribution.
17
+ # * Neither the name of Google Inc. nor the names of its
18
+ # contributors may be used to endorse or promote products derived from
19
+ # this software without specific prior written permission.
20
+ #
21
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ #
33
+ # An integration test service that covers all the method signature permutations
34
+ # of unary/streaming requests/responses.
35
+ #
36
+
37
+ require 'grpc'
38
+ require 'src/proto/grpc/testing/test'
39
+
40
+ module Grpc
41
+ module Testing
42
+ module TestService
43
+ # A simple service to test the various types of RPCs and experiment with
44
+ # performance with various types of payload.
45
+ class Service
46
+
47
+ include GRPC::GenericService
48
+
49
+ self.marshal_class_method = :encode
50
+ self.unmarshal_class_method = :decode
51
+ self.service_name = 'grpc.testing.TestService'
52
+
53
+ # One empty request followed by one empty response.
54
+ rpc :EmptyCall, Empty, Empty
55
+ # One request followed by one response.
56
+ rpc :UnaryCall, SimpleRequest, SimpleResponse
57
+ # One request followed by a sequence of responses (streamed download).
58
+ # The server returns the payload with client desired type and sizes.
59
+ rpc :StreamingOutputCall, StreamingOutputCallRequest, stream(StreamingOutputCallResponse)
60
+ # A sequence of requests followed by one response (streamed upload).
61
+ # The server returns the aggregated size of client payload as the result.
62
+ rpc :StreamingInputCall, stream(StreamingInputCallRequest), StreamingInputCallResponse
63
+ # A sequence of requests with each request served by the server immediately.
64
+ # As one request could lead to multiple responses, this interface
65
+ # demonstrates the idea of full duplexing.
66
+ rpc :FullDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
67
+ # A sequence of requests followed by a sequence of responses.
68
+ # The server buffers all the client requests and then serves them in order. A
69
+ # stream of responses are returned to the client when the server starts with
70
+ # first request.
71
+ rpc :HalfDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
72
+ end
73
+
74
+ Stub = Service.rpc_stub_class
75
+ end
76
+ module UnimplementedService
77
+ # A simple service NOT implemented at servers so clients can test for
78
+ # that case.
79
+ class Service
80
+
81
+ include GRPC::GenericService
82
+
83
+ self.marshal_class_method = :encode
84
+ self.unmarshal_class_method = :decode
85
+ self.service_name = 'grpc.testing.UnimplementedService'
86
+
87
+ # A call that no server should implement
88
+ rpc :UnimplementedCall, Empty, Empty
89
+ end
90
+
91
+ Stub = Service.rpc_stub_class
92
+ end
93
+ module ReconnectService
94
+ # A service used to control reconnect server.
95
+ class Service
96
+
97
+ include GRPC::GenericService
98
+
99
+ self.marshal_class_method = :encode
100
+ self.unmarshal_class_method = :decode
101
+ self.service_name = 'grpc.testing.ReconnectService'
102
+
103
+ rpc :Start, ReconnectParams, Empty
104
+ rpc :Stop, Empty, ReconnectInfo
105
+ end
106
+
107
+ Stub = Service.rpc_stub_class
108
+ end
109
+ end
110
+ end
@@ -114,7 +114,9 @@ def create_stub(opts)
114
114
  if opts.secure
115
115
  creds = ssl_creds(opts.use_test_ca)
116
116
  stub_opts = {
117
- GRPC::Core::Channel::SSL_TARGET => opts.host_override
117
+ channel_args: {
118
+ GRPC::Core::Channel::SSL_TARGET => opts.host_override
119
+ }
118
120
  }
119
121
 
120
122
  # Add service account creds if specified
@@ -315,7 +317,8 @@ class NamedTests
315
317
  def timeout_on_sleeping_server
316
318
  msg_sizes = [[27_182, 31_415]]
317
319
  ppp = PingPongPlayer.new(msg_sizes)
318
- resps = @stub.full_duplex_call(ppp.each_item, timeout: 0.001)
320
+ deadline = GRPC::Core::TimeConsts::from_relative_time(0.001)
321
+ resps = @stub.full_duplex_call(ppp.each_item, deadline: deadline)
319
322
  resps.each { |r| ppp.queue.push(r) }
320
323
  fail 'Should have raised GRPC::BadStatus(DEADLINE_EXCEEDED)'
321
324
  rescue GRPC::BadStatus => e
@@ -159,9 +159,10 @@ describe GRPC::ActiveCall do
159
159
  end
160
160
 
161
161
  describe '#client_invoke' do
162
- it 'sends keywords as metadata to the server when the are present' do
162
+ it 'sends metadata to the server when present' do
163
163
  call = make_test_call
164
- ActiveCall.client_invoke(call, @client_queue, k1: 'v1', k2: 'v2')
164
+ metadata = { k1: 'v1', k2: 'v2' }
165
+ ActiveCall.client_invoke(call, @client_queue, metadata)
165
166
  recvd_rpc = @server.request_call(@server_queue, @server_tag, deadline)
166
167
  recvd_call = recvd_rpc.call
167
168
  expect(recvd_call).to_not be_nil
@@ -68,15 +68,7 @@ describe 'ClientStub' do
68
68
  describe '#new' do
69
69
  let(:fake_host) { 'localhost:0' }
70
70
  it 'can be created from a host and args' do
71
- opts = { a_channel_arg: 'an_arg' }
72
- blk = proc do
73
- GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
74
- end
75
- expect(&blk).not_to raise_error
76
- end
77
-
78
- it 'can be created with a default deadline' do
79
- opts = { a_channel_arg: 'an_arg', deadline: 5 }
71
+ opts = { channel_args: { a_channel_arg: 'an_arg' } }
80
72
  blk = proc do
81
73
  GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
82
74
  end
@@ -84,7 +76,10 @@ describe 'ClientStub' do
84
76
  end
85
77
 
86
78
  it 'can be created with an channel override' do
87
- opts = { a_channel_arg: 'an_arg', channel_override: @ch }
79
+ opts = {
80
+ channel_args: { a_channel_arg: 'an_arg' },
81
+ channel_override: @ch
82
+ }
88
83
  blk = proc do
89
84
  GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
90
85
  end
@@ -93,7 +88,10 @@ describe 'ClientStub' do
93
88
 
94
89
  it 'cannot be created with a bad channel override' do
95
90
  blk = proc do
96
- opts = { a_channel_arg: 'an_arg', channel_override: Object.new }
91
+ opts = {
92
+ channel_args: { a_channel_arg: 'an_arg' },
93
+ channel_override: Object.new
94
+ }
97
95
  GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
98
96
  end
99
97
  expect(&blk).to raise_error
@@ -101,7 +99,7 @@ describe 'ClientStub' do
101
99
 
102
100
  it 'cannot be created with bad credentials' do
103
101
  blk = proc do
104
- opts = { a_channel_arg: 'an_arg' }
102
+ opts = { channel_args: { a_channel_arg: 'an_arg' } }
105
103
  GRPC::ClientStub.new(fake_host, @cq, Object.new, **opts)
106
104
  end
107
105
  expect(&blk).to raise_error
@@ -111,8 +109,10 @@ describe 'ClientStub' do
111
109
  certs = load_test_certs
112
110
  blk = proc do
113
111
  opts = {
114
- GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr',
115
- a_channel_arg: 'an_arg'
112
+ channel_args: {
113
+ GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr',
114
+ a_channel_arg: 'an_arg'
115
+ }
116
116
  }
117
117
  creds = GRPC::Core::ChannelCredentials.new(certs[0], nil, nil)
118
118
  GRPC::ClientStub.new(fake_host, @cq, creds, **opts)
@@ -172,7 +172,7 @@ describe 'ClientStub' do
172
172
  describe 'without a call operation' do
173
173
  def get_response(stub)
174
174
  stub.request_response(@method, @sent_msg, noop, noop,
175
- k1: 'v1', k2: 'v2')
175
+ metadata: { k1: 'v1', k2: 'v2' })
176
176
  end
177
177
 
178
178
  it_behaves_like 'request response'
@@ -181,7 +181,8 @@ describe 'ClientStub' do
181
181
  describe 'via a call operation' do
182
182
  def get_response(stub)
183
183
  op = stub.request_response(@method, @sent_msg, noop, noop,
184
- return_op: true, k1: 'v1', k2: 'v2')
184
+ return_op: true,
185
+ metadata: { k1: 'v1', k2: 'v2' })
185
186
  expect(op).to be_a(GRPC::ActiveCall::Operation)
186
187
  op.execute
187
188
  end
@@ -196,7 +197,7 @@ describe 'ClientStub' do
196
197
  server_port = create_test_server
197
198
  host = "localhost:#{server_port}"
198
199
  @stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
199
- @options = { k1: 'v1', k2: 'v2' }
200
+ @metadata = { k1: 'v1', k2: 'v2' }
200
201
  @sent_msgs = Array.new(3) { |i| 'msg_' + (i + 1).to_s }
201
202
  @resp = 'a_reply'
202
203
  end
@@ -208,7 +209,7 @@ describe 'ClientStub' do
208
209
  end
209
210
 
210
211
  it 'should send metadata to the server ok' do
211
- th = run_client_streamer(@sent_msgs, @resp, @pass, @options)
212
+ th = run_client_streamer(@sent_msgs, @resp, @pass, **@metadata)
212
213
  expect(get_response(@stub)).to eq(@resp)
213
214
  th.join
214
215
  end
@@ -221,7 +222,7 @@ describe 'ClientStub' do
221
222
  end
222
223
 
223
224
  it 'should raise ArgumentError if metadata contains invalid values' do
224
- @options.merge!(k3: 3)
225
+ @metadata.merge!(k3: 3)
225
226
  expect do
226
227
  get_response(@stub)
227
228
  end.to raise_error(ArgumentError,
@@ -231,7 +232,8 @@ describe 'ClientStub' do
231
232
 
232
233
  describe 'without a call operation' do
233
234
  def get_response(stub)
234
- stub.client_streamer(@method, @sent_msgs, noop, noop, @options)
235
+ stub.client_streamer(@method, @sent_msgs, noop, noop,
236
+ metadata: @metadata)
235
237
  end
236
238
 
237
239
  it_behaves_like 'client streaming'
@@ -240,7 +242,7 @@ describe 'ClientStub' do
240
242
  describe 'via a call operation' do
241
243
  def get_response(stub)
242
244
  op = stub.client_streamer(@method, @sent_msgs, noop, noop,
243
- @options.merge(return_op: true))
245
+ return_op: true, metadata: @metadata)
244
246
  expect(op).to be_a(GRPC::ActiveCall::Operation)
245
247
  op.execute
246
248
  end
@@ -290,7 +292,7 @@ describe 'ClientStub' do
290
292
  describe 'without a call operation' do
291
293
  def get_responses(stub)
292
294
  e = stub.server_streamer(@method, @sent_msg, noop, noop,
293
- k1: 'v1', k2: 'v2')
295
+ metadata: { k1: 'v1', k2: 'v2' })
294
296
  expect(e).to be_a(Enumerator)
295
297
  e
296
298
  end
@@ -301,7 +303,8 @@ describe 'ClientStub' do
301
303
  describe 'via a call operation' do
302
304
  def get_responses(stub)
303
305
  op = stub.server_streamer(@method, @sent_msg, noop, noop,
304
- return_op: true, k1: 'v1', k2: 'v2')
306
+ return_op: true,
307
+ metadata: { k1: 'v1', k2: 'v2' })
305
308
  expect(op).to be_a(GRPC::ActiveCall::Operation)
306
309
  e = op.execute
307
310
  expect(e).to be_a(Enumerator)
@@ -383,7 +386,7 @@ describe 'ClientStub' do
383
386
  stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
384
387
  blk = proc do
385
388
  e = stub.bidi_streamer(@method, @sent_msgs, noop, noop,
386
- timeout: 0.001)
389
+ deadline: from_relative_time(0.001))
387
390
  e.collect { |r| r }
388
391
  end
389
392
  expect(&blk).to raise_error GRPC::BadStatus, /Deadline Exceeded/
@@ -56,14 +56,14 @@ describe GRPC::RpcDesc do
56
56
  it 'sends the specified status if BadStatus is raised' do
57
57
  expect(@call).to receive(:remote_read).once.and_return(Object.new)
58
58
  expect(@call).to receive(:send_status).once.with(@bs_code, 'NOK', false,
59
- {})
59
+ metadata: {})
60
60
  this_desc.run_server_method(@call, method(:bad_status))
61
61
  end
62
62
 
63
63
  it 'sends status UNKNOWN if other StandardErrors are raised' do
64
64
  expect(@call).to receive(:remote_read).once.and_return(Object.new)
65
65
  expect(@call).to receive(:send_status) .once.with(UNKNOWN, @no_reason,
66
- false, {})
66
+ false, metadata: {})
67
67
  this_desc.run_server_method(@call, method(:other_error))
68
68
  end
69
69
 
@@ -93,7 +93,7 @@ describe GRPC::RpcDesc do
93
93
  expect(@call).to receive(:remote_send).once.with(@ok_response)
94
94
  expect(@call).to receive(:output_metadata).and_return(fake_md)
95
95
  expect(@call).to receive(:send_status).once.with(OK, 'OK', true,
96
- **fake_md)
96
+ metadata: fake_md)
97
97
  this_desc.run_server_method(@call, method(:fake_reqresp))
98
98
  end
99
99
  end
@@ -106,13 +106,13 @@ describe GRPC::RpcDesc do
106
106
 
107
107
  it 'sends the specified status if BadStatus is raised' do
108
108
  expect(@call).to receive(:send_status).once.with(@bs_code, 'NOK', false,
109
- {})
109
+ metadata: {})
110
110
  @client_streamer.run_server_method(@call, method(:bad_status_alt))
111
111
  end
112
112
 
113
113
  it 'sends status UNKNOWN if other StandardErrors are raised' do
114
- expect(@call).to receive(:send_status) .once.with(UNKNOWN, @no_reason,
115
- false, {})
114
+ expect(@call).to receive(:send_status).once.with(UNKNOWN, @no_reason,
115
+ false, metadata: {})
116
116
  @client_streamer.run_server_method(@call, method(:other_error_alt))
117
117
  end
118
118
 
@@ -128,7 +128,7 @@ describe GRPC::RpcDesc do
128
128
  expect(@call).to receive(:remote_send).once.with(@ok_response)
129
129
  expect(@call).to receive(:output_metadata).and_return(fake_md)
130
130
  expect(@call).to receive(:send_status).once.with(OK, 'OK', true,
131
- **fake_md)
131
+ metadata: fake_md)
132
132
  @client_streamer.run_server_method(@call, method(:fake_clstream))
133
133
  end
134
134
  end
@@ -148,7 +148,7 @@ describe GRPC::RpcDesc do
148
148
  expect(@call).to receive(:remote_send).twice.with(@ok_response)
149
149
  expect(@call).to receive(:output_metadata).and_return(fake_md)
150
150
  expect(@call).to receive(:send_status).once.with(OK, 'OK', true,
151
- **fake_md)
151
+ metadata: fake_md)
152
152
  @server_streamer.run_server_method(@call, method(:fake_svstream))
153
153
  end
154
154
  end
@@ -165,14 +165,14 @@ describe GRPC::RpcDesc do
165
165
  e = GRPC::BadStatus.new(@bs_code, 'NOK')
166
166
  expect(@call).to receive(:run_server_bidi).and_raise(e)
167
167
  expect(@call).to receive(:send_status).once.with(@bs_code, 'NOK', false,
168
- {})
168
+ metadata: {})
169
169
  @bidi_streamer.run_server_method(@call, method(:bad_status_alt))
170
170
  end
171
171
 
172
172
  it 'sends status UNKNOWN if other StandardErrors are raised' do
173
173
  expect(@call).to receive(:run_server_bidi).and_raise(StandardError)
174
174
  expect(@call).to receive(:send_status).once.with(UNKNOWN, @no_reason,
175
- false, {})
175
+ false, metadata: {})
176
176
  @bidi_streamer.run_server_method(@call, method(:other_error_alt))
177
177
  end
178
178
 
@@ -180,7 +180,7 @@ describe GRPC::RpcDesc do
180
180
  expect(@call).to receive(:run_server_bidi)
181
181
  expect(@call).to receive(:output_metadata).and_return(fake_md)
182
182
  expect(@call).to receive(:send_status).once.with(OK, 'OK', true,
183
- **fake_md)
183
+ metadata: fake_md)
184
184
  @bidi_streamer.run_server_method(@call, method(:fake_bidistream))
185
185
  end
186
186
  end
@@ -99,7 +99,7 @@ class FailingService
99
99
  end
100
100
 
101
101
  def an_rpc(_req, _call)
102
- fail GRPC::BadStatus.new(@code, @details, **@md)
102
+ fail GRPC::BadStatus.new(@code, @details, @md)
103
103
  end
104
104
  end
105
105
 
@@ -137,24 +137,11 @@ describe GRPC::RpcServer do
137
137
  @noop = proc { |x| x }
138
138
 
139
139
  @server_queue = GRPC::Core::CompletionQueue.new
140
- server_host = '0.0.0.0:0'
141
- @server = GRPC::Core::Server.new(@server_queue, nil)
142
- server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
143
- @host = "localhost:#{server_port}"
144
- @ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
145
140
  end
146
141
 
147
142
  describe '#new' do
148
143
  it 'can be created with just some args' do
149
- opts = { a_channel_arg: 'an_arg' }
150
- blk = proc do
151
- RpcServer.new(**opts)
152
- end
153
- expect(&blk).not_to raise_error
154
- end
155
-
156
- it 'can be created with a default deadline' do
157
- opts = { a_channel_arg: 'an_arg', deadline: 5 }
144
+ opts = { server_args: { a_channel_arg: 'an_arg' } }
158
145
  blk = proc do
159
146
  RpcServer.new(**opts)
160
147
  end
@@ -163,7 +150,7 @@ describe GRPC::RpcServer do
163
150
 
164
151
  it 'can be created with a completion queue override' do
165
152
  opts = {
166
- a_channel_arg: 'an_arg',
153
+ server_args: { a_channel_arg: 'an_arg' },
167
154
  completion_queue_override: @server_queue
168
155
  }
169
156
  blk = proc do
@@ -175,7 +162,7 @@ describe GRPC::RpcServer do
175
162
  it 'cannot be created with a bad completion queue override' do
176
163
  blk = proc do
177
164
  opts = {
178
- a_channel_arg: 'an_arg',
165
+ server_args: { a_channel_arg: 'an_arg' },
179
166
  completion_queue_override: Object.new
180
167
  }
181
168
  RpcServer.new(**opts)
@@ -186,38 +173,20 @@ describe GRPC::RpcServer do
186
173
  it 'cannot be created with invalid ServerCredentials' do
187
174
  blk = proc do
188
175
  opts = {
189
- a_channel_arg: 'an_arg',
176
+ server_args: { a_channel_arg: 'an_arg' },
190
177
  creds: Object.new
191
178
  }
192
179
  RpcServer.new(**opts)
193
180
  end
194
181
  expect(&blk).to raise_error
195
182
  end
196
-
197
- it 'can be created with a server override' do
198
- opts = { a_channel_arg: 'an_arg', server_override: @server }
199
- blk = proc do
200
- RpcServer.new(**opts)
201
- end
202
- expect(&blk).not_to raise_error
203
- end
204
-
205
- it 'cannot be created with a bad server override' do
206
- blk = proc do
207
- opts = {
208
- a_channel_arg: 'an_arg',
209
- server_override: Object.new
210
- }
211
- RpcServer.new(**opts)
212
- end
213
- expect(&blk).to raise_error
214
- end
215
183
  end
216
184
 
217
185
  describe '#stopped?' do
218
186
  before(:each) do
219
- opts = { a_channel_arg: 'an_arg', poll_period: 1.5 }
187
+ opts = { server_args: { a_channel_arg: 'an_arg' }, poll_period: 1.5 }
220
188
  @srv = RpcServer.new(**opts)
189
+ @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
221
190
  end
222
191
 
223
192
  it 'starts out false' do
@@ -245,28 +214,30 @@ describe GRPC::RpcServer do
245
214
 
246
215
  describe '#running?' do
247
216
  it 'starts out false' do
248
- opts = { a_channel_arg: 'an_arg', server_override: @server }
217
+ opts = {
218
+ server_args: { a_channel_arg: 'an_arg' }
219
+ }
249
220
  r = RpcServer.new(**opts)
250
221
  expect(r.running?).to be(false)
251
222
  end
252
223
 
253
224
  it 'is false if run is called with no services registered', server: true do
254
225
  opts = {
255
- a_channel_arg: 'an_arg',
256
- poll_period: 2,
257
- server_override: @server
226
+ server_args: { a_channel_arg: 'an_arg' },
227
+ poll_period: 2
258
228
  }
259
229
  r = RpcServer.new(**opts)
230
+ r.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
260
231
  expect { r.run }.to raise_error(RuntimeError)
261
232
  end
262
233
 
263
234
  it 'is true after run is called with a registered service' do
264
235
  opts = {
265
- a_channel_arg: 'an_arg',
266
- poll_period: 2.5,
267
- server_override: @server
236
+ server_args: { a_channel_arg: 'an_arg' },
237
+ poll_period: 2.5
268
238
  }
269
239
  r = RpcServer.new(**opts)
240
+ r.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
270
241
  r.handle(EchoService)
271
242
  t = Thread.new { r.run }
272
243
  r.wait_till_running
@@ -278,8 +249,9 @@ describe GRPC::RpcServer do
278
249
 
279
250
  describe '#handle' do
280
251
  before(:each) do
281
- @opts = { a_channel_arg: 'an_arg', poll_period: 1 }
252
+ @opts = { server_args: { a_channel_arg: 'an_arg' }, poll_period: 1 }
282
253
  @srv = RpcServer.new(**@opts)
254
+ @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
283
255
  end
284
256
 
285
257
  it 'raises if #run has already been called' do
@@ -322,11 +294,13 @@ describe GRPC::RpcServer do
322
294
  context 'with no connect_metadata' do
323
295
  before(:each) do
324
296
  server_opts = {
325
- server_override: @server,
326
297
  completion_queue_override: @server_queue,
327
298
  poll_period: 1
328
299
  }
329
300
  @srv = RpcServer.new(**server_opts)
301
+ server_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
302
+ @host = "localhost:#{server_port}"
303
+ @ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
330
304
  end
331
305
 
332
306
  it 'should return NOT_FOUND status on unknown methods', server: true do
@@ -383,7 +357,8 @@ describe GRPC::RpcServer do
383
357
  @srv.wait_till_running
384
358
  req = EchoMsg.new
385
359
  stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
386
- expect(stub.an_rpc(req, k1: 'v1', k2: 'v2')).to be_a(EchoMsg)
360
+ expect(stub.an_rpc(req, metadata: { k1: 'v1', k2: 'v2' }))
361
+ .to be_a(EchoMsg)
387
362
  wanted_md = [{ 'k1' => 'v1', 'k2' => 'v2' }]
388
363
  check_md(wanted_md, service.received_md)
389
364
  @srv.stop
@@ -397,8 +372,11 @@ describe GRPC::RpcServer do
397
372
  @srv.wait_till_running
398
373
  req = EchoMsg.new
399
374
  stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
400
- timeout = service.delay + 1.0 # wait for long enough
401
- resp = stub.an_rpc(req, timeout: timeout, k1: 'v1', k2: 'v2')
375
+ timeout = service.delay + 1.0
376
+ deadline = GRPC::Core::TimeConsts.from_relative_time(timeout)
377
+ resp = stub.an_rpc(req,
378
+ deadline: deadline,
379
+ metadata: { k1: 'v1', k2: 'v2' })
402
380
  expect(resp).to be_a(EchoMsg)
403
381
  wanted_md = [{ 'k1' => 'v1', 'k2' => 'v2' }]
404
382
  check_md(wanted_md, service.received_md)
@@ -413,7 +391,7 @@ describe GRPC::RpcServer do
413
391
  @srv.wait_till_running
414
392
  req = EchoMsg.new
415
393
  stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
416
- op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
394
+ op = stub.an_rpc(req, metadata: { k1: 'v1', k2: 'v2' }, return_op: true)
417
395
  Thread.new do # cancel the call
418
396
  sleep 0.1
419
397
  op.cancel
@@ -443,8 +421,7 @@ describe GRPC::RpcServer do
443
421
 
444
422
  it 'should return RESOURCE_EXHAUSTED on too many jobs', server: true do
445
423
  opts = {
446
- a_channel_arg: 'an_arg',
447
- server_override: @server,
424
+ server_args: { a_channel_arg: 'an_arg' },
448
425
  completion_queue_override: @server_queue,
449
426
  pool_size: 1,
450
427
  poll_period: 1,
@@ -452,6 +429,8 @@ describe GRPC::RpcServer do
452
429
  }
453
430
  alt_srv = RpcServer.new(**opts)
454
431
  alt_srv.handle(SlowService)
432
+ alt_port = alt_srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
433
+ alt_host = "0.0.0.0:#{alt_port}"
455
434
  t = Thread.new { alt_srv.run }
456
435
  alt_srv.wait_till_running
457
436
  req = EchoMsg.new
@@ -460,7 +439,7 @@ describe GRPC::RpcServer do
460
439
  one_failed_as_unavailable = false
461
440
  n.times do
462
441
  threads << Thread.new do
463
- stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
442
+ stub = SlowStub.new(alt_host, :this_channel_is_insecure)
464
443
  begin
465
444
  stub.an_rpc(req)
466
445
  rescue GRPC::BadStatus => e
@@ -487,12 +466,13 @@ describe GRPC::RpcServer do
487
466
  end
488
467
  before(:each) do
489
468
  server_opts = {
490
- server_override: @server,
491
469
  completion_queue_override: @server_queue,
492
470
  poll_period: 1,
493
471
  connect_md_proc: test_md_proc
494
472
  }
495
473
  @srv = RpcServer.new(**server_opts)
474
+ alt_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
475
+ @alt_host = "0.0.0.0:#{alt_port}"
496
476
  end
497
477
 
498
478
  it 'should send connect metadata to the client', server: true do
@@ -501,8 +481,8 @@ describe GRPC::RpcServer do
501
481
  t = Thread.new { @srv.run }
502
482
  @srv.wait_till_running
503
483
  req = EchoMsg.new
504
- stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
505
- op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
484
+ stub = EchoStub.new(@alt_host, :this_channel_is_insecure)
485
+ op = stub.an_rpc(req, metadata: { k1: 'v1', k2: 'v2' }, return_op: true)
506
486
  expect(op.metadata).to be nil
507
487
  expect(op.execute).to be_a(EchoMsg)
508
488
  wanted_md = {
@@ -522,11 +502,12 @@ describe GRPC::RpcServer do
522
502
  context 'with trailing metadata' do
523
503
  before(:each) do
524
504
  server_opts = {
525
- server_override: @server,
526
505
  completion_queue_override: @server_queue,
527
506
  poll_period: 1
528
507
  }
529
508
  @srv = RpcServer.new(**server_opts)
509
+ alt_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
510
+ @alt_host = "0.0.0.0:#{alt_port}"
530
511
  end
531
512
 
532
513
  it 'should be added to BadStatus when requests fail', server: true do
@@ -535,7 +516,7 @@ describe GRPC::RpcServer do
535
516
  t = Thread.new { @srv.run }
536
517
  @srv.wait_till_running
537
518
  req = EchoMsg.new
538
- stub = FailingStub.new(@host, :this_channel_is_insecure, **client_opts)
519
+ stub = FailingStub.new(@alt_host, :this_channel_is_insecure)
539
520
  blk = proc { stub.an_rpc(req) }
540
521
 
541
522
  # confirm it raise the expected error
@@ -560,8 +541,8 @@ describe GRPC::RpcServer do
560
541
  t = Thread.new { @srv.run }
561
542
  @srv.wait_till_running
562
543
  req = EchoMsg.new
563
- stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
564
- op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
544
+ stub = EchoStub.new(@alt_host, :this_channel_is_insecure)
545
+ op = stub.an_rpc(req, return_op: true, metadata: { k1: 'v1', k2: 'v2' })
565
546
  expect(op.metadata).to be nil
566
547
  expect(op.execute).to be_a(EchoMsg)
567
548
  expect(op.metadata).to eq(wanted_trailers)