diff options
author | Michael Lumish <mlumish@google.com> | 2015-01-29 13:38:33 -0800 |
---|---|---|
committer | Michael Lumish <mlumish@google.com> | 2015-01-29 13:38:33 -0800 |
commit | d87c9ea3c9aec16fff5f52dd221d728701c78dcf (patch) | |
tree | 4452718ee7025bdac5070f265adcfae51906541a /src/ruby | |
parent | 14a2b8d1f493e55ff4e543cde820fd06b0ec0923 (diff) | |
parent | 303af9f322a28e6ebc7786769453331507c9d4c7 (diff) |
Merge pull request #287 from tbetbetbe/grpc_ruby_unittest_cleanup
Grpc ruby unittest cleanup
Diffstat (limited to 'src/ruby')
-rwxr-xr-x | src/ruby/Rakefile | 16 | ||||
-rw-r--r-- | src/ruby/spec/completion_queue_spec.rb | 42 | ||||
-rw-r--r-- | src/ruby/spec/generic/rpc_server_spec.rb | 8 |
3 files changed, 36 insertions, 30 deletions
diff --git a/src/ruby/Rakefile b/src/ruby/Rakefile index 6ba9a97c89..5fc325ef0e 100755 --- a/src/ruby/Rakefile +++ b/src/ruby/Rakefile @@ -13,9 +13,11 @@ end SPEC_SUITES = [ { id: :wrapper, title: 'wrapper layer', files: %w(spec/*.rb) }, { id: :idiomatic, title: 'idiomatic layer', dir: %w(spec/generic), - tag: '~bidi' }, + tags: ['~bidi', '~server'] }, { id: :bidi, title: 'bidi tests', dir: %w(spec/generic), - tag: 'bidi' } + tag: 'bidi' }, + { id: :server, title: 'rpc server thread tests', dir: %w(spec/generic), + tag: 'server' } ] desc 'Run all RSpec tests' @@ -33,12 +35,18 @@ namespace :spec do t.pattern = spec_files t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag] + t.rspec_opts = suite[:tags].map{ |t| "--tag #{t}" }.join(' ') if suite[:tags] end end end end -task default: 'spec:suite:idiomatic' # this should be spec:suite:bidi +desc 'Run compiles the extension, runs all the tests' +task :all + +task default: :all task 'spec:suite:wrapper' => :compile task 'spec:suite:idiomatic' => 'spec:suite:wrapper' -task 'spec:suite:bidi' => 'spec:suite:idiomatic' +task 'spec:suite:bidi' => 'spec:suite:wrapper' +task 'spec:suite:server' => 'spec:suite:wrapper' +task :all => ['spec:suite:idiomatic', 'spec:suite:bidi', 'spec:suite:server'] diff --git a/src/ruby/spec/completion_queue_spec.rb b/src/ruby/spec/completion_queue_spec.rb index 022a066e8e..6117e062d6 100644 --- a/src/ruby/spec/completion_queue_spec.rb +++ b/src/ruby/spec/completion_queue_spec.rb @@ -30,6 +30,10 @@ require 'grpc' describe GRPC::Core::CompletionQueue do + before(:example) do + @cq = GRPC::Core::CompletionQueue.new + end + describe '#new' do it 'is constructed successufully' do expect { GRPC::Core::CompletionQueue.new }.not_to raise_error @@ -38,39 +42,33 @@ describe GRPC::Core::CompletionQueue do describe '#next' do it 'can be called without failing' do - ch = GRPC::Core::CompletionQueue.new - expect { ch.next(3) }.not_to raise_error + expect { @cq.next(3) }.not_to raise_error end - it 'can be called with the time constants' do - ch = GRPC::Core::CompletionQueue.new - # don't use INFINITE_FUTURE, as there we have no events. - non_blocking_consts = [:ZERO, :INFINITE_PAST] - m = GRPC::Core::TimeConsts - non_blocking_consts.each do |c| - a_time = m.const_get(c) - expect { ch.next(a_time) }.not_to raise_error - end + it 'can be called with a time constant' do + # don't use INFINITE_FUTURE, as are no events and this blocks. + # + # don't use INFINITE_PAST, as this fails on docker, and does not need to + # be tested, as its not used anywhere in the ruby implementation + a_time = GRPC::Core::TimeConsts::ZERO + expect { @cq.next(a_time) }.not_to raise_error end end describe '#pluck' do it 'can be called without failing' do - ch = GRPC::Core::CompletionQueue.new tag = Object.new - expect { ch.pluck(tag, 3) }.not_to raise_error + expect { @cq.pluck(tag, 3) }.not_to raise_error end - it 'can be called with the time constants' do - ch = GRPC::Core::CompletionQueue.new - # don't use INFINITE_FUTURE, as there we have no events. - non_blocking_consts = [:ZERO, :INFINITE_PAST] - m = GRPC::Core::TimeConsts + it 'can be called with a time constant' do + # don't use INFINITE_FUTURE, as there no events and this blocks. + # + # don't use INFINITE_PAST, as this fails on docker, and does not need to + # be tested, as its not used anywhere in the ruby implementation tag = Object.new - non_blocking_consts.each do |c| - a_time = m.const_get(c) - expect { ch.pluck(tag, a_time) }.not_to raise_error - end + a_time = GRPC::Core::TimeConsts::ZERO + expect { @cq.pluck(tag, a_time) }.not_to raise_error end end end diff --git a/src/ruby/spec/generic/rpc_server_spec.rb b/src/ruby/spec/generic/rpc_server_spec.rb index e083bc1e9d..0ec79572e7 100644 --- a/src/ruby/spec/generic/rpc_server_spec.rb +++ b/src/ruby/spec/generic/rpc_server_spec.rb @@ -323,7 +323,7 @@ describe GRPC::RpcServer do end describe 'when running' do - it 'should return NOT_FOUND status for requests on unknown methods' do + it 'should return NOT_FOUND status on unknown methods', server: true do @srv.handle(EchoService) t = Thread.new { @srv.run } @srv.wait_till_running @@ -338,7 +338,7 @@ describe GRPC::RpcServer do t.join end - it 'should obtain responses for multiple sequential requests' do + it 'should handle multiple sequential requests', server: true do @srv.handle(EchoService) t = Thread.new { @srv.run } @srv.wait_till_running @@ -350,7 +350,7 @@ describe GRPC::RpcServer do t.join end - it 'should obtain responses for multiple parallel requests' do + it 'should handle multiple parallel requests', server: true do @srv.handle(EchoService) Thread.new { @srv.run } @srv.wait_till_running @@ -368,7 +368,7 @@ describe GRPC::RpcServer do threads.each(&:join) end - it 'should return UNAVAILABLE status if there too many jobs' do + it 'should return UNAVAILABLE on too many jobs', server: true do opts = { a_channel_arg: 'an_arg', server_override: @server, |