Merge pull request #17290 from ganmacs/return-unimplemented-in-server-streamer

Return UNIMPLEMENTED error when user does not implement server_streamer method
pull/17320/head
apolcyn 6 years ago committed by GitHub
commit aa00e06b65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/ruby/lib/grpc/generic/service.rb
  2. 22
      src/ruby/spec/generic/rpc_server_spec.rb
  3. 1
      src/ruby/spec/support/services.rb

@ -95,7 +95,7 @@ module GRPC
rpc_descs[name] = RpcDesc.new(name, input, output,
marshal_class_method,
unmarshal_class_method)
define_method(GenericService.underscore(name.to_s).to_sym) do |_, _|
define_method(GenericService.underscore(name.to_s).to_sym) do |*|
fail GRPC::BadStatus.new_status_exception(
GRPC::Core::StatusCodes::UNIMPLEMENTED)
end

@ -342,6 +342,28 @@ describe GRPC::RpcServer do
t.join
end
it 'should return UNIMPLEMENTED on unimplemented ' \
'methods for client_streamer', server: true do
@srv.handle(EchoService)
t = Thread.new { @srv.run }
@srv.wait_till_running
blk = proc do
stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
requests = [EchoMsg.new, EchoMsg.new]
stub.a_client_streaming_rpc_unimplemented(requests)
end
begin
expect(&blk).to raise_error do |error|
expect(error).to be_a(GRPC::BadStatus)
expect(error.code).to eq(GRPC::Core::StatusCodes::UNIMPLEMENTED)
end
ensure
@srv.stop # should be call not to crash
t.join
end
end
it 'should handle multiple sequential requests', server: true do
@srv.handle(EchoService)
t = Thread.new { @srv.run }

@ -33,6 +33,7 @@ class EchoService
rpc :a_client_streaming_rpc, stream(EchoMsg), EchoMsg
rpc :a_server_streaming_rpc, EchoMsg, stream(EchoMsg)
rpc :a_bidi_rpc, stream(EchoMsg), stream(EchoMsg)
rpc :a_client_streaming_rpc_unimplemented, stream(EchoMsg), EchoMsg
attr_reader :received_md
def initialize(**kw)

Loading…
Cancel
Save