aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/spec
diff options
context:
space:
mode:
authorGravatar Dan Born <dborn+github@google.com>2016-01-20 14:16:29 -0800
committerGravatar Dan Born <dborn+github@google.com>2016-01-20 14:16:29 -0800
commitbeeb4c2ad75533848ac0fca545a3b4785d8fce57 (patch)
treeeed3a91f80967ab90ae4cbc559503015bd3a0483 /src/ruby/spec
parentb13a69da41ddad7880f409c53d1f55982ee79ac5 (diff)
parent4c3c397bbea2acf023950f7470fe36d2e7322cc0 (diff)
Merge branch 'master' into tcp_listener
Diffstat (limited to 'src/ruby/spec')
-rw-r--r--src/ruby/spec/call_spec.rb2
-rw-r--r--src/ruby/spec/channel_spec.rb21
-rw-r--r--src/ruby/spec/client_server_spec.rb2
-rw-r--r--src/ruby/spec/generic/active_call_spec.rb3
-rw-r--r--src/ruby/spec/generic/client_stub_spec.rb51
-rw-r--r--src/ruby/spec/generic/rpc_server_spec.rb23
-rw-r--r--src/ruby/spec/generic/service_spec.rb9
-rw-r--r--src/ruby/spec/pb/health/checker_spec.rb17
8 files changed, 70 insertions, 58 deletions
diff --git a/src/ruby/spec/call_spec.rb b/src/ruby/spec/call_spec.rb
index 6629570fba..ae3ce0748a 100644
--- a/src/ruby/spec/call_spec.rb
+++ b/src/ruby/spec/call_spec.rb
@@ -101,7 +101,7 @@ describe GRPC::Core::Call do
let(:fake_host) { 'localhost:10101' }
before(:each) do
- @ch = GRPC::Core::Channel.new(fake_host, nil)
+ @ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
end
describe '#status' do
diff --git a/src/ruby/spec/channel_spec.rb b/src/ruby/spec/channel_spec.rb
index b4d2b94a81..355f95c9d7 100644
--- a/src/ruby/spec/channel_spec.rb
+++ b/src/ruby/spec/channel_spec.rb
@@ -45,7 +45,10 @@ describe GRPC::Core::Channel do
shared_examples '#new' do
it 'take a host name without channel args' do
- expect { GRPC::Core::Channel.new('dummy_host', nil) }.not_to raise_error
+ blk = proc do
+ GRPC::Core::Channel.new('dummy_host', nil, :this_channel_is_insecure)
+ end
+ expect(&blk).not_to raise_error
end
it 'does not take a hash with bad keys as channel args' do
@@ -106,13 +109,15 @@ describe GRPC::Core::Channel do
it_behaves_like '#new'
def construct_with_args(a)
- proc { GRPC::Core::Channel.new('dummy_host', a) }
+ proc do
+ GRPC::Core::Channel.new('dummy_host', a, :this_channel_is_insecure)
+ end
end
end
describe '#create_call' do
it 'creates a call OK' do
- ch = GRPC::Core::Channel.new(fake_host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
deadline = Time.now + 5
@@ -123,7 +128,7 @@ describe GRPC::Core::Channel do
end
it 'raises an error if called on a closed channel' do
- ch = GRPC::Core::Channel.new(fake_host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
ch.close
deadline = Time.now + 5
@@ -136,13 +141,13 @@ describe GRPC::Core::Channel do
describe '#destroy' do
it 'destroys a channel ok' do
- ch = GRPC::Core::Channel.new(fake_host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.destroy }
expect(&blk).to_not raise_error
end
it 'can be called more than once without error' do
- ch = GRPC::Core::Channel.new(fake_host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.destroy }
blk.call
expect(&blk).to_not raise_error
@@ -157,13 +162,13 @@ describe GRPC::Core::Channel do
describe '#close' do
it 'closes a channel ok' do
- ch = GRPC::Core::Channel.new(fake_host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.close }
expect(&blk).to_not raise_error
end
it 'can be called more than once without error' do
- ch = GRPC::Core::Channel.new(fake_host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
blk = proc { ch.close }
blk.call
expect(&blk).to_not raise_error
diff --git a/src/ruby/spec/client_server_spec.rb b/src/ruby/spec/client_server_spec.rb
index 7cce2076c9..594fda1cd3 100644
--- a/src/ruby/spec/client_server_spec.rb
+++ b/src/ruby/spec/client_server_spec.rb
@@ -397,7 +397,7 @@ describe 'the http client/server' do
@server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
@server.start
- @ch = Channel.new("0.0.0.0:#{server_port}", nil)
+ @ch = Channel.new("0.0.0.0:#{server_port}", nil, :this_channel_is_insecure)
end
after(:example) do
diff --git a/src/ruby/spec/generic/active_call_spec.rb b/src/ruby/spec/generic/active_call_spec.rb
index b05e3284fe..c0181e21fb 100644
--- a/src/ruby/spec/generic/active_call_spec.rb
+++ b/src/ruby/spec/generic/active_call_spec.rb
@@ -48,7 +48,8 @@ describe GRPC::ActiveCall do
@server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(host, :this_port_is_insecure)
@server.start
- @ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil)
+ @ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
+ :this_channel_is_insecure)
end
after(:each) do
diff --git a/src/ruby/spec/generic/client_stub_spec.rb b/src/ruby/spec/generic/client_stub_spec.rb
index 40550230dd..5e13c25fcf 100644
--- a/src/ruby/spec/generic/client_stub_spec.rb
+++ b/src/ruby/spec/generic/client_stub_spec.rb
@@ -70,7 +70,7 @@ describe 'ClientStub' do
it 'can be created from a host and args' do
opts = { a_channel_arg: 'an_arg' }
blk = proc do
- GRPC::ClientStub.new(fake_host, @cq, **opts)
+ GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end
expect(&blk).not_to raise_error
end
@@ -78,7 +78,7 @@ describe 'ClientStub' do
it 'can be created with a default deadline' do
opts = { a_channel_arg: 'an_arg', deadline: 5 }
blk = proc do
- GRPC::ClientStub.new(fake_host, @cq, **opts)
+ GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end
expect(&blk).not_to raise_error
end
@@ -86,7 +86,7 @@ describe 'ClientStub' do
it 'can be created with an channel override' do
opts = { a_channel_arg: 'an_arg', channel_override: @ch }
blk = proc do
- GRPC::ClientStub.new(fake_host, @cq, **opts)
+ GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end
expect(&blk).not_to raise_error
end
@@ -94,15 +94,15 @@ describe 'ClientStub' do
it 'cannot be created with a bad channel override' do
blk = proc do
opts = { a_channel_arg: 'an_arg', channel_override: Object.new }
- GRPC::ClientStub.new(fake_host, @cq, **opts)
+ GRPC::ClientStub.new(fake_host, @cq, :this_channel_is_insecure, **opts)
end
expect(&blk).to raise_error
end
it 'cannot be created with bad credentials' do
blk = proc do
- opts = { a_channel_arg: 'an_arg', creds: Object.new }
- GRPC::ClientStub.new(fake_host, @cq, **opts)
+ opts = { a_channel_arg: 'an_arg' }
+ GRPC::ClientStub.new(fake_host, @cq, Object.new, **opts)
end
expect(&blk).to raise_error
end
@@ -112,10 +112,10 @@ describe 'ClientStub' do
blk = proc do
opts = {
GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr',
- a_channel_arg: 'an_arg',
- creds: GRPC::Core::ChannelCredentials.new(certs[0], nil, nil)
+ a_channel_arg: 'an_arg'
}
- GRPC::ClientStub.new(fake_host, @cq, **opts)
+ creds = GRPC::Core::ChannelCredentials.new(certs[0], nil, nil)
+ GRPC::ClientStub.new(fake_host, @cq, creds, **opts)
end
expect(&blk).to_not raise_error
end
@@ -130,7 +130,8 @@ describe 'ClientStub' do
it 'should send a request to/receive a reply from a server' do
server_port = create_test_server
th = run_request_response(@sent_msg, @resp, @pass)
- stub = GRPC::ClientStub.new("localhost:#{server_port}", @cq)
+ stub = GRPC::ClientStub.new("localhost:#{server_port}", @cq,
+ :this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp)
th.join
end
@@ -140,7 +141,7 @@ describe 'ClientStub' do
host = "localhost:#{server_port}"
th = run_request_response(@sent_msg, @resp, @pass,
k1: 'v1', k2: 'v2')
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp)
th.join
end
@@ -149,8 +150,10 @@ describe 'ClientStub' do
server_port = create_test_server
alt_host = "localhost:#{server_port}"
th = run_request_response(@sent_msg, @resp, @pass)
- ch = GRPC::Core::Channel.new(alt_host, nil)
- stub = GRPC::ClientStub.new('ignored-host', @cq, channel_override: ch)
+ ch = GRPC::Core::Channel.new(alt_host, nil, :this_channel_is_insecure)
+ stub = GRPC::ClientStub.new('ignored-host', @cq,
+ :this_channel_is_insecure,
+ channel_override: ch)
expect(get_response(stub)).to eq(@resp)
th.join
end
@@ -159,7 +162,7 @@ describe 'ClientStub' do
server_port = create_test_server
host = "localhost:#{server_port}"
th = run_request_response(@sent_msg, @resp, @fail)
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
blk = proc { get_response(stub) }
expect(&blk).to raise_error(GRPC::BadStatus)
th.join
@@ -198,7 +201,7 @@ describe 'ClientStub' do
server_port = create_test_server
host = "localhost:#{server_port}"
th = run_client_streamer(@sent_msgs, @resp, @pass)
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp)
th.join
end
@@ -208,7 +211,7 @@ describe 'ClientStub' do
host = "localhost:#{server_port}"
th = run_client_streamer(@sent_msgs, @resp, @pass,
k1: 'v1', k2: 'v2')
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_response(stub)).to eq(@resp)
th.join
end
@@ -217,7 +220,7 @@ describe 'ClientStub' do
server_port = create_test_server
host = "localhost:#{server_port}"
th = run_client_streamer(@sent_msgs, @resp, @fail)
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
blk = proc { get_response(stub) }
expect(&blk).to raise_error(GRPC::BadStatus)
th.join
@@ -256,7 +259,7 @@ describe 'ClientStub' do
server_port = create_test_server
host = "localhost:#{server_port}"
th = run_server_streamer(@sent_msg, @replys, @pass)
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
expect(get_responses(stub).collect { |r| r }).to eq(@replys)
th.join
end
@@ -265,7 +268,7 @@ describe 'ClientStub' do
server_port = create_test_server
host = "localhost:#{server_port}"
th = run_server_streamer(@sent_msg, @replys, @fail)
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
e = get_responses(stub)
expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus)
th.join
@@ -276,7 +279,7 @@ describe 'ClientStub' do
host = "localhost:#{server_port}"
th = run_server_streamer(@sent_msg, @replys, @fail,
k1: 'v1', k2: 'v2')
- stub = GRPC::ClientStub.new(host, @cq)
+ stub = GRPC::ClientStub.new(host, @cq, :this_channel_is_insecure)
e = get_responses(stub)
expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus)
th.join
@@ -320,7 +323,7 @@ describe 'ClientStub' do
it 'supports sending all the requests first', bidi: true do
th = run_bidi_streamer_handle_inputs_first(@sent_msgs, @replys,
@pass)
- stub = GRPC::ClientStub.new(@host, @cq)
+ stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
e = get_responses(stub)
expect(e.collect { |r| r }).to eq(@replys)
th.join
@@ -328,7 +331,7 @@ describe 'ClientStub' do
it 'supports client-initiated ping pong', bidi: true do
th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, true)
- stub = GRPC::ClientStub.new(@host, @cq)
+ stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
e = get_responses(stub)
expect(e.collect { |r| r }).to eq(@sent_msgs)
th.join
@@ -336,7 +339,7 @@ describe 'ClientStub' do
it 'supports a server-initiated ping pong', bidi: true do
th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, false)
- stub = GRPC::ClientStub.new(@host, @cq)
+ stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
e = get_responses(stub)
expect(e.collect { |r| r }).to eq(@sent_msgs)
th.join
@@ -376,7 +379,7 @@ describe 'ClientStub' do
it 'should fail with DeadlineExceeded', bidi: true do
@server.start
- stub = GRPC::ClientStub.new(@host, @cq)
+ stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
blk = proc do
e = stub.bidi_streamer(@method, @sent_msgs, noop, noop,
timeout: 0.001)
diff --git a/src/ruby/spec/generic/rpc_server_spec.rb b/src/ruby/spec/generic/rpc_server_spec.rb
index d95a021311..be6331d68b 100644
--- a/src/ruby/spec/generic/rpc_server_spec.rb
+++ b/src/ruby/spec/generic/rpc_server_spec.rb
@@ -141,7 +141,7 @@ describe GRPC::RpcServer do
@server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
@host = "localhost:#{server_port}"
- @ch = GRPC::Core::Channel.new(@host, nil)
+ @ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
end
describe '#new' do
@@ -355,7 +355,8 @@ describe GRPC::RpcServer do
req = EchoMsg.new
blk = proc do
cq = GRPC::Core::CompletionQueue.new
- stub = GRPC::ClientStub.new(@host, cq, **client_opts)
+ stub = GRPC::ClientStub.new(@host, cq, :this_channel_is_insecure,
+ **client_opts)
stub.request_response('/unknown', req, marshal, unmarshal)
end
expect(&blk).to raise_error GRPC::BadStatus
@@ -369,7 +370,7 @@ describe GRPC::RpcServer do
@srv.wait_till_running
req = EchoMsg.new
n = 5 # arbitrary
- stub = EchoStub.new(@host, **client_opts)
+ stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
n.times { expect(stub.an_rpc(req)).to be_a(EchoMsg) }
@srv.stop
t.join
@@ -381,7 +382,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run }
@srv.wait_till_running
req = EchoMsg.new
- stub = EchoStub.new(@host, **client_opts)
+ stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
expect(stub.an_rpc(req, k1: 'v1', k2: 'v2')).to be_a(EchoMsg)
wanted_md = [{ 'k1' => 'v1', 'k2' => 'v2' }]
check_md(wanted_md, service.received_md)
@@ -395,7 +396,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run }
@srv.wait_till_running
req = EchoMsg.new
- stub = SlowStub.new(@host, **client_opts)
+ stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
timeout = service.delay + 1.0 # wait for long enough
resp = stub.an_rpc(req, timeout: timeout, k1: 'v1', k2: 'v2')
expect(resp).to be_a(EchoMsg)
@@ -411,7 +412,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run }
@srv.wait_till_running
req = EchoMsg.new
- stub = SlowStub.new(@host, **client_opts)
+ stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
Thread.new do # cancel the call
sleep 0.1
@@ -431,7 +432,7 @@ describe GRPC::RpcServer do
threads = [t]
n.times do
threads << Thread.new do
- stub = EchoStub.new(@host, **client_opts)
+ stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
q << stub.an_rpc(req)
end
end
@@ -459,7 +460,7 @@ describe GRPC::RpcServer do
one_failed_as_unavailable = false
n.times do
threads << Thread.new do
- stub = SlowStub.new(@host, **client_opts)
+ stub = SlowStub.new(@host, :this_channel_is_insecure, **client_opts)
begin
stub.an_rpc(req)
rescue GRPC::BadStatus => e
@@ -499,7 +500,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run }
@srv.wait_till_running
req = EchoMsg.new
- stub = EchoStub.new(@host, **client_opts)
+ stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
expect(op.metadata).to be nil
expect(op.execute).to be_a(EchoMsg)
@@ -537,7 +538,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run }
@srv.wait_till_running
req = EchoMsg.new
- stub = FailingStub.new(@host, **client_opts)
+ stub = FailingStub.new(@host, :this_channel_is_insecure, **client_opts)
blk = proc { stub.an_rpc(req) }
# confirm it raise the expected error
@@ -562,7 +563,7 @@ describe GRPC::RpcServer do
t = Thread.new { @srv.run }
@srv.wait_till_running
req = EchoMsg.new
- stub = EchoStub.new(@host, **client_opts)
+ stub = EchoStub.new(@host, :this_channel_is_insecure, **client_opts)
op = stub.an_rpc(req, k1: 'v1', k2: 'v2', return_op: true)
expect(op.metadata).to be nil
expect(op.execute).to be_a(EchoMsg)
diff --git a/src/ruby/spec/generic/service_spec.rb b/src/ruby/spec/generic/service_spec.rb
index 6cfc34db84..5e7b6c7aba 100644
--- a/src/ruby/spec/generic/service_spec.rb
+++ b/src/ruby/spec/generic/service_spec.rb
@@ -241,7 +241,7 @@ describe GenericService do
end
describe 'the generated instances' do
- it 'can be instanciated with just a hostname' do
+ it 'can be instanciated with just a hostname and credentials' do
s = Class.new do
include GenericService
rpc :AnRpc, GoodMsg, GoodMsg
@@ -250,7 +250,10 @@ describe GenericService do
rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg)
end
client_class = s.rpc_stub_class
- expect { client_class.new('fakehostname') }.not_to raise_error
+ blk = proc do
+ client_class.new('fakehostname', :this_channel_is_insecure)
+ end
+ expect(&blk).not_to raise_error
end
it 'has the methods defined in the service' do
@@ -262,7 +265,7 @@ describe GenericService do
rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg)
end
client_class = s.rpc_stub_class
- o = client_class.new('fakehostname')
+ o = client_class.new('fakehostname', :this_channel_is_insecure)
expect(o.methods).to include(:an_rpc)
expect(o.methods).to include(:a_bidi_streamer)
expect(o.methods).to include(:a_client_streamer)
diff --git a/src/ruby/spec/pb/health/checker_spec.rb b/src/ruby/spec/pb/health/checker_spec.rb
index 322566b784..c1decd822a 100644
--- a/src/ruby/spec/pb/health/checker_spec.rb
+++ b/src/ruby/spec/pb/health/checker_spec.rb
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -47,13 +47,12 @@ describe 'Health protobuf code generation' do
end
it 'should have the same content as created by code generation' do
- root_dir = File.dirname(
- File.dirname(File.dirname(File.dirname(__FILE__))))
- pb_dir = File.join(root_dir, 'pb')
+ root_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..')
+ pb_dir = File.join(root_dir, 'proto')
# Get the current content
- service_path = File.join(pb_dir, 'grpc', 'health', 'v1alpha',
- 'health_services.rb')
+ service_path = File.join(root_dir, 'ruby', 'pb', 'grpc',
+ 'health', 'v1alpha', 'health_services.rb')
want = nil
File.open(service_path) { |f| want = f.read }
@@ -188,7 +187,7 @@ describe Grpc::Health::Checker do
@server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
@host = "localhost:#{server_port}"
- @ch = GRPC::Core::Channel.new(@host, nil)
+ @ch = GRPC::Core::Channel.new(@host, nil, :this_channel_is_insecure)
@client_opts = { channel_override: @ch }
server_opts = {
server_override: @server,
@@ -208,7 +207,7 @@ describe Grpc::Health::Checker do
t = Thread.new { @srv.run }
@srv.wait_till_running
- stub = CheckerStub.new(@host, **@client_opts)
+ stub = CheckerStub.new(@host, :this_channel_is_insecure, **@client_opts)
got = stub.check(HCReq.new)
want = HCResp.new(status: ServingStatus::NOT_SERVING)
expect(got).to eq(want)
@@ -221,7 +220,7 @@ describe Grpc::Health::Checker do
t = Thread.new { @srv.run }
@srv.wait_till_running
blk = proc do
- stub = CheckerStub.new(@host, **@client_opts)
+ stub = CheckerStub.new(@host, :this_channel_is_insecure, **@client_opts)
stub.check(HCReq.new(host: 'unknown', service: 'unknown'))
end
expected_msg = /#{StatusCodes::NOT_FOUND}/