grpc 0.15.0 → 1.0.0.pre1
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/Makefile +127 -159
- data/etc/roots.pem +784 -509
- data/include/grpc/grpc_posix.h +8 -0
- data/include/grpc/impl/codegen/byte_buffer.h +5 -4
- data/include/grpc/impl/codegen/grpc_types.h +2 -0
- data/include/grpc/impl/codegen/port_platform.h +2 -1
- data/include/grpc/module.modulemap +15 -0
- data/src/core/ext/census/grpc_filter.c +3 -0
- data/src/core/ext/client_config/channel_connectivity.c +4 -3
- data/src/core/ext/client_config/client_channel.c +6 -0
- data/src/core/ext/client_config/subchannel.c +2 -0
- data/src/core/ext/client_config/subchannel_call_holder.c +2 -5
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +2 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +171 -104
- data/src/core/ext/transport/chttp2/transport/internal.h +5 -3
- data/src/core/ext/transport/chttp2/transport/parsing.c +4 -3
- data/src/core/ext/transport/chttp2/transport/status_conversion.c +8 -2
- data/src/core/ext/transport/chttp2/transport/status_conversion.h +1 -1
- data/src/core/lib/channel/channel_stack.c +12 -1
- data/src/core/lib/channel/channel_stack.h +5 -0
- data/src/core/lib/channel/http_client_filter.c +7 -1
- data/src/core/lib/debug/trace.c +6 -2
- data/src/core/lib/iomgr/error.c +62 -19
- data/src/core/lib/iomgr/error.h +10 -6
- data/src/core/lib/iomgr/ev_epoll_linux.c +1872 -0
- data/src/core/lib/{surface/surface_trace.h → iomgr/ev_epoll_linux.h} +11 -12
- data/src/core/lib/iomgr/ev_posix.c +9 -6
- data/src/core/lib/iomgr/ev_posix.h +3 -0
- data/src/core/lib/iomgr/network_status_tracker.c +121 -0
- data/{include/grpc/grpc_zookeeper.h → src/core/lib/iomgr/network_status_tracker.h} +8 -26
- data/src/core/lib/iomgr/socket_utils_common_posix.c +22 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_posix.c +6 -2
- data/src/core/lib/iomgr/tcp_server.h +3 -0
- data/src/core/lib/iomgr/tcp_server_posix.c +114 -16
- data/src/core/lib/iomgr/tcp_server_windows.c +1 -0
- data/src/core/lib/iomgr/tcp_windows.c +5 -0
- data/src/core/lib/iomgr/udp_server.c +28 -16
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +4 -2
- data/src/core/lib/profiling/basic_timers.c +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -3
- data/src/core/lib/security/credentials/credentials.c +1 -1
- data/src/core/lib/security/credentials/credentials.h +4 -5
- data/src/core/lib/security/credentials/fake/fake_credentials.c +2 -2
- data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +7 -6
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +6 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +4 -3
- data/src/core/lib/security/transport/client_auth_filter.c +10 -7
- data/src/core/lib/surface/byte_buffer_reader.c +6 -4
- data/src/core/lib/surface/call.c +64 -51
- data/src/core/lib/surface/call.h +0 -1
- data/src/core/lib/surface/channel.c +10 -8
- data/src/core/lib/surface/completion_queue.c +26 -12
- data/src/core/lib/surface/completion_queue.h +4 -0
- data/src/core/lib/surface/init.c +6 -1
- data/src/core/lib/surface/version.c +1 -1
- data/src/core/lib/transport/transport.c +62 -29
- data/src/core/lib/transport/transport.h +8 -5
- data/src/core/lib/transport/transport_op_string.c +14 -3
- data/src/ruby/ext/grpc/rb_byte_buffer.c +4 -1
- data/src/ruby/ext/grpc/rb_call.c +87 -54
- data/src/ruby/ext/grpc/rb_call.h +1 -1
- data/src/ruby/ext/grpc/rb_call_credentials.c +1 -30
- data/src/ruby/ext/grpc/rb_channel.c +25 -50
- data/src/ruby/ext/grpc/rb_channel_credentials.c +1 -31
- data/src/ruby/ext/grpc/rb_completion_queue.c +15 -134
- data/src/ruby/ext/grpc/rb_completion_queue.h +3 -7
- data/src/ruby/ext/grpc/rb_grpc.c +2 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
- data/src/ruby/ext/grpc/rb_server.c +81 -133
- data/src/ruby/ext/grpc/rb_server_credentials.c +4 -33
- data/src/ruby/lib/grpc/generic/active_call.rb +40 -55
- data/src/ruby/lib/grpc/generic/bidi_call.rb +21 -23
- data/src/ruby/lib/grpc/generic/client_stub.rb +20 -15
- data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -37
- data/src/ruby/lib/grpc/generic/service.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/test/client.rb +25 -7
- data/src/ruby/pb/test/server.rb +7 -5
- data/src/ruby/spec/call_spec.rb +1 -2
- data/src/ruby/spec/channel_spec.rb +2 -3
- data/src/ruby/spec/client_server_spec.rb +74 -59
- data/src/ruby/spec/generic/active_call_spec.rb +66 -86
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -48
- data/src/ruby/spec/generic/rpc_server_spec.rb +4 -34
- data/src/ruby/spec/pb/health/checker_spec.rb +0 -2
- data/src/ruby/spec/server_spec.rb +20 -24
- metadata +9 -8
- data/src/ruby/spec/completion_queue_spec.rb +0 -42
@@ -168,7 +168,7 @@ module GRPC
|
|
168
168
|
# @param kw [KeywordArgs] the channel arguments, plus any optional
|
169
169
|
# args for configuring the client's channel
|
170
170
|
def initialize(host, creds, **kw)
|
171
|
-
super(host,
|
171
|
+
super(host, creds, **kw)
|
172
172
|
end
|
173
173
|
|
174
174
|
# Used define_method to add a method for each rpc_desc. Each method
|
data/src/ruby/pb/test/client.rb
CHANGED
@@ -197,6 +197,25 @@ class PingPongPlayer
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
+
class BlockingEnumerator
|
201
|
+
include Grpc::Testing
|
202
|
+
include Grpc::Testing::PayloadType
|
203
|
+
|
204
|
+
def initialize(req_size, sleep_time)
|
205
|
+
@req_size = req_size
|
206
|
+
@sleep_time = sleep_time
|
207
|
+
end
|
208
|
+
|
209
|
+
def each_item
|
210
|
+
return enum_for(:each_item) unless block_given?
|
211
|
+
req_cls = StreamingOutputCallRequest
|
212
|
+
req = req_cls.new(payload: Payload.new(body: nulls(@req_size)))
|
213
|
+
yield req
|
214
|
+
# Sleep until after the deadline should have passed
|
215
|
+
sleep(@sleep_time)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
200
219
|
# defines methods corresponding to each interop test case.
|
201
220
|
class NamedTests
|
202
221
|
include Grpc::Testing
|
@@ -315,11 +334,10 @@ class NamedTests
|
|
315
334
|
end
|
316
335
|
|
317
336
|
def timeout_on_sleeping_server
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
resps
|
322
|
-
resps.each { |r| ppp.queue.push(r) }
|
337
|
+
enum = BlockingEnumerator.new(27_182, 2)
|
338
|
+
deadline = GRPC::Core::TimeConsts::from_relative_time(1)
|
339
|
+
resps = @stub.full_duplex_call(enum.each_item, deadline: deadline)
|
340
|
+
resps.each { } # wait to receive each request (or timeout)
|
323
341
|
fail 'Should have raised GRPC::BadStatus(DEADLINE_EXCEEDED)'
|
324
342
|
rescue GRPC::BadStatus => e
|
325
343
|
assert("#{__callee__}: status was wrong") do
|
@@ -351,7 +369,7 @@ class NamedTests
|
|
351
369
|
op.execute
|
352
370
|
fail 'Should have raised GRPC:Cancelled'
|
353
371
|
rescue GRPC::Cancelled
|
354
|
-
assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled }
|
372
|
+
assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled? }
|
355
373
|
end
|
356
374
|
|
357
375
|
def cancel_after_first_response
|
@@ -362,7 +380,7 @@ class NamedTests
|
|
362
380
|
op.execute.each { |r| ppp.queue.push(r) }
|
363
381
|
fail 'Should have raised GRPC:Cancelled'
|
364
382
|
rescue GRPC::Cancelled
|
365
|
-
assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled }
|
383
|
+
assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled? }
|
366
384
|
op.wait
|
367
385
|
end
|
368
386
|
|
data/src/ruby/pb/test/server.rb
CHANGED
@@ -188,11 +188,13 @@ class TestTarget < Grpc::Testing::TestService::Service
|
|
188
188
|
begin
|
189
189
|
GRPC.logger.info('interop-server: started receiving')
|
190
190
|
reqs.each do |req|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
191
|
+
req.response_parameters.each do |params|
|
192
|
+
resp_size = params.size
|
193
|
+
GRPC.logger.info("read a req, response size is #{resp_size}")
|
194
|
+
resp = cls.new(payload: Payload.new(type: req.response_type,
|
195
|
+
body: nulls(resp_size)))
|
196
|
+
q.push(resp)
|
197
|
+
end
|
196
198
|
end
|
197
199
|
GRPC.logger.info('interop-server: finished receiving')
|
198
200
|
q.push(self)
|
data/src/ruby/spec/call_spec.rb
CHANGED
@@ -96,7 +96,6 @@ describe GRPC::Core::CallOps do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
describe GRPC::Core::Call do
|
99
|
-
let(:client_queue) { GRPC::Core::CompletionQueue.new }
|
100
99
|
let(:test_tag) { Object.new }
|
101
100
|
let(:fake_host) { 'localhost:10101' }
|
102
101
|
|
@@ -154,7 +153,7 @@ describe GRPC::Core::Call do
|
|
154
153
|
end
|
155
154
|
|
156
155
|
def make_test_call
|
157
|
-
@ch.create_call(
|
156
|
+
@ch.create_call(nil, nil, 'dummy_method', nil, deadline)
|
158
157
|
end
|
159
158
|
|
160
159
|
def deadline
|
@@ -37,7 +37,6 @@ end
|
|
37
37
|
|
38
38
|
describe GRPC::Core::Channel do
|
39
39
|
let(:fake_host) { 'localhost:0' }
|
40
|
-
let(:cq) { GRPC::Core::CompletionQueue.new }
|
41
40
|
|
42
41
|
def create_test_cert
|
43
42
|
GRPC::Core::ChannelCredentials.new(load_test_certs[0])
|
@@ -122,7 +121,7 @@ describe GRPC::Core::Channel do
|
|
122
121
|
deadline = Time.now + 5
|
123
122
|
|
124
123
|
blk = proc do
|
125
|
-
ch.create_call(
|
124
|
+
ch.create_call(nil, nil, 'dummy_method', nil, deadline)
|
126
125
|
end
|
127
126
|
expect(&blk).to_not raise_error
|
128
127
|
end
|
@@ -133,7 +132,7 @@ describe GRPC::Core::Channel do
|
|
133
132
|
|
134
133
|
deadline = Time.now + 5
|
135
134
|
blk = proc do
|
136
|
-
ch.create_call(
|
135
|
+
ch.create_call(nil, nil, 'dummy_method', nil, deadline)
|
137
136
|
end
|
138
137
|
expect(&blk).to raise_error(RuntimeError)
|
139
138
|
end
|
@@ -34,27 +34,23 @@ include GRPC::Core
|
|
34
34
|
shared_context 'setup: tags' do
|
35
35
|
let(:sent_message) { 'sent message' }
|
36
36
|
let(:reply_text) { 'the reply' }
|
37
|
-
before(:example) do
|
38
|
-
@client_tag = Object.new
|
39
|
-
@server_tag = Object.new
|
40
|
-
end
|
41
37
|
|
42
38
|
def deadline
|
43
39
|
Time.now + 5
|
44
40
|
end
|
45
41
|
|
46
|
-
def server_allows_client_to_proceed
|
47
|
-
recvd_rpc = @server.request_call
|
42
|
+
def server_allows_client_to_proceed(metadata = {})
|
43
|
+
recvd_rpc = @server.request_call
|
48
44
|
expect(recvd_rpc).to_not eq nil
|
49
45
|
server_call = recvd_rpc.call
|
50
|
-
ops = { CallOps::SEND_INITIAL_METADATA =>
|
51
|
-
svr_batch = server_call.run_batch(
|
46
|
+
ops = { CallOps::SEND_INITIAL_METADATA => metadata }
|
47
|
+
svr_batch = server_call.run_batch(ops)
|
52
48
|
expect(svr_batch.send_metadata).to be true
|
53
49
|
server_call
|
54
50
|
end
|
55
51
|
|
56
52
|
def new_client_call
|
57
|
-
@ch.create_call(
|
53
|
+
@ch.create_call(nil, nil, '/method', nil, deadline)
|
58
54
|
end
|
59
55
|
end
|
60
56
|
|
@@ -91,8 +87,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
91
87
|
CallOps::SEND_INITIAL_METADATA => {},
|
92
88
|
CallOps::SEND_MESSAGE => sent_message
|
93
89
|
}
|
94
|
-
batch_result = call.run_batch(
|
95
|
-
client_ops)
|
90
|
+
batch_result = call.run_batch(client_ops)
|
96
91
|
expect(batch_result.send_metadata).to be true
|
97
92
|
expect(batch_result.send_message).to be true
|
98
93
|
|
@@ -101,8 +96,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
101
96
|
server_ops = {
|
102
97
|
CallOps::RECV_MESSAGE => nil
|
103
98
|
}
|
104
|
-
svr_batch = server_call.run_batch(
|
105
|
-
server_ops)
|
99
|
+
svr_batch = server_call.run_batch(server_ops)
|
106
100
|
expect(svr_batch.message).to eq(sent_message)
|
107
101
|
end
|
108
102
|
|
@@ -118,8 +112,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
118
112
|
CallOps::SEND_INITIAL_METADATA => {},
|
119
113
|
CallOps::SEND_MESSAGE => sent_message
|
120
114
|
}
|
121
|
-
batch_result = call.run_batch(
|
122
|
-
client_ops)
|
115
|
+
batch_result = call.run_batch(client_ops)
|
123
116
|
expect(batch_result.send_metadata).to be true
|
124
117
|
expect(batch_result.send_message).to be true
|
125
118
|
|
@@ -129,12 +122,50 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
129
122
|
CallOps::RECV_MESSAGE => nil,
|
130
123
|
CallOps::SEND_MESSAGE => reply_text
|
131
124
|
}
|
132
|
-
svr_batch = server_call.run_batch(
|
133
|
-
server_ops)
|
125
|
+
svr_batch = server_call.run_batch(server_ops)
|
134
126
|
expect(svr_batch.message).to eq(sent_message)
|
135
127
|
expect(svr_batch.send_message).to be true
|
136
128
|
end
|
137
129
|
|
130
|
+
it 'compressed messages can be sent and received' do
|
131
|
+
call = new_client_call
|
132
|
+
server_call = nil
|
133
|
+
long_request_str = '0' * 2000
|
134
|
+
long_response_str = '1' * 2000
|
135
|
+
md = { 'grpc-internal-encoding-request' => 'gzip' }
|
136
|
+
|
137
|
+
server_thread = Thread.new do
|
138
|
+
server_call = server_allows_client_to_proceed(md)
|
139
|
+
end
|
140
|
+
|
141
|
+
client_ops = {
|
142
|
+
CallOps::SEND_INITIAL_METADATA => md,
|
143
|
+
CallOps::SEND_MESSAGE => long_request_str
|
144
|
+
}
|
145
|
+
batch_result = call.run_batch(client_ops)
|
146
|
+
expect(batch_result.send_metadata).to be true
|
147
|
+
expect(batch_result.send_message).to be true
|
148
|
+
|
149
|
+
# confirm the server can read the inbound message
|
150
|
+
server_thread.join
|
151
|
+
server_ops = {
|
152
|
+
CallOps::RECV_MESSAGE => nil,
|
153
|
+
CallOps::SEND_MESSAGE => long_response_str
|
154
|
+
}
|
155
|
+
svr_batch = server_call.run_batch(server_ops)
|
156
|
+
expect(svr_batch.message).to eq(long_request_str)
|
157
|
+
expect(svr_batch.send_message).to be true
|
158
|
+
|
159
|
+
client_ops = {
|
160
|
+
CallOps::SEND_CLOSE_FROM_CLIENT => nil,
|
161
|
+
CallOps::RECV_INITIAL_METADATA => nil,
|
162
|
+
CallOps::RECV_MESSAGE => nil
|
163
|
+
}
|
164
|
+
batch_result = call.run_batch(client_ops)
|
165
|
+
expect(batch_result.send_close).to be true
|
166
|
+
expect(batch_result.message).to eq long_response_str
|
167
|
+
end
|
168
|
+
|
138
169
|
it 'servers can ignore a client write and send a status' do
|
139
170
|
call = new_client_call
|
140
171
|
server_call = nil
|
@@ -147,8 +178,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
147
178
|
CallOps::SEND_INITIAL_METADATA => {},
|
148
179
|
CallOps::SEND_MESSAGE => sent_message
|
149
180
|
}
|
150
|
-
batch_result = call.run_batch(
|
151
|
-
client_ops)
|
181
|
+
batch_result = call.run_batch(client_ops)
|
152
182
|
expect(batch_result.send_metadata).to be true
|
153
183
|
expect(batch_result.send_message).to be true
|
154
184
|
|
@@ -158,8 +188,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
158
188
|
server_ops = {
|
159
189
|
CallOps::SEND_STATUS_FROM_SERVER => the_status
|
160
190
|
}
|
161
|
-
svr_batch = server_call.run_batch(
|
162
|
-
server_ops)
|
191
|
+
svr_batch = server_call.run_batch(server_ops)
|
163
192
|
expect(svr_batch.message).to eq nil
|
164
193
|
expect(svr_batch.send_status).to be true
|
165
194
|
end
|
@@ -176,8 +205,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
176
205
|
CallOps::SEND_INITIAL_METADATA => {},
|
177
206
|
CallOps::SEND_MESSAGE => sent_message
|
178
207
|
}
|
179
|
-
batch_result = call.run_batch(
|
180
|
-
client_ops)
|
208
|
+
batch_result = call.run_batch(client_ops)
|
181
209
|
expect(batch_result.send_metadata).to be true
|
182
210
|
expect(batch_result.send_message).to be true
|
183
211
|
|
@@ -189,8 +217,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
189
217
|
CallOps::SEND_MESSAGE => reply_text,
|
190
218
|
CallOps::SEND_STATUS_FROM_SERVER => the_status
|
191
219
|
}
|
192
|
-
svr_batch = server_call.run_batch(
|
193
|
-
server_ops)
|
220
|
+
svr_batch = server_call.run_batch(server_ops)
|
194
221
|
expect(svr_batch.message).to eq sent_message
|
195
222
|
expect(svr_batch.send_status).to be true
|
196
223
|
expect(svr_batch.send_message).to be true
|
@@ -202,8 +229,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
202
229
|
CallOps::RECV_MESSAGE => nil,
|
203
230
|
CallOps::RECV_STATUS_ON_CLIENT => nil
|
204
231
|
}
|
205
|
-
batch_result = call.run_batch(
|
206
|
-
client_ops)
|
232
|
+
batch_result = call.run_batch(client_ops)
|
207
233
|
expect(batch_result.send_close).to be true
|
208
234
|
expect(batch_result.message).to eq reply_text
|
209
235
|
expect(batch_result.status).to eq the_status
|
@@ -212,8 +238,7 @@ shared_examples 'basic GRPC message delivery is OK' do
|
|
212
238
|
server_ops = {
|
213
239
|
CallOps::RECV_CLOSE_ON_SERVER => nil
|
214
240
|
}
|
215
|
-
svr_batch = server_call.run_batch(
|
216
|
-
server_ops)
|
241
|
+
svr_batch = server_call.run_batch(server_ops)
|
217
242
|
expect(svr_batch.send_close).to be true
|
218
243
|
end
|
219
244
|
end
|
@@ -244,8 +269,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
244
269
|
CallOps::SEND_INITIAL_METADATA => md
|
245
270
|
}
|
246
271
|
blk = proc do
|
247
|
-
call.run_batch(
|
248
|
-
client_ops)
|
272
|
+
call.run_batch(client_ops)
|
249
273
|
end
|
250
274
|
expect(&blk).to raise_error
|
251
275
|
end
|
@@ -255,15 +279,14 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
255
279
|
@valid_metadata.each do |md|
|
256
280
|
recvd_rpc = nil
|
257
281
|
rcv_thread = Thread.new do
|
258
|
-
recvd_rpc = @server.request_call
|
282
|
+
recvd_rpc = @server.request_call
|
259
283
|
end
|
260
284
|
|
261
285
|
call = new_client_call
|
262
286
|
client_ops = {
|
263
287
|
CallOps::SEND_INITIAL_METADATA => md
|
264
288
|
}
|
265
|
-
batch_result = call.run_batch(
|
266
|
-
client_ops)
|
289
|
+
batch_result = call.run_batch(client_ops)
|
267
290
|
expect(batch_result.send_metadata).to be true
|
268
291
|
|
269
292
|
# confirm the server can receive the client metadata
|
@@ -296,7 +319,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
296
319
|
@bad_keys.each do |md|
|
297
320
|
recvd_rpc = nil
|
298
321
|
rcv_thread = Thread.new do
|
299
|
-
recvd_rpc = @server.request_call
|
322
|
+
recvd_rpc = @server.request_call
|
300
323
|
end
|
301
324
|
|
302
325
|
call = new_client_call
|
@@ -305,7 +328,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
305
328
|
client_ops = {
|
306
329
|
CallOps::SEND_INITIAL_METADATA => nil
|
307
330
|
}
|
308
|
-
call.run_batch(
|
331
|
+
call.run_batch(client_ops)
|
309
332
|
|
310
333
|
# server gets the invocation
|
311
334
|
rcv_thread.join
|
@@ -314,8 +337,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
314
337
|
CallOps::SEND_INITIAL_METADATA => md
|
315
338
|
}
|
316
339
|
blk = proc do
|
317
|
-
recvd_rpc.call.run_batch(
|
318
|
-
server_ops)
|
340
|
+
recvd_rpc.call.run_batch(server_ops)
|
319
341
|
end
|
320
342
|
expect(&blk).to raise_error
|
321
343
|
end
|
@@ -324,7 +346,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
324
346
|
it 'sends an empty hash if no metadata is added' do
|
325
347
|
recvd_rpc = nil
|
326
348
|
rcv_thread = Thread.new do
|
327
|
-
recvd_rpc = @server.request_call
|
349
|
+
recvd_rpc = @server.request_call
|
328
350
|
end
|
329
351
|
|
330
352
|
call = new_client_call
|
@@ -333,7 +355,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
333
355
|
client_ops = {
|
334
356
|
CallOps::SEND_INITIAL_METADATA => nil
|
335
357
|
}
|
336
|
-
call.run_batch(
|
358
|
+
call.run_batch(client_ops)
|
337
359
|
|
338
360
|
# server gets the invocation but sends no metadata back
|
339
361
|
rcv_thread.join
|
@@ -342,14 +364,13 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
342
364
|
server_ops = {
|
343
365
|
CallOps::SEND_INITIAL_METADATA => nil
|
344
366
|
}
|
345
|
-
server_call.run_batch(
|
367
|
+
server_call.run_batch(server_ops)
|
346
368
|
|
347
369
|
# client receives nothing as expected
|
348
370
|
client_ops = {
|
349
371
|
CallOps::RECV_INITIAL_METADATA => nil
|
350
372
|
}
|
351
|
-
batch_result = call.run_batch(
|
352
|
-
client_ops)
|
373
|
+
batch_result = call.run_batch(client_ops)
|
353
374
|
expect(batch_result.metadata).to eq({})
|
354
375
|
end
|
355
376
|
|
@@ -357,7 +378,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
357
378
|
@valid_metadata.each do |md|
|
358
379
|
recvd_rpc = nil
|
359
380
|
rcv_thread = Thread.new do
|
360
|
-
recvd_rpc = @server.request_call
|
381
|
+
recvd_rpc = @server.request_call
|
361
382
|
end
|
362
383
|
|
363
384
|
call = new_client_call
|
@@ -366,7 +387,7 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
366
387
|
client_ops = {
|
367
388
|
CallOps::SEND_INITIAL_METADATA => nil
|
368
389
|
}
|
369
|
-
call.run_batch(
|
390
|
+
call.run_batch(client_ops)
|
370
391
|
|
371
392
|
# server gets the invocation but sends no metadata back
|
372
393
|
rcv_thread.join
|
@@ -375,14 +396,13 @@ shared_examples 'GRPC metadata delivery works OK' do
|
|
375
396
|
server_ops = {
|
376
397
|
CallOps::SEND_INITIAL_METADATA => md
|
377
398
|
}
|
378
|
-
server_call.run_batch(
|
399
|
+
server_call.run_batch(server_ops)
|
379
400
|
|
380
401
|
# client receives nothing as expected
|
381
402
|
client_ops = {
|
382
403
|
CallOps::RECV_INITIAL_METADATA => nil
|
383
404
|
}
|
384
|
-
batch_result = call.run_batch(
|
385
|
-
client_ops)
|
405
|
+
batch_result = call.run_batch(client_ops)
|
386
406
|
replace_symbols = Hash[md.each_pair.collect { |x, y| [x.to_s, y] }]
|
387
407
|
expect(batch_result.metadata).to eq(replace_symbols)
|
388
408
|
end
|
@@ -393,9 +413,7 @@ end
|
|
393
413
|
describe 'the http client/server' do
|
394
414
|
before(:example) do
|
395
415
|
server_host = '0.0.0.0:0'
|
396
|
-
@
|
397
|
-
@server_queue = GRPC::Core::CompletionQueue.new
|
398
|
-
@server = GRPC::Core::Server.new(@server_queue, nil)
|
416
|
+
@server = GRPC::Core::Server.new(nil)
|
399
417
|
server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
|
400
418
|
@server.start
|
401
419
|
@ch = Channel.new("0.0.0.0:#{server_port}", nil, :this_channel_is_insecure)
|
@@ -403,7 +421,7 @@ describe 'the http client/server' do
|
|
403
421
|
|
404
422
|
after(:example) do
|
405
423
|
@ch.close
|
406
|
-
@server.close(
|
424
|
+
@server.close(deadline)
|
407
425
|
end
|
408
426
|
|
409
427
|
it_behaves_like 'basic GRPC message delivery is OK' do
|
@@ -425,11 +443,9 @@ describe 'the secure http client/server' do
|
|
425
443
|
before(:example) do
|
426
444
|
certs = load_test_certs
|
427
445
|
server_host = '0.0.0.0:0'
|
428
|
-
@client_queue = GRPC::Core::CompletionQueue.new
|
429
|
-
@server_queue = GRPC::Core::CompletionQueue.new
|
430
446
|
server_creds = GRPC::Core::ServerCredentials.new(
|
431
447
|
nil, [{ private_key: certs[1], cert_chain: certs[2] }], false)
|
432
|
-
@server = GRPC::Core::Server.new(
|
448
|
+
@server = GRPC::Core::Server.new(nil)
|
433
449
|
server_port = @server.add_http2_port(server_host, server_creds)
|
434
450
|
@server.start
|
435
451
|
args = { Channel::SSL_TARGET => 'foo.test.google.fr' }
|
@@ -438,7 +454,7 @@ describe 'the secure http client/server' do
|
|
438
454
|
end
|
439
455
|
|
440
456
|
after(:example) do
|
441
|
-
@server.close(
|
457
|
+
@server.close(deadline)
|
442
458
|
end
|
443
459
|
|
444
460
|
it_behaves_like 'basic GRPC message delivery is OK' do
|
@@ -454,7 +470,7 @@ describe 'the secure http client/server' do
|
|
454
470
|
expected_md = { 'k1' => 'updated-v1', 'k2' => 'v2' }
|
455
471
|
recvd_rpc = nil
|
456
472
|
rcv_thread = Thread.new do
|
457
|
-
recvd_rpc = @server.request_call
|
473
|
+
recvd_rpc = @server.request_call
|
458
474
|
end
|
459
475
|
|
460
476
|
call = new_client_call
|
@@ -462,8 +478,7 @@ describe 'the secure http client/server' do
|
|
462
478
|
client_ops = {
|
463
479
|
CallOps::SEND_INITIAL_METADATA => md
|
464
480
|
}
|
465
|
-
batch_result = call.run_batch(
|
466
|
-
client_ops)
|
481
|
+
batch_result = call.run_batch(client_ops)
|
467
482
|
expect(batch_result.send_metadata).to be true
|
468
483
|
|
469
484
|
# confirm the server can receive the client metadata
|