grpc 1.4.1 → 1.4.5
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 +2 -2
- data/src/ruby/ext/grpc/rb_call.c +23 -10
- data/src/ruby/ext/grpc/rb_call.h +3 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +6 -1
- data/src/ruby/ext/grpc/rb_channel_credentials.c +6 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +137 -33
- data/src/ruby/lib/grpc/generic/bidi_call.rb +28 -34
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +2 -2
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/client_auth_spec.rb +152 -0
- data/src/ruby/spec/client_server_spec.rb +29 -5
- data/src/ruby/spec/generic/active_call_spec.rb +2 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +313 -70
- data/src/ruby/spec/generic/rpc_desc_spec.rb +5 -5
- data/src/ruby/spec/generic/rpc_server_spec.rb +145 -0
- data/src/ruby/spec/testdata/client.key +16 -0
- data/src/ruby/spec/testdata/client.pem +14 -0
- metadata +8 -2
@@ -53,14 +53,14 @@ describe GRPC::RpcDesc do
|
|
53
53
|
|
54
54
|
shared_examples 'it handles errors' do
|
55
55
|
it 'sends the specified status if BadStatus is raised' do
|
56
|
-
expect(@call).to receive(:
|
56
|
+
expect(@call).to receive(:read_unary_request).once.and_return(Object.new)
|
57
57
|
expect(@call).to receive(:send_status).once.with(@bs_code, 'NOK', false,
|
58
58
|
metadata: {})
|
59
59
|
this_desc.run_server_method(@call, method(:bad_status))
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'sends status UNKNOWN if other StandardErrors are raised' do
|
63
|
-
expect(@call).to receive(:
|
63
|
+
expect(@call).to receive(:read_unary_request).once.and_return(Object.new)
|
64
64
|
expect(@call).to receive(:send_status).once.with(UNKNOWN,
|
65
65
|
arg_error_msg,
|
66
66
|
false, metadata: {})
|
@@ -68,7 +68,7 @@ describe GRPC::RpcDesc do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'absorbs CallError with no further action' do
|
71
|
-
expect(@call).to receive(:
|
71
|
+
expect(@call).to receive(:read_unary_request).once.and_raise(CallError)
|
72
72
|
blk = proc do
|
73
73
|
this_desc.run_server_method(@call, method(:fake_reqresp))
|
74
74
|
end
|
@@ -90,7 +90,7 @@ describe GRPC::RpcDesc do
|
|
90
90
|
|
91
91
|
it 'sends a response and closes the stream if there no errors' do
|
92
92
|
req = Object.new
|
93
|
-
expect(@call).to receive(:
|
93
|
+
expect(@call).to receive(:read_unary_request).once.and_return(req)
|
94
94
|
expect(@call).to receive(:output_metadata).once.and_return(fake_md)
|
95
95
|
expect(@call).to receive(:server_unary_response).once
|
96
96
|
.with(@ok_response, trailing_metadata: fake_md)
|
@@ -148,7 +148,7 @@ describe GRPC::RpcDesc do
|
|
148
148
|
|
149
149
|
it 'sends a response and closes the stream if there no errors' do
|
150
150
|
req = Object.new
|
151
|
-
expect(@call).to receive(:
|
151
|
+
expect(@call).to receive(:read_unary_request).once.and_return(req)
|
152
152
|
expect(@call).to receive(:remote_send).twice.with(@ok_response)
|
153
153
|
expect(@call).to receive(:output_metadata).and_return(fake_md)
|
154
154
|
expect(@call).to receive(:send_status).once.with(OK, 'OK', true,
|
@@ -126,6 +126,47 @@ end
|
|
126
126
|
|
127
127
|
SlowStub = SlowService.rpc_stub_class
|
128
128
|
|
129
|
+
# a test service that hangs onto call objects
|
130
|
+
# and uses them after the server-side call has been
|
131
|
+
# finished
|
132
|
+
class CheckCallAfterFinishedService
|
133
|
+
include GRPC::GenericService
|
134
|
+
rpc :an_rpc, EchoMsg, EchoMsg
|
135
|
+
rpc :a_client_streaming_rpc, stream(EchoMsg), EchoMsg
|
136
|
+
rpc :a_server_streaming_rpc, EchoMsg, stream(EchoMsg)
|
137
|
+
rpc :a_bidi_rpc, stream(EchoMsg), stream(EchoMsg)
|
138
|
+
attr_reader :server_side_call
|
139
|
+
|
140
|
+
def an_rpc(req, call)
|
141
|
+
fail 'shouldnt reuse service' unless @server_side_call.nil?
|
142
|
+
@server_side_call = call
|
143
|
+
req
|
144
|
+
end
|
145
|
+
|
146
|
+
def a_client_streaming_rpc(call)
|
147
|
+
fail 'shouldnt reuse service' unless @server_side_call.nil?
|
148
|
+
@server_side_call = call
|
149
|
+
# iterate through requests so call can complete
|
150
|
+
call.each_remote_read.each { |r| p r }
|
151
|
+
EchoMsg.new
|
152
|
+
end
|
153
|
+
|
154
|
+
def a_server_streaming_rpc(_, call)
|
155
|
+
fail 'shouldnt reuse service' unless @server_side_call.nil?
|
156
|
+
@server_side_call = call
|
157
|
+
[EchoMsg.new, EchoMsg.new]
|
158
|
+
end
|
159
|
+
|
160
|
+
def a_bidi_rpc(requests, call)
|
161
|
+
fail 'shouldnt reuse service' unless @server_side_call.nil?
|
162
|
+
@server_side_call = call
|
163
|
+
requests.each { |r| p r }
|
164
|
+
[EchoMsg.new, EchoMsg.new]
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
CheckCallAfterFinishedServiceStub = CheckCallAfterFinishedService.rpc_stub_class
|
169
|
+
|
129
170
|
describe GRPC::RpcServer do
|
130
171
|
RpcServer = GRPC::RpcServer
|
131
172
|
StatusCodes = GRPC::Core::StatusCodes
|
@@ -520,5 +561,109 @@ describe GRPC::RpcServer do
|
|
520
561
|
t.join
|
521
562
|
end
|
522
563
|
end
|
564
|
+
|
565
|
+
context 'when call objects are used after calls have completed' do
|
566
|
+
before(:each) do
|
567
|
+
server_opts = {
|
568
|
+
poll_period: 1
|
569
|
+
}
|
570
|
+
@srv = RpcServer.new(**server_opts)
|
571
|
+
alt_port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
|
572
|
+
@alt_host = "0.0.0.0:#{alt_port}"
|
573
|
+
|
574
|
+
@service = CheckCallAfterFinishedService.new
|
575
|
+
@srv.handle(@service)
|
576
|
+
@srv_thd = Thread.new { @srv.run }
|
577
|
+
@srv.wait_till_running
|
578
|
+
end
|
579
|
+
|
580
|
+
# check that the server-side call is still in a usable state even
|
581
|
+
# after it has finished
|
582
|
+
def check_single_req_view_of_finished_call(call)
|
583
|
+
common_check_of_finished_server_call(call)
|
584
|
+
|
585
|
+
expect(call.peer).to be_a(String)
|
586
|
+
expect(call.peer_cert).to be(nil)
|
587
|
+
end
|
588
|
+
|
589
|
+
def check_multi_req_view_of_finished_call(call)
|
590
|
+
common_check_of_finished_server_call(call)
|
591
|
+
|
592
|
+
expect do
|
593
|
+
call.each_remote_read.each { |r| p r }
|
594
|
+
end.to raise_error(GRPC::Core::CallError)
|
595
|
+
end
|
596
|
+
|
597
|
+
def common_check_of_finished_server_call(call)
|
598
|
+
expect do
|
599
|
+
call.merge_metadata_to_send({})
|
600
|
+
end.to raise_error(RuntimeError)
|
601
|
+
|
602
|
+
expect do
|
603
|
+
call.send_initial_metadata
|
604
|
+
end.to_not raise_error
|
605
|
+
|
606
|
+
expect(call.cancelled?).to be(false)
|
607
|
+
expect(call.metadata).to be_a(Hash)
|
608
|
+
expect(call.metadata['user-agent']).to be_a(String)
|
609
|
+
|
610
|
+
expect(call.metadata_sent).to be(true)
|
611
|
+
expect(call.output_metadata).to eq({})
|
612
|
+
expect(call.metadata_to_send).to eq({})
|
613
|
+
expect(call.deadline.is_a?(Time)).to be(true)
|
614
|
+
end
|
615
|
+
|
616
|
+
it 'should not crash when call used after an unary call is finished' do
|
617
|
+
req = EchoMsg.new
|
618
|
+
stub = CheckCallAfterFinishedServiceStub.new(@alt_host,
|
619
|
+
:this_channel_is_insecure)
|
620
|
+
resp = stub.an_rpc(req)
|
621
|
+
expect(resp).to be_a(EchoMsg)
|
622
|
+
@srv.stop
|
623
|
+
@srv_thd.join
|
624
|
+
|
625
|
+
check_single_req_view_of_finished_call(@service.server_side_call)
|
626
|
+
end
|
627
|
+
|
628
|
+
it 'should not crash when call used after client streaming finished' do
|
629
|
+
requests = [EchoMsg.new, EchoMsg.new]
|
630
|
+
stub = CheckCallAfterFinishedServiceStub.new(@alt_host,
|
631
|
+
:this_channel_is_insecure)
|
632
|
+
resp = stub.a_client_streaming_rpc(requests)
|
633
|
+
expect(resp).to be_a(EchoMsg)
|
634
|
+
@srv.stop
|
635
|
+
@srv_thd.join
|
636
|
+
|
637
|
+
check_multi_req_view_of_finished_call(@service.server_side_call)
|
638
|
+
end
|
639
|
+
|
640
|
+
it 'should not crash when call used after server streaming finished' do
|
641
|
+
req = EchoMsg.new
|
642
|
+
stub = CheckCallAfterFinishedServiceStub.new(@alt_host,
|
643
|
+
:this_channel_is_insecure)
|
644
|
+
responses = stub.a_server_streaming_rpc(req)
|
645
|
+
responses.each do |r|
|
646
|
+
expect(r).to be_a(EchoMsg)
|
647
|
+
end
|
648
|
+
@srv.stop
|
649
|
+
@srv_thd.join
|
650
|
+
|
651
|
+
check_single_req_view_of_finished_call(@service.server_side_call)
|
652
|
+
end
|
653
|
+
|
654
|
+
it 'should not crash when call used after a bidi call is finished' do
|
655
|
+
requests = [EchoMsg.new, EchoMsg.new]
|
656
|
+
stub = CheckCallAfterFinishedServiceStub.new(@alt_host,
|
657
|
+
:this_channel_is_insecure)
|
658
|
+
responses = stub.a_bidi_rpc(requests)
|
659
|
+
responses.each do |r|
|
660
|
+
expect(r).to be_a(EchoMsg)
|
661
|
+
end
|
662
|
+
@srv.stop
|
663
|
+
@srv_thd.join
|
664
|
+
|
665
|
+
check_multi_req_view_of_finished_call(@service.server_side_call)
|
666
|
+
end
|
667
|
+
end
|
523
668
|
end
|
524
669
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
-----BEGIN PRIVATE KEY-----
|
2
|
+
MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAOxUR9uhvhbeVUIM
|
3
|
+
s5WbH0px0mehl2+6sZpNjzvE2KimZpHzMJHukVH0Ffkvhs0b8+S5Ut9VNUAqd3IM
|
4
|
+
JCCAEGtRNoQhM1t9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zNTYwMloXDTI0MDcxNDIzNTYw
|
5
|
+
MlowWjELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
6
|
+
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDETMBEGA1UEAwwKdGVzdGNsaWVudDCB
|
7
|
+
nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA7FRH26G+Ft5VQgyzlZsfSnHSZ6GX
|
8
|
+
b7qxmk2PO8TYqKZmkfMwke6RUfQV+S+GzRvz5LlS31U1QCp3cgwkIIAQa1E2hCEz
|
9
|
+
W31ivbMByRK9tFpyn4Uv8KP14ObKjTQqxUZp558DgOHg5b5mGRM0pyV1eqRK6PWw
|
10
|
+
R/bjglli6pmnr+0CAwEAATANBgkqhkiG9w0BAQUFAAOBgQAStSm5PM7ubROiKK6/
|
11
|
+
T2FkKlhiTOx+Ryenm3Eio59emq+jXl+1nhPySX5G2PQzSR5vd1dIhwgZSR4Gyttk
|
12
|
+
tRZ57k/NI1brUW8joiEOMJA/Mr7H7asx7wIRYDE91Fs8GkKWd5LhoPAQj+qdG35C
|
13
|
+
OO+svdkmqH0KZo320ZUqdl2ooQ==
|
14
|
+
-----END CERTIFICATE-----
|
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.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gRPC Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: src/ruby/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -844,6 +844,7 @@ files:
|
|
844
844
|
- src/ruby/spec/channel_connection_spec.rb
|
845
845
|
- src/ruby/spec/channel_credentials_spec.rb
|
846
846
|
- src/ruby/spec/channel_spec.rb
|
847
|
+
- src/ruby/spec/client_auth_spec.rb
|
847
848
|
- src/ruby/spec/client_server_spec.rb
|
848
849
|
- src/ruby/spec/compression_options_spec.rb
|
849
850
|
- src/ruby/spec/error_sanity_spec.rb
|
@@ -860,6 +861,8 @@ files:
|
|
860
861
|
- src/ruby/spec/spec_helper.rb
|
861
862
|
- src/ruby/spec/testdata/README
|
862
863
|
- src/ruby/spec/testdata/ca.pem
|
864
|
+
- src/ruby/spec/testdata/client.key
|
865
|
+
- src/ruby/spec/testdata/client.pem
|
863
866
|
- src/ruby/spec/testdata/server1.key
|
864
867
|
- src/ruby/spec/testdata/server1.pem
|
865
868
|
- src/ruby/spec/time_consts_spec.rb
|
@@ -1405,10 +1408,13 @@ summary: GRPC system in Ruby
|
|
1405
1408
|
test_files:
|
1406
1409
|
- src/ruby/spec/server_spec.rb
|
1407
1410
|
- src/ruby/spec/channel_spec.rb
|
1411
|
+
- src/ruby/spec/client_auth_spec.rb
|
1408
1412
|
- src/ruby/spec/testdata/README
|
1409
1413
|
- src/ruby/spec/testdata/ca.pem
|
1410
1414
|
- src/ruby/spec/testdata/server1.key
|
1415
|
+
- src/ruby/spec/testdata/client.pem
|
1411
1416
|
- src/ruby/spec/testdata/server1.pem
|
1417
|
+
- src/ruby/spec/testdata/client.key
|
1412
1418
|
- src/ruby/spec/time_consts_spec.rb
|
1413
1419
|
- src/ruby/spec/channel_connection_spec.rb
|
1414
1420
|
- src/ruby/spec/call_spec.rb
|