|
|
|
@ -136,12 +136,14 @@ class PingPongPlayer |
|
|
|
|
include Grpc::Testing::PayloadType |
|
|
|
|
attr_accessor :assertions # required by Minitest::Assertions |
|
|
|
|
attr_accessor :queue |
|
|
|
|
attr_accessor :canceller_op |
|
|
|
|
|
|
|
|
|
# reqs is the enumerator over the requests |
|
|
|
|
def initialize(msg_sizes) |
|
|
|
|
@queue = Queue.new |
|
|
|
|
@msg_sizes = msg_sizes |
|
|
|
|
@assertions = 0 # required by Minitest::Assertions |
|
|
|
|
@canceller_op = nil # used to cancel after the first response |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def each_item |
|
|
|
@ -155,12 +157,15 @@ class PingPongPlayer |
|
|
|
|
response_parameters: [p_cls.new(size: resp_size)]) |
|
|
|
|
yield req |
|
|
|
|
resp = @queue.pop |
|
|
|
|
assert_equal(:COMPRESSABLE, resp.payload.type, |
|
|
|
|
'payload type is wrong') |
|
|
|
|
assert_equal(:COMPRESSABLE, resp.payload.type, 'payload type is wrong') |
|
|
|
|
assert_equal(resp_size, resp.payload.body.length, |
|
|
|
|
'payload body #{i} has the wrong length') |
|
|
|
|
"payload body #{count} has the wrong length") |
|
|
|
|
p "OK: ping_pong #{count}" |
|
|
|
|
count += 1 |
|
|
|
|
unless @canceller_op.nil? |
|
|
|
|
canceller_op.cancel |
|
|
|
|
break |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -260,6 +265,27 @@ class NamedTests |
|
|
|
|
p 'OK: ping_pong' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def cancel_after_begin |
|
|
|
|
msg_sizes = [27_182, 8, 1828, 45_904] |
|
|
|
|
reqs = msg_sizes.map do |x| |
|
|
|
|
req = Payload.new(body: nulls(x)) |
|
|
|
|
StreamingInputCallRequest.new(payload: req) |
|
|
|
|
end |
|
|
|
|
op = @stub.streaming_input_call(reqs, return_op: true) |
|
|
|
|
op.cancel |
|
|
|
|
assert_raises(GRPC::Cancelled) { op.execute } |
|
|
|
|
p 'OK: cancel_after_begin' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def cancel_after_first |
|
|
|
|
msg_sizes = [[27_182, 31_415], [8, 9], [1828, 2653], [45_904, 58_979]] |
|
|
|
|
ppp = PingPongPlayer.new(msg_sizes) |
|
|
|
|
op = @stub.full_duplex_call(ppp.each_item, return_op: true) |
|
|
|
|
ppp.canceller_op = op # causes ppp to cancel after the 1st message |
|
|
|
|
assert_raises(GRPC::Cancelled) { op.execute.each { |r| ppp.queue.push(r) } } |
|
|
|
|
p 'OK: cancel_after_first' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def all |
|
|
|
|
all_methods = NamedTests.instance_methods(false).map(&:to_s) |
|
|
|
|
all_methods.each do |m| |
|
|
|
|