Merge pull request #16653 from ganmacs/not-to-use-p-in-test

Use logger to suppress output debug output during test
pull/13653/merge
apolcyn 6 years ago committed by GitHub
commit 878703d6fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/ruby/spec/client_auth_spec.rb
  2. 22
      src/ruby/spec/generic/client_stub_spec.rb
  3. 6
      src/ruby/spec/generic/rpc_server_spec.rb
  4. 50
      src/ruby/spec/support/services.rb

@ -30,7 +30,7 @@ end
def create_server_creds
test_root = File.join(File.dirname(__FILE__), 'testdata')
p "test root: #{test_root}"
GRPC.logger.info("test root: #{test_root}")
files = ['ca.pem', 'server1.key', 'server1.pem']
creds = files.map { |f| File.open(File.join(test_root, f)).read }
GRPC::Core::ServerCredentials.new(
@ -59,7 +59,7 @@ class SslTestService
def a_client_streaming_rpc(call)
check_peer_cert(call)
call.each_remote_read.each { |r| p r }
call.each_remote_read.each { |r| GRPC.logger.info(r) }
EchoMsg.new
end
@ -70,7 +70,7 @@ class SslTestService
def a_bidi_rpc(requests, call)
check_peer_cert(call)
requests.each { |r| p r }
requests.each { |r| GRPC.logger.info(r) }
[EchoMsg.new, EchoMsg.new]
end
end
@ -116,11 +116,11 @@ describe 'client-server auth' do
it 'client-server auth with server streaming RPCs' do
responses = @stub.a_server_streaming_rpc(EchoMsg.new)
responses.each { |r| p r }
responses.each { |r| GRPC.logger.info(r) }
end
it 'client-server auth with bidi RPCs' do
responses = @stub.a_bidi_rpc([EchoMsg.new, EchoMsg.new])
responses.each { |r| p r }
responses.each { |r| GRPC.logger.info(r) }
end
end

@ -293,7 +293,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
describe 'without a call operation' do
def get_response(stub, credentials: nil)
puts credentials.inspect
GRPC.logger.info(credentials.inspect)
stub.request_response(@method, @sent_msg, noop, noop,
metadata: @metadata,
credentials: credentials)
@ -342,13 +342,15 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
it 'sends metadata to the server ok when running start_call first' do
run_op_view_metadata_test(true)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) { |r| p r }
@op, @server_initial_md, @server_trailing_md
) { |r| GRPC.logger.info(r) }
end
it 'does not crash when used after the call has been finished' do
run_op_view_metadata_test(false)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) { |r| p r }
@op, @server_initial_md, @server_trailing_md
) { |r| GRPC.logger.info(r) }
end
end
end
@ -435,13 +437,15 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
it 'sends metadata to the server ok when running start_call first' do
run_op_view_metadata_test(true)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) { |r| p r }
@op, @server_initial_md, @server_trailing_md
) { |r| GRPC.logger.info(r) }
end
it 'does not crash when used after the call has been finished' do
run_op_view_metadata_test(false)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) { |r| p r }
@op, @server_initial_md, @server_trailing_md
) { |r| GRPC.logger.info(r) }
end
end
end
@ -578,7 +582,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
run_op_view_metadata_test(true)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) do |responses|
responses.each { |r| p r }
responses.each { |r| GRPC.logger.info(r) }
end
end
@ -586,7 +590,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
run_op_view_metadata_test(false)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) do |responses|
responses.each { |r| p r }
responses.each { |r| GRPC.logger.info(r) }
end
end
@ -895,7 +899,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
run_op_view_metadata_test(true)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) do |responses|
responses.each { |r| p r }
responses.each { |r| GRPC.logger.info(r) }
end
end
@ -903,7 +907,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
run_op_view_metadata_test(false)
check_op_view_of_finished_client_call(
@op, @server_initial_md, @server_trailing_md) do |responses|
responses.each { |r| p r }
responses.each { |r| GRPC.logger.info(r) }
end
end

@ -125,7 +125,7 @@ class CheckCallAfterFinishedService
fail 'shouldnt reuse service' unless @server_side_call.nil?
@server_side_call = call
# iterate through requests so call can complete
call.each_remote_read.each { |r| p r }
call.each_remote_read.each { |r| GRPC.logger.info(r) }
EchoMsg.new
end
@ -138,7 +138,7 @@ class CheckCallAfterFinishedService
def a_bidi_rpc(requests, call)
fail 'shouldnt reuse service' unless @server_side_call.nil?
@server_side_call = call
requests.each { |r| p r }
requests.each { |r| GRPC.logger.info(r) }
[EchoMsg.new, EchoMsg.new]
end
end
@ -560,7 +560,7 @@ describe GRPC::RpcServer do
'connect_k1' => 'connect_v1'
}
wanted_md.each do |key, value|
puts "key: #{key}"
GRPC.logger.info("key: #{key}")
expect(op.metadata[key]).to eq(value)
end
@srv.stop

@ -50,7 +50,9 @@ class EchoService
def a_client_streaming_rpc(call)
# iterate through requests so call can complete
call.output_metadata.update(@trailing_metadata)
call.each_remote_read.each { |r| p r }
call.each_remote_read.each do |r|
GRPC.logger.info(r)
end
EchoMsg.new
end
@ -61,7 +63,9 @@ class EchoService
def a_bidi_rpc(requests, call)
call.output_metadata.update(@trailing_metadata)
requests.each { |r| p r }
requests.each do |r|
GRPC.logger.info(r)
end
[EchoMsg.new, EchoMsg.new]
end
end
@ -71,35 +75,37 @@ EchoStub = EchoService.rpc_stub_class
# For testing server interceptors
class TestServerInterceptor < GRPC::ServerInterceptor
def request_response(request:, call:, method:)
p "Received request/response call at method #{method}" \
" with request #{request} for call #{call}"
GRPC.logger.info("Received request/response call at method #{method}" \
" with request #{request} for call #{call}")
call.output_metadata[:interc] = 'from_request_response'
p "[GRPC::Ok] (#{method.owner.name}.#{method.name})"
GRPC.logger.info("[GRPC::Ok] (#{method.owner.name}.#{method.name})")
yield
end
def client_streamer(call:, method:)
call.output_metadata[:interc] = 'from_client_streamer'
call.each_remote_read.each do |r|
p "In interceptor: #{r}"
GRPC.logger.info("In interceptor: #{r}")
end
p "Received client streamer call at method #{method} for call #{call}"
GRPC.logger.info(
"Received client streamer call at method #{method} for call #{call}"
)
yield
end
def server_streamer(request:, call:, method:)
p "Received server streamer call at method #{method} with request" \
" #{request} for call #{call}"
GRPC.logger.info("Received server streamer call at method #{method} with request" \
" #{request} for call #{call}")
call.output_metadata[:interc] = 'from_server_streamer'
yield
end
def bidi_streamer(requests:, call:, method:)
requests.each do |r|
p "Bidi request: #{r}"
GRPC.logger.info("Bidi request: #{r}")
end
p "Received bidi streamer call at method #{method} with requests" \
" #{requests} for call #{call}"
GRPC.logger.info("Received bidi streamer call at method #{method} with requests" \
" #{requests} for call #{call}")
call.output_metadata[:interc] = 'from_bidi_streamer'
yield
end
@ -108,38 +114,38 @@ end
# For testing client interceptors
class TestClientInterceptor < GRPC::ClientInterceptor
def request_response(request:, call:, method:, metadata: {})
p "Intercepted request/response call at method #{method}" \
GRPC.logger.info("Intercepted request/response call at method #{method}" \
" with request #{request} for call #{call}" \
" and metadata: #{metadata}"
" and metadata: #{metadata}")
metadata['foo'] = 'bar_from_request_response'
yield
end
def client_streamer(requests:, call:, method:, metadata: {})
p "Received client streamer call at method #{method}" \
GRPC.logger.info("Received client streamer call at method #{method}" \
" with requests #{requests} for call #{call}" \
" and metadata: #{metadata}"
" and metadata: #{metadata}")
requests.each do |r|
p "In client interceptor: #{r}"
GRPC.logger.info("In client interceptor: #{r}")
end
metadata['foo'] = 'bar_from_client_streamer'
yield
end
def server_streamer(request:, call:, method:, metadata: {})
p "Received server streamer call at method #{method}" \
GRPC.logger.info("Received server streamer call at method #{method}" \
" with request #{request} for call #{call}" \
" and metadata: #{metadata}"
" and metadata: #{metadata}")
metadata['foo'] = 'bar_from_server_streamer'
yield
end
def bidi_streamer(requests:, call:, method:, metadata: {})
p "Received bidi streamer call at method #{method}" \
GRPC.logger.info("Received bidi streamer call at method #{method}" \
"with requests #{requests} for call #{call}" \
" and metadata: #{metadata}"
" and metadata: #{metadata}")
requests.each do |r|
p "In client interceptor: #{r}"
GRPC.logger.info("In client interceptor: #{r}")
end
metadata['foo'] = 'bar_from_bidi_streamer'
yield

Loading…
Cancel
Save