Merge pull request #139 from tbetbetbe/grpc_ruby_correct_interop_test_payload_type

Corrects the ruby interop tests
pull/149/head
Michael Lumish 10 years ago
commit eca0e219d6
  1. 16
      src/ruby/bin/interop/interop_client.rb
  2. 2
      src/ruby/bin/interop/interop_server.rb

@ -107,11 +107,11 @@ class PingPongPlayer
@msg_sizes.each do |m| @msg_sizes.each do |m|
req_size, resp_size = m req_size, resp_size = m
req = req_cls.new(payload: Payload.new(body: nulls(req_size)), req = req_cls.new(payload: Payload.new(body: nulls(req_size)),
response_type: COMPRESSABLE, response_type: :COMPRESSABLE,
response_parameters: [p_cls.new(size: resp_size)]) response_parameters: [p_cls.new(size: resp_size)])
yield req yield req
resp = @queue.pop resp = @queue.pop
assert_equal(PayloadType.lookup(COMPRESSABLE), resp.payload.type, assert_equal(:COMPRESSABLE, resp.payload.type,
'payload type is wrong') 'payload type is wrong')
assert_equal(resp_size, resp.payload.body.length, assert_equal(resp_size, resp.payload.body.length,
'payload body #{i} has the wrong length') 'payload body #{i} has the wrong length')
@ -149,11 +149,13 @@ class NamedTests
# FAILED # FAILED
def large_unary def large_unary
req_size, wanted_response_size = 271_828, 314_159 req_size, wanted_response_size = 271_828, 314_159
payload = Payload.new(type: COMPRESSABLE, body: nulls(req_size)) payload = Payload.new(type: :COMPRESSABLE, body: nulls(req_size))
req = SimpleRequest.new(response_type: COMPRESSABLE, req = SimpleRequest.new(response_type: :COMPRESSABLE,
response_size: wanted_response_size, response_size: wanted_response_size,
payload: payload) payload: payload)
resp = @stub.unary_call(req) resp = @stub.unary_call(req)
assert_equal(:COMPRESSABLE, resp.payload.type,
'large_unary: payload had the wrong type')
assert_equal(wanted_response_size, resp.payload.body.length, assert_equal(wanted_response_size, resp.payload.body.length,
'large_unary: payload had the wrong length') 'large_unary: payload had the wrong length')
assert_equal(nulls(wanted_response_size), resp.payload.body, assert_equal(nulls(wanted_response_size), resp.payload.body,
@ -185,12 +187,12 @@ class NamedTests
def server_streaming def server_streaming
msg_sizes = [31_415, 9, 2653, 58_979] msg_sizes = [31_415, 9, 2653, 58_979]
response_spec = msg_sizes.map { |s| ResponseParameters.new(size: s) } response_spec = msg_sizes.map { |s| ResponseParameters.new(size: s) }
req = StreamingOutputCallRequest.new(response_type: COMPRESSABLE, req = StreamingOutputCallRequest.new(response_type: :COMPRESSABLE,
response_parameters: response_spec) response_parameters: response_spec)
resps = @stub.streaming_output_call(req) resps = @stub.streaming_output_call(req)
resps.each_with_index do |r, i| resps.each_with_index do |r, i|
assert i < msg_sizes.length, 'too many responses' assert i < msg_sizes.length, 'too many responses'
assert_equal(PayloadType.lookup(COMPRESSABLE), r.payload.type, assert_equal(:COMPRESSABLE, r.payload.type,
'payload type is wrong') 'payload type is wrong')
assert_equal(msg_sizes[i], r.payload.body.length, assert_equal(msg_sizes[i], r.payload.body.length,
'payload body #{i} has the wrong length') 'payload body #{i} has the wrong length')
@ -235,7 +237,7 @@ def parse_options
end end
end.parse! end.parse!
%w(server_host, server_port, test_case).each do |arg| %w(server_host server_port test_case).each do |arg|
if options[arg].nil? if options[arg].nil?
fail(OptionParser::MissingArgument, "please specify --#{arg}") fail(OptionParser::MissingArgument, "please specify --#{arg}")
end end

@ -104,7 +104,7 @@ class TestTarget < Grpc::Testing::TestService::Service
def unary_call(simple_req, _call) def unary_call(simple_req, _call)
req_size = simple_req.response_size req_size = simple_req.response_size
SimpleResponse.new(payload: Payload.new(type: COMPRESSABLE, SimpleResponse.new(payload: Payload.new(type: :COMPRESSABLE,
body: nulls(req_size))) body: nulls(req_size)))
end end

Loading…
Cancel
Save