From ddaa69f15d8b3bb1a6bf9aff231950406fe5e961 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 Apr 2016 13:37:26 -0700 Subject: Got Ruby stress client working, with some modifications to interop tests --- src/ruby/pb/grpc/testing/metrics.rb | 28 ++++++++++++++++++++++++++++ src/ruby/pb/grpc/testing/metrics_services.rb | 27 +++++++++++++++++++++++++++ src/ruby/pb/test/client.rb | 28 +++++++--------------------- src/ruby/pb/test/server.rb | 2 +- 4 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 src/ruby/pb/grpc/testing/metrics.rb create mode 100644 src/ruby/pb/grpc/testing/metrics_services.rb (limited to 'src/ruby/pb') diff --git a/src/ruby/pb/grpc/testing/metrics.rb b/src/ruby/pb/grpc/testing/metrics.rb new file mode 100644 index 0000000000..3b3c8cd61b --- /dev/null +++ b/src/ruby/pb/grpc/testing/metrics.rb @@ -0,0 +1,28 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: grpc/testing/metrics.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "grpc.testing.GaugeResponse" do + optional :name, :string, 1 + oneof :value do + optional :long_value, :int64, 2 + optional :double_value, :double, 3 + optional :string_value, :string, 4 + end + end + add_message "grpc.testing.GaugeRequest" do + optional :name, :string, 1 + end + add_message "grpc.testing.EmptyMessage" do + end +end + +module Grpc + module Testing + GaugeResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.GaugeResponse").msgclass + GaugeRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.GaugeRequest").msgclass + EmptyMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.EmptyMessage").msgclass + end +end diff --git a/src/ruby/pb/grpc/testing/metrics_services.rb b/src/ruby/pb/grpc/testing/metrics_services.rb new file mode 100644 index 0000000000..f5778bbbb1 --- /dev/null +++ b/src/ruby/pb/grpc/testing/metrics_services.rb @@ -0,0 +1,27 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: grpc/testing/metrics.proto for package 'grpc.testing' + +require 'grpc' +require 'grpc/testing/metrics' + +module Grpc + module Testing + module MetricsService + + # TODO: add proto service documentation here + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'grpc.testing.MetricsService' + + rpc :GetAllGauges, EmptyMessage, stream(GaugeResponse) + rpc :GetGauge, GaugeRequest, GaugeResponse + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/src/ruby/pb/test/client.rb b/src/ruby/pb/test/client.rb index 695a5c4ea2..95b059a18e 100755 --- a/src/ruby/pb/test/client.rb +++ b/src/ruby/pb/test/client.rb @@ -38,23 +38,23 @@ # --server_port= \ # --test_case= +# These lines are required for the generated files to load grpc this_dir = File.expand_path(File.dirname(__FILE__)) lib_dir = File.join(File.dirname(File.dirname(this_dir)), 'lib') -pb_dir = File.dirname(File.dirname(this_dir)) +pb_dir = File.dirname(this_dir) $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) $LOAD_PATH.unshift(pb_dir) unless $LOAD_PATH.include?(pb_dir) -$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) require 'optparse' require 'logger' -require 'grpc' +require_relative '../../lib/grpc' require 'googleauth' require 'google/protobuf' -require 'test/proto/empty' -require 'test/proto/messages' -require 'test/proto/test_services' +require_relative 'proto/empty' +require_relative 'proto/messages' +require_relative 'proto/test_services' AUTH_ENV = Google::Auth::CredentialsLoader::ENV_VAR @@ -208,12 +208,10 @@ class NamedTests def empty_unary resp = @stub.empty_call(Empty.new) assert('empty_unary: invalid response') { resp.is_a?(Empty) } - p 'OK: empty_unary' end def large_unary perform_large_unary - p 'OK: large_unary' end def service_account_creds @@ -230,7 +228,6 @@ class NamedTests assert("#{__callee__}: bad oauth scope") do @args.oauth_scope.include?(resp.oauth_scope) end - p "OK: #{__callee__}" end def jwt_token_creds @@ -238,7 +235,6 @@ class NamedTests wanted_email = MultiJson.load(json_key)['client_email'] resp = perform_large_unary(fill_username: true) assert("#{__callee__}: bad username") { wanted_email == resp.username } - p "OK: #{__callee__}" end def compute_engine_creds @@ -247,7 +243,6 @@ class NamedTests assert("#{__callee__}: bad username") do @args.default_service_account == resp.username end - p "OK: #{__callee__}" end def oauth2_auth_token @@ -259,7 +254,6 @@ class NamedTests assert("#{__callee__}: bad oauth scope") do @args.oauth_scope.include?(resp.oauth_scope) end - p "OK: #{__callee__}" end def per_rpc_creds @@ -279,7 +273,6 @@ class NamedTests assert("#{__callee__}: bad oauth scope") do @args.oauth_scope.include?(resp.oauth_scope) end - p "OK: #{__callee__}" end def client_streaming @@ -293,7 +286,6 @@ class NamedTests assert("#{__callee__}: aggregate payload size is incorrect") do wanted_aggregate_size == resp.aggregated_payload_size end - p "OK: #{__callee__}" end def server_streaming @@ -311,7 +303,6 @@ class NamedTests :COMPRESSABLE == r.payload.type end end - p "OK: #{__callee__}" end def ping_pong @@ -319,7 +310,6 @@ class NamedTests ppp = PingPongPlayer.new(msg_sizes) resps = @stub.full_duplex_call(ppp.each_item) resps.each { |r| ppp.queue.push(r) } - p "OK: #{__callee__}" end def timeout_on_sleeping_server @@ -332,7 +322,6 @@ class NamedTests assert("#{__callee__}: status was wrong") do e.code == GRPC::Core::StatusCodes::DEADLINE_EXCEEDED end - p "OK: #{__callee__}" end def empty_stream @@ -346,7 +335,6 @@ class NamedTests assert("#{__callee__}: too many responses expected 0") do count == 0 end - p "OK: #{__callee__}" end def cancel_after_begin @@ -361,7 +349,6 @@ class NamedTests fail 'Should have raised GRPC:Cancelled' rescue GRPC::Cancelled assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled } - p "OK: #{__callee__}" end def cancel_after_first_response @@ -374,7 +361,6 @@ class NamedTests rescue GRPC::Cancelled assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled } op.wait - p "OK: #{__callee__}" end def all @@ -442,7 +428,7 @@ def parse_args opts.on('--use_tls USE_TLS', ['false', 'true'], 'require a secure connection?') do |v| args['secure'] = v == 'true' - end +p end opts.on('--use_test_ca USE_TEST_CA', ['false', 'true'], 'if secure, use the test certificate?') do |v| args['use_test_ca'] = v == 'true' diff --git a/src/ruby/pb/test/server.rb b/src/ruby/pb/test/server.rb index 851e815222..914c7cc79d 100755 --- a/src/ruby/pb/test/server.rb +++ b/src/ruby/pb/test/server.rb @@ -39,7 +39,7 @@ this_dir = File.expand_path(File.dirname(__FILE__)) lib_dir = File.join(File.dirname(File.dirname(this_dir)), 'lib') -pb_dir = File.dirname(File.dirname(this_dir)) +pb_dir = File.dirname(this_dir) $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) $LOAD_PATH.unshift(pb_dir) unless $LOAD_PATH.include?(pb_dir) $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) -- cgit v1.2.3