diff options
author | Alexander Polcyn <apolcyn@google.com> | 2017-07-21 19:22:10 -0700 |
---|---|---|
committer | Alexander Polcyn <apolcyn@google.com> | 2017-07-21 19:22:10 -0700 |
commit | 11fade7c140c86ff005fb0c040318f7c57075b43 (patch) | |
tree | cbf5e43e495577e2dba4048ed6b256a21f67bc51 | |
parent | e8e05f90a40c59a7ee6b1fe43fb097bb3badbeea (diff) |
Fix a ruby test flake
-rw-r--r-- | src/ruby/spec/generic/client_stub_spec.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/ruby/spec/generic/client_stub_spec.rb b/src/ruby/spec/generic/client_stub_spec.rb index a8653e73cf..26cb970a1f 100644 --- a/src/ruby/spec/generic/client_stub_spec.rb +++ b/src/ruby/spec/generic/client_stub_spec.rb @@ -451,10 +451,31 @@ describe 'ClientStub' do /Header values must be of type string or array/) end + def run_server_streamer_against_client_with_unmarshal_error( + expected_input, replys) + wakey_thread do |notifier| + c = expect_server_to_be_invoked(notifier) + expect(c.remote_read).to eq(expected_input) + begin + replys.each { |r| c.remote_send(r) } + rescue GRPC::Core::CallError + # An attempt to write to the client might fail. This is ok + # because the client call is expected to fail when + # unmarshalling the first response, and to cancel the call, + # and there is a race as for when the server-side call will + # start to fail. + p 'remote_send failed (allowed because call expected to cancel)' + ensure + c.send_status(OK, 'OK', true) + end + end + end + it 'the call terminates when there is an unmarshalling error' do server_port = create_test_server host = "localhost:#{server_port}" - th = run_server_streamer(@sent_msg, @replys, @pass) + th = run_server_streamer_against_client_with_unmarshal_error( + @sent_msg, @replys) stub = GRPC::ClientStub.new(host, :this_channel_is_insecure) unmarshal = proc { fail(ArgumentError, 'test unmarshalling error') } |