diff options
author | ganmacs <ganmacs@gmail.com> | 2018-06-17 11:01:35 +0900 |
---|---|---|
committer | ganmacs <ganmacs@gmail.com> | 2018-09-19 19:06:46 +0900 |
commit | 50c31d18e5945b3bbcfa77abac8f805835c6f997 (patch) | |
tree | 5ec587b5c3245a449a9354185ff51715c4564de7 | |
parent | d177c8fe46c2550133199f71714c23ff0df8d38a (diff) |
Use logger to suppress output debug output during test
-rw-r--r-- | src/ruby/spec/client_auth_spec.rb | 10 | ||||
-rw-r--r-- | src/ruby/spec/generic/client_stub_spec.rb | 22 | ||||
-rw-r--r-- | src/ruby/spec/generic/rpc_server_spec.rb | 6 | ||||
-rw-r--r-- | src/ruby/spec/support/services.rb | 50 |
4 files changed, 49 insertions, 39 deletions
diff --git a/src/ruby/spec/client_auth_spec.rb b/src/ruby/spec/client_auth_spec.rb index c563ed3227..5d2e6d24ec 100644 --- a/src/ruby/spec/client_auth_spec.rb +++ b/src/ruby/spec/client_auth_spec.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 diff --git a/src/ruby/spec/generic/client_stub_spec.rb b/src/ruby/spec/generic/client_stub_spec.rb index fc50362ca5..200139d849 100644 --- a/src/ruby/spec/generic/client_stub_spec.rb +++ b/src/ruby/spec/generic/client_stub_spec.rb @@ -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 diff --git a/src/ruby/spec/generic/rpc_server_spec.rb b/src/ruby/spec/generic/rpc_server_spec.rb index e072d0c45f..44a6134086 100644 --- a/src/ruby/spec/generic/rpc_server_spec.rb +++ b/src/ruby/spec/generic/rpc_server_spec.rb @@ -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 diff --git a/src/ruby/spec/support/services.rb b/src/ruby/spec/support/services.rb index 27239cd66c..6e693f1cde 100644 --- a/src/ruby/spec/support/services.rb +++ b/src/ruby/spec/support/services.rb @@ -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 |