aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/spec/generic
diff options
context:
space:
mode:
authorGravatar Tim Emiola <temiola@google.com>2015-04-15 08:06:16 -0700
committerGravatar Tim Emiola <temiola@google.com>2015-04-15 08:06:16 -0700
commit72d70fc0af2c30609ef765ec938cc231d9dfe255 (patch)
tree98fe5dc13473259e3ab308a62564cd4032704010 /src/ruby/spec/generic
parentc547dcb547b4f6db558244edbe5b1c9d7001b717 (diff)
Adds a tests that demonstrates successful cancellation
Diffstat (limited to 'src/ruby/spec/generic')
-rw-r--r--src/ruby/spec/generic/rpc_server_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ruby/spec/generic/rpc_server_spec.rb b/src/ruby/spec/generic/rpc_server_spec.rb
index 245999ea03..25ad6f7e59 100644
--- a/src/ruby/spec/generic/rpc_server_spec.rb
+++ b/src/ruby/spec/generic/rpc_server_spec.rb
@@ -388,6 +388,23 @@ describe GRPC::RpcServer do
t.join
end
+ it 'should handle cancellation correctly', server: true do
+ service = SlowService.new
+ @srv.handle(service)
+ t = Thread.new { @srv.run }
+ @srv.wait_till_running
+ req = EchoMsg.new
+ stub = SlowStub.new(@host, **@client_opts)
+ op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
+ cancel_thread = Thread.new do
+ sleep 0.1
+ op.cancel
+ end
+ expect{op.execute}.to raise_error GRPC::Cancelled
+ @srv.stop
+ t.join
+ end
+
it 'should receive updated metadata', server: true do
service = EchoService.new
@srv.handle(service)