Merge pull request #287 from tbetbetbe/grpc_ruby_unittest_cleanup

Grpc ruby unittest cleanup
pull/289/head
Michael Lumish 10 years ago
commit d87c9ea3c9
  1. 16
      src/ruby/Rakefile
  2. 42
      src/ruby/spec/completion_queue_spec.rb
  3. 8
      src/ruby/spec/generic/rpc_server_spec.rb
  4. 10
      tools/dockerfile/grpc_ruby/Dockerfile
  5. 1
      tools/dockerfile/grpc_ruby_base/Dockerfile

@ -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']

@ -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

@ -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,

@ -12,14 +12,8 @@ RUN touch /var/local/git/grpc/include/grpc/support/string.h
# Build the C core.
RUN make install_c -C /var/local/git/grpc
# Install the grpc gem locally with its dependencies and build the extension
RUN /bin/bash -l -c 'cd /var/local/git/grpc/src/ruby && bundle && rake compile:grpc && gem build grpc.gemspec && gem install grpc'
# TODO add a command to run the unittest tests when the bug below is fixed
# - the tests fail due to an error in the C threading library:
# they fail with 'ruby: __pthread_mutex_cond_lock_adjust for unknown reasons' at the end of a testcase
# - however, the interop server and client run OK, so this bug can be investigated
# RUN /bin/bash -l -c 'cd /var/local/git/grpc/src/ruby && bundle && rake'
# Build ruby gRPC and run its tests
RUN /bin/bash -l -c 'cd /var/local/git/grpc/src/ruby && bundle && rake'
# Add a cacerts directory containing the Google root pem file, allowing the ruby client to access the production test instance
ADD cacerts cacerts

@ -39,7 +39,6 @@ RUN /bin/bash -l -c "curl -L get.rvm.io | bash -s stable"
RUN /bin/bash -l -c "rvm install ruby-2.1"
RUN /bin/bash -l -c "rvm use --default ruby-2.1"
RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'source /home/grpc_ruby/.rvm/scripts/rvm' >> ~/.bashrc"
RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"

Loading…
Cancel
Save