grpc 1.66.0-x86_64-linux → 1.67.0.pre1-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -55,17 +55,20 @@ describe GRPC::ActiveCall do
55
55
  end
56
56
  @ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
57
57
  :this_channel_is_insecure)
58
+ @call = make_test_call
58
59
  end
59
60
 
60
61
  after(:each) do
61
62
  @server.shutdown_and_notify(deadline)
62
63
  @server.close
63
64
  @server_thread.join
65
+ # Don't rely on GC to unref the call, since that can prevent
66
+ # the channel connectivity state polling thread from shutting down.
67
+ @call.close
64
68
  end
65
69
 
66
70
  describe 'restricted view methods' do
67
71
  before(:each) do
68
- @call = make_test_call
69
72
  ActiveCall.client_invoke(@call)
70
73
  @client_call = ActiveCall.new(@call, @pass_through,
71
74
  @pass_through, deadline)
@@ -117,9 +120,8 @@ describe GRPC::ActiveCall do
117
120
 
118
121
  describe '#remote_send' do
119
122
  it 'allows a client to send a payload to the server', test: true do
120
- call = make_test_call
121
- ActiveCall.client_invoke(call)
122
- client_call = ActiveCall.new(call, @pass_through,
123
+ ActiveCall.client_invoke(@call)
124
+ client_call = ActiveCall.new(@call, @pass_through,
123
125
  @pass_through, deadline)
124
126
  msg = 'message is a string'
125
127
  client_call.remote_send(msg)
@@ -137,15 +139,14 @@ describe GRPC::ActiveCall do
137
139
  expect(server_call.remote_read).to eq(msg)
138
140
  # finish the call
139
141
  server_call.send_initial_metadata
140
- call.run_batch(CallOps::RECV_INITIAL_METADATA => nil)
141
- send_and_receive_close_and_status(call, recvd_call)
142
+ @call.run_batch(CallOps::RECV_INITIAL_METADATA => nil)
143
+ send_and_receive_close_and_status(@call, recvd_call)
142
144
  end
143
145
 
144
146
  it 'marshals the payload using the marshal func' do
145
- call = make_test_call
146
- ActiveCall.client_invoke(call)
147
+ ActiveCall.client_invoke(@call)
147
148
  marshal = proc { |x| 'marshalled:' + x }
148
- client_call = ActiveCall.new(call, marshal, @pass_through, deadline)
149
+ client_call = ActiveCall.new(@call, marshal, @pass_through, deadline)
149
150
  msg = 'message is a string'
150
151
  client_call.remote_send(msg)
151
152
 
@@ -161,23 +162,22 @@ describe GRPC::ActiveCall do
161
162
  metadata_received: true)
162
163
  expect(server_call.remote_read).to eq('marshalled:' + msg)
163
164
  # finish the call
164
- call.run_batch(CallOps::RECV_INITIAL_METADATA => nil)
165
- send_and_receive_close_and_status(call, recvd_call)
165
+ @call.run_batch(CallOps::RECV_INITIAL_METADATA => nil)
166
+ send_and_receive_close_and_status(@call, recvd_call)
166
167
  end
167
168
 
168
169
  TEST_WRITE_FLAGS = [WriteFlags::BUFFER_HINT, WriteFlags::NO_COMPRESS]
169
170
  TEST_WRITE_FLAGS.each do |f|
170
171
  it "successfully makes calls with write_flag set to #{f}" do
171
- call = make_test_call
172
- ActiveCall.client_invoke(call)
172
+ ActiveCall.client_invoke(@call)
173
173
  marshal = proc { |x| 'marshalled:' + x }
174
- client_call = ActiveCall.new(call, marshal,
174
+ client_call = ActiveCall.new(@call, marshal,
175
175
  @pass_through, deadline)
176
176
  msg = 'message is a string'
177
177
  client_call.write_flag = f
178
178
  client_call.remote_send(msg)
179
179
  # flush the message in case writes are set to buffered
180
- call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil) if f == 1
180
+ @call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil) if f == 1
181
181
 
182
182
  # confirm that the message was marshalled
183
183
  recvd_rpc = @received_rpcs_queue.pop
@@ -199,9 +199,8 @@ describe GRPC::ActiveCall do
199
199
 
200
200
  describe 'sending initial metadata', send_initial_metadata: true do
201
201
  it 'sends metadata before sending a message if it hasnt been sent yet' do
202
- call = make_test_call
203
202
  @client_call = ActiveCall.new(
204
- call,
203
+ @call,
205
204
  @pass_through,
206
205
  @pass_through,
207
206
  deadline,
@@ -213,13 +212,13 @@ describe GRPC::ActiveCall do
213
212
 
214
213
  message = 'phony message'
215
214
 
216
- expect(call).to(
215
+ expect(@call).to(
217
216
  receive(:run_batch)
218
217
  .with(
219
218
  hash_including(
220
219
  CallOps::SEND_INITIAL_METADATA => metadata)).once)
221
220
 
222
- expect(call).to(
221
+ expect(@call).to(
223
222
  receive(:run_batch).with(hash_including(
224
223
  CallOps::SEND_MESSAGE => message)).once)
225
224
  @client_call.remote_send(message)
@@ -228,14 +227,12 @@ describe GRPC::ActiveCall do
228
227
  end
229
228
 
230
229
  it 'doesnt send metadata if it thinks its already been sent' do
231
- call = make_test_call
232
-
233
- @client_call = ActiveCall.new(call,
230
+ @client_call = ActiveCall.new(@call,
234
231
  @pass_through,
235
232
  @pass_through,
236
233
  deadline)
237
234
  expect(@client_call.metadata_sent).to eql(true)
238
- expect(call).to(
235
+ expect(@call).to(
239
236
  receive(:run_batch).with(hash_including(
240
237
  CallOps::SEND_INITIAL_METADATA)).never)
241
238
 
@@ -243,9 +240,7 @@ describe GRPC::ActiveCall do
243
240
  end
244
241
 
245
242
  it 'sends metadata if it is explicitly sent and ok to do so' do
246
- call = make_test_call
247
-
248
- @client_call = ActiveCall.new(call,
243
+ @client_call = ActiveCall.new(@call,
249
244
  @pass_through,
250
245
  @pass_through,
251
246
  deadline,
@@ -257,7 +252,7 @@ describe GRPC::ActiveCall do
257
252
  @client_call.merge_metadata_to_send(metadata)
258
253
  expect(@client_call.metadata_to_send).to eq(metadata)
259
254
 
260
- expect(call).to(
255
+ expect(@call).to(
261
256
  receive(:run_batch).with(hash_including(
262
257
  CallOps::SEND_INITIAL_METADATA =>
263
258
  metadata)).once)
@@ -265,9 +260,7 @@ describe GRPC::ActiveCall do
265
260
  end
266
261
 
267
262
  it 'explicit sending does nothing if metadata has already been sent' do
268
- call = make_test_call
269
-
270
- @client_call = ActiveCall.new(call,
263
+ @client_call = ActiveCall.new(@call,
271
264
  @pass_through,
272
265
  @pass_through,
273
266
  deadline)
@@ -284,7 +277,6 @@ describe GRPC::ActiveCall do
284
277
 
285
278
  describe '#merge_metadata_to_send', merge_metadata_to_send: true do
286
279
  it 'adds to existing metadata when there is existing metadata to send' do
287
- call = make_test_call
288
280
  starting_metadata = {
289
281
  k1: 'key1_val',
290
282
  k2: 'key2_val',
@@ -292,7 +284,7 @@ describe GRPC::ActiveCall do
292
284
  }
293
285
 
294
286
  @client_call = ActiveCall.new(
295
- call,
287
+ @call,
296
288
  @pass_through, @pass_through,
297
289
  deadline,
298
290
  started: false,
@@ -318,9 +310,8 @@ describe GRPC::ActiveCall do
318
310
  end
319
311
 
320
312
  it 'fails when initial metadata has already been sent' do
321
- call = make_test_call
322
313
  @client_call = ActiveCall.new(
323
- call,
314
+ @call,
324
315
  @pass_through,
325
316
  @pass_through,
326
317
  deadline,
@@ -338,9 +329,8 @@ describe GRPC::ActiveCall do
338
329
 
339
330
  describe '#client_invoke' do
340
331
  it 'sends metadata to the server when present' do
341
- call = make_test_call
342
332
  metadata = { k1: 'v1', k2: 'v2' }
343
- ActiveCall.client_invoke(call, metadata)
333
+ ActiveCall.client_invoke(@call, metadata)
344
334
  recvd_rpc = @received_rpcs_queue.pop
345
335
  recvd_call = recvd_rpc.call
346
336
  expect(recvd_call).to_not be_nil
@@ -349,15 +339,14 @@ describe GRPC::ActiveCall do
349
339
  expect(recvd_rpc.metadata['k2']).to eq('v2')
350
340
  # finish the call
351
341
  recvd_call.run_batch(CallOps::SEND_INITIAL_METADATA => {})
352
- call.run_batch(CallOps::RECV_INITIAL_METADATA => nil)
353
- send_and_receive_close_and_status(call, recvd_call)
342
+ @call.run_batch(CallOps::RECV_INITIAL_METADATA => nil)
343
+ send_and_receive_close_and_status(@call, recvd_call)
354
344
  end
355
345
  end
356
346
 
357
347
  describe '#send_status', send_status: true do
358
348
  it 'works when no metadata or messages have been sent yet' do
359
- call = make_test_call
360
- ActiveCall.client_invoke(call)
349
+ ActiveCall.client_invoke(@call)
361
350
 
362
351
  recvd_rpc = @received_rpcs_queue.pop
363
352
  server_call = ActiveCall.new(
@@ -375,9 +364,8 @@ describe GRPC::ActiveCall do
375
364
 
376
365
  describe '#remote_read', remote_read: true do
377
366
  it 'reads the response sent by a server' do
378
- call = make_test_call
379
- ActiveCall.client_invoke(call)
380
- client_call = ActiveCall.new(call, @pass_through,
367
+ ActiveCall.client_invoke(@call)
368
+ client_call = ActiveCall.new(@call, @pass_through,
381
369
  @pass_through, deadline)
382
370
  msg = 'message is a string'
383
371
  client_call.remote_send(msg)
@@ -385,13 +373,12 @@ describe GRPC::ActiveCall do
385
373
  server_call.remote_send('server_response')
386
374
  expect(client_call.remote_read).to eq('server_response')
387
375
  send_and_receive_close_and_status(
388
- call, inner_call_of_active_call(server_call))
376
+ @call, inner_call_of_active_call(server_call))
389
377
  end
390
378
 
391
379
  it 'saves no metadata when the server adds no metadata' do
392
- call = make_test_call
393
- ActiveCall.client_invoke(call)
394
- client_call = ActiveCall.new(call, @pass_through,
380
+ ActiveCall.client_invoke(@call)
381
+ client_call = ActiveCall.new(@call, @pass_through,
395
382
  @pass_through, deadline)
396
383
  msg = 'message is a string'
397
384
  client_call.remote_send(msg)
@@ -401,13 +388,12 @@ describe GRPC::ActiveCall do
401
388
  client_call.remote_read
402
389
  expect(client_call.metadata).to eq({})
403
390
  send_and_receive_close_and_status(
404
- call, inner_call_of_active_call(server_call))
391
+ @call, inner_call_of_active_call(server_call))
405
392
  end
406
393
 
407
394
  it 'saves metadata add by the server' do
408
- call = make_test_call
409
- ActiveCall.client_invoke(call)
410
- client_call = ActiveCall.new(call, @pass_through,
395
+ ActiveCall.client_invoke(@call)
396
+ client_call = ActiveCall.new(@call, @pass_through,
411
397
  @pass_through, deadline)
412
398
  msg = 'message is a string'
413
399
  client_call.remote_send(msg)
@@ -418,12 +404,11 @@ describe GRPC::ActiveCall do
418
404
  expected = { 'k1' => 'v1', 'k2' => 'v2' }
419
405
  expect(client_call.metadata).to eq(expected)
420
406
  send_and_receive_close_and_status(
421
- call, inner_call_of_active_call(server_call))
407
+ @call, inner_call_of_active_call(server_call))
422
408
  end
423
409
 
424
410
  it 'get a status from server when nothing else sent from server' do
425
- client_call = make_test_call
426
- ActiveCall.client_invoke(client_call)
411
+ ActiveCall.client_invoke(@call)
427
412
 
428
413
  recvd_rpc = @received_rpcs_queue.pop
429
414
  recvd_call = recvd_rpc.call
@@ -438,22 +423,21 @@ describe GRPC::ActiveCall do
438
423
  server_call.send_status(OK, 'OK')
439
424
 
440
425
  # Check that we can receive initial metadata and a status
441
- client_call.run_batch(
426
+ @call.run_batch(
442
427
  CallOps::RECV_INITIAL_METADATA => nil)
443
- batch_result = client_call.run_batch(
428
+ batch_result = @call.run_batch(
444
429
  CallOps::RECV_STATUS_ON_CLIENT => nil)
445
430
 
446
431
  expect(batch_result.status.code).to eq(OK)
447
432
  end
448
433
 
449
434
  it 'get a nil msg before a status when an OK status is sent' do
450
- call = make_test_call
451
- ActiveCall.client_invoke(call)
452
- client_call = ActiveCall.new(call, @pass_through,
435
+ ActiveCall.client_invoke(@call)
436
+ client_call = ActiveCall.new(@call, @pass_through,
453
437
  @pass_through, deadline)
454
438
  msg = 'message is a string'
455
439
  client_call.remote_send(msg)
456
- call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
440
+ @call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
457
441
  server_call = expect_server_to_receive(msg)
458
442
  server_call.remote_send('server_response')
459
443
  server_call.send_status(OK, 'OK')
@@ -463,10 +447,9 @@ describe GRPC::ActiveCall do
463
447
  end
464
448
 
465
449
  it 'unmarshals the response using the unmarshal func' do
466
- call = make_test_call
467
- ActiveCall.client_invoke(call)
450
+ ActiveCall.client_invoke(@call)
468
451
  unmarshal = proc { |x| 'unmarshalled:' + x }
469
- client_call = ActiveCall.new(call, @pass_through,
452
+ client_call = ActiveCall.new(@call, @pass_through,
470
453
  unmarshal, deadline)
471
454
 
472
455
  # confirm the client receives the unmarshalled message
@@ -476,14 +459,13 @@ describe GRPC::ActiveCall do
476
459
  server_call.remote_send('server_response')
477
460
  expect(client_call.remote_read).to eq('unmarshalled:server_response')
478
461
  send_and_receive_close_and_status(
479
- call, inner_call_of_active_call(server_call))
462
+ @call, inner_call_of_active_call(server_call))
480
463
  end
481
464
  end
482
465
 
483
466
  describe '#each_remote_read' do
484
467
  it 'creates an Enumerator' do
485
- call = make_test_call
486
- client_call = ActiveCall.new(call, @pass_through,
468
+ client_call = ActiveCall.new(@call, @pass_through,
487
469
  @pass_through, deadline)
488
470
  expect(client_call.each_remote_read).to be_a(Enumerator)
489
471
  # finish the call
@@ -491,9 +473,8 @@ describe GRPC::ActiveCall do
491
473
  end
492
474
 
493
475
  it 'the returned enumerator can read n responses' do
494
- call = make_test_call
495
- ActiveCall.client_invoke(call)
496
- client_call = ActiveCall.new(call, @pass_through,
476
+ ActiveCall.client_invoke(@call)
477
+ client_call = ActiveCall.new(@call, @pass_through,
497
478
  @pass_through, deadline)
498
479
  msg = 'message is a string'
499
480
  reply = 'server_response'
@@ -506,18 +487,17 @@ describe GRPC::ActiveCall do
506
487
  expect(e.next).to eq(reply)
507
488
  end
508
489
  send_and_receive_close_and_status(
509
- call, inner_call_of_active_call(server_call))
490
+ @call, inner_call_of_active_call(server_call))
510
491
  end
511
492
 
512
493
  it 'the returns an enumerator that stops after an OK Status' do
513
- call = make_test_call
514
- ActiveCall.client_invoke(call)
515
- client_call = ActiveCall.new(call, @pass_through,
494
+ ActiveCall.client_invoke(@call)
495
+ client_call = ActiveCall.new(@call, @pass_through,
516
496
  @pass_through, deadline)
517
497
  msg = 'message is a string'
518
498
  reply = 'server_response'
519
499
  client_call.remote_send(msg)
520
- call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
500
+ @call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
521
501
  server_call = expect_server_to_receive(msg)
522
502
  e = client_call.each_remote_read
523
503
  n = 3 # arbitrary value > 1
@@ -532,14 +512,13 @@ describe GRPC::ActiveCall do
532
512
 
533
513
  describe '#closing the call from the client' do
534
514
  it 'finishes ok if the server sends a status response' do
535
- call = make_test_call
536
- ActiveCall.client_invoke(call)
537
- client_call = ActiveCall.new(call, @pass_through,
515
+ ActiveCall.client_invoke(@call)
516
+ client_call = ActiveCall.new(@call, @pass_through,
538
517
  @pass_through, deadline)
539
518
  msg = 'message is a string'
540
519
  client_call.remote_send(msg)
541
520
  expect do
542
- call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
521
+ @call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
543
522
  end.to_not raise_error
544
523
  server_call = expect_server_to_receive(msg)
545
524
  server_call.remote_send('server_response')
@@ -549,9 +528,8 @@ describe GRPC::ActiveCall do
549
528
  end
550
529
 
551
530
  it 'finishes ok if the server sends an early status response' do
552
- call = make_test_call
553
- ActiveCall.client_invoke(call)
554
- client_call = ActiveCall.new(call, @pass_through,
531
+ ActiveCall.client_invoke(@call)
532
+ client_call = ActiveCall.new(@call, @pass_through,
555
533
  @pass_through, deadline)
556
534
  msg = 'message is a string'
557
535
  client_call.remote_send(msg)
@@ -560,15 +538,14 @@ describe GRPC::ActiveCall do
560
538
  server_call.send_status(OK, 'status code is OK')
561
539
  expect(client_call.remote_read).to eq('server_response')
562
540
  expect do
563
- call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
541
+ @call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil)
564
542
  end.to_not raise_error
565
543
  expect { client_call.receive_and_check_status }.to_not raise_error
566
544
  end
567
545
 
568
546
  it 'finishes ok if SEND_CLOSE and RECV_STATUS has been sent' do
569
- call = make_test_call
570
- ActiveCall.client_invoke(call)
571
- client_call = ActiveCall.new(call, @pass_through,
547
+ ActiveCall.client_invoke(@call)
548
+ client_call = ActiveCall.new(@call, @pass_through,
572
549
  @pass_through, deadline)
573
550
  msg = 'message is a string'
574
551
  client_call.remote_send(msg)
@@ -577,7 +554,7 @@ describe GRPC::ActiveCall do
577
554
  server_call.send_status(OK, 'status code is OK')
578
555
  expect(client_call.remote_read).to eq('server_response')
579
556
  expect do
580
- call.run_batch(
557
+ @call.run_batch(
581
558
  CallOps::SEND_CLOSE_FROM_CLIENT => nil,
582
559
  CallOps::RECV_STATUS_ON_CLIENT => nil)
583
560
  end.to_not raise_error
@@ -631,6 +608,7 @@ describe GRPC::ActiveCall do
631
608
  batch_result = @client_call.run_batch(
632
609
  CallOps::RECV_STATUS_ON_CLIENT => nil)
633
610
  expect(batch_result.status.code).to eq(@server_status)
611
+ @client_call.close
634
612
  end
635
613
 
636
614
  it 'sends the initial metadata implicitly if not already sent' do
@@ -41,14 +41,17 @@ class EchoService
41
41
  rpc :a_bidi_rpc, stream(EchoMsg), stream(EchoMsg)
42
42
  rpc :a_client_streaming_rpc_unimplemented, stream(EchoMsg), EchoMsg
43
43
  attr_reader :received_md
44
+ attr_accessor :on_call_started
44
45
 
45
46
  def initialize(**kw)
46
47
  @trailing_metadata = kw
47
48
  @received_md = []
49
+ @on_call_started = nil
48
50
  end
49
51
 
50
52
  def an_rpc(req, call)
51
53
  GRPC.logger.info('echo service received a request')
54
+ on_call_started&.call(call)
52
55
  call.output_metadata.update(@trailing_metadata)
53
56
  @received_md << call.metadata unless call.metadata.nil?
54
57
  req
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.66.0
4
+ version: 1.67.0.pre1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - gRPC Authors
8
8
  autorequire:
9
9
  bindir: src/ruby/bin
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -359,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
359
  - !ruby/object:Gem::Version
360
360
  version: '0'
361
361
  requirements: []
362
- rubygems_version: 3.5.17
362
+ rubygems_version: 3.5.18
363
363
  signing_key:
364
364
  specification_version: 4
365
365
  summary: GRPC system in Ruby