diff options
Diffstat (limited to 'src/ruby/bin/interop')
10 files changed, 250 insertions, 166 deletions
diff --git a/src/ruby/bin/interop/interop_client.rb b/src/ruby/bin/interop/interop_client.rb index 6e7bfeef97..d0478bb4d1 100644 --- a/src/ruby/bin/interop/interop_client.rb +++ b/src/ruby/bin/interop/interop_client.rb @@ -47,9 +47,11 @@ require 'minitest' require 'minitest/assertions' require 'grpc' +require 'google/protobuf' -require 'third_party/stubby/testing/proto/test.pb' -require 'third_party/stubby/testing/proto/messages.pb' +require 'test/cpp/interop/test_services' +require 'test/cpp/interop/messages' +require 'test/cpp/interop/empty' # loads the certificates used to access the test server securely. def load_test_certs @@ -79,7 +81,7 @@ end # produces a string of null chars (\0) of length l. def nulls(l) raise 'requires #{l} to be +ve' if l < 0 - [].pack('x' * l) + [].pack('x' * l).force_encoding('utf-8') end # a PingPongPlayer implements the ping pong bidi test. @@ -105,10 +107,11 @@ class PingPongPlayer req_size, resp_size = m req = req_cls.new(:payload => Payload.new(:body => nulls(req_size)), :response_type => COMPRESSABLE, - :response_parameters => p_cls.new(:size => resp_size)) + :response_parameters => [p_cls.new(:size => resp_size)]) yield req resp = @queue.pop - assert_equal(COMPRESSABLE, resp.payload.type, 'payload type is wrong') + assert_equal(PayloadType.lookup(COMPRESSABLE), resp.payload.type, + 'payload type is wrong') assert_equal(resp_size, resp.payload.body.length, 'payload body #{i} has the wrong length') p "OK: ping_pong #{count}" @@ -132,10 +135,10 @@ class NamedTests # TESTING # PASSED # FAIL - # ruby server: fails beefcake throws on deserializing the 0-length message + # ruby server: fails protobuf-ruby can't pass an empty message def empty_unary - resp = @stub.empty_call(Proto2::Empty.new) - assert resp.is_a?(Proto::Empty), 'empty_unary: invalid response' + resp = @stub.empty_call(Empty.new) + assert resp.is_a?(Empty), 'empty_unary: invalid response' p 'OK: empty_unary' end @@ -186,7 +189,8 @@ class NamedTests resps = @stub.streaming_output_call(req) resps.each_with_index do |r, i| assert i < msg_sizes.length, 'too many responses' - assert_equal(COMPRESSABLE, r.payload.type, 'payload type is wrong') + assert_equal(PayloadType.lookup(COMPRESSABLE), r.payload.type, + 'payload type is wrong') assert_equal(msg_sizes[i], r.payload.body.length, 'payload body #{i} has the wrong length') end @@ -197,9 +201,6 @@ class NamedTests # PASSED # ruby server # FAILED - # - # TODO(temiola): update this test to stay consistent with the java test's - # interpretation of the test spec. def ping_pong msg_sizes = [[27182, 31415], [8, 9], [1828, 2653], [45904, 58979]] ppp = PingPongPlayer.new(msg_sizes) diff --git a/src/ruby/bin/interop/interop_server.rb b/src/ruby/bin/interop/interop_server.rb index 35d69f6fd3..53e271e80d 100644 --- a/src/ruby/bin/interop/interop_server.rb +++ b/src/ruby/bin/interop/interop_server.rb @@ -47,8 +47,9 @@ require 'optparse' require 'grpc' -require 'third_party/stubby/testing/proto/test.pb' -require 'third_party/stubby/testing/proto/messages.pb' +require 'test/cpp/interop/test_services' +require 'test/cpp/interop/messages' +require 'test/cpp/interop/empty' # loads the certificates by the test server. def load_test_certs @@ -67,7 +68,7 @@ end # produces a string of null chars (\0) of length l. def nulls(l) raise 'requires #{l} to be +ve' if l < 0 - [].pack('x' * l) + [].pack('x' * l).force_encoding('utf-8') end # A EnumeratorQueue wraps a Queue yielding the items added to it via each_item. @@ -98,7 +99,7 @@ class TestTarget < Grpc::Testing::TestService::Service include Grpc::Testing::PayloadType def empty_call(empty, call) - Proto::Empty.new + Empty.new end def unary_call(simple_req, call) diff --git a/src/ruby/bin/interop/net/proto2/bridge/proto/message_set.pb.rb b/src/ruby/bin/interop/net/proto2/bridge/proto/message_set.pb.rb deleted file mode 100755 index eadd1d4ceb..0000000000 --- a/src/ruby/bin/interop/net/proto2/bridge/proto/message_set.pb.rb +++ /dev/null @@ -1,14 +0,0 @@ -## Generated from net/proto2/bridge/proto/message_set.proto for proto2.bridge -require 'beefcake' - -module Proto2 - module Bridge - - class MessageSet - include Beefcake::Message - end - - class MessageSet - end - end -end diff --git a/src/ruby/bin/interop/net/proto2/proto/empty.pb.rb b/src/ruby/bin/interop/net/proto2/proto/empty.pb.rb deleted file mode 100755 index 2aa0c76509..0000000000 --- a/src/ruby/bin/interop/net/proto2/proto/empty.pb.rb +++ /dev/null @@ -1,12 +0,0 @@ -## Generated from net/proto2/proto/empty.proto for proto2 -require 'beefcake' - -module Proto2 - - class Empty - include Beefcake::Message - end - - class Empty - end -end diff --git a/src/ruby/bin/interop/test/cpp/interop/empty.rb b/src/ruby/bin/interop/test/cpp/interop/empty.rb new file mode 100644 index 0000000000..acd4160d24 --- /dev/null +++ b/src/ruby/bin/interop/test/cpp/interop/empty.rb @@ -0,0 +1,44 @@ +# Copyright 2014, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: test/cpp/interop/empty.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "grpc.testing.Empty" do + end +end + +module Grpc + module Testing + Empty = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Empty").msgclass + end +end diff --git a/src/ruby/bin/interop/test/cpp/interop/messages.rb b/src/ruby/bin/interop/test/cpp/interop/messages.rb new file mode 100644 index 0000000000..491608bff2 --- /dev/null +++ b/src/ruby/bin/interop/test/cpp/interop/messages.rb @@ -0,0 +1,86 @@ +# Copyright 2014, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: test/cpp/interop/messages.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "grpc.testing.Payload" do + optional :type, :enum, 1, "grpc.testing.PayloadType" + optional :body, :string, 2 + end + add_message "grpc.testing.SimpleRequest" do + optional :response_type, :enum, 1, "grpc.testing.PayloadType" + optional :response_size, :int32, 2 + optional :payload, :message, 3, "grpc.testing.Payload" + end + add_message "grpc.testing.SimpleResponse" do + optional :payload, :message, 1, "grpc.testing.Payload" + optional :effective_gaia_user_id, :int64, 2 + end + add_message "grpc.testing.StreamingInputCallRequest" do + optional :payload, :message, 1, "grpc.testing.Payload" + end + add_message "grpc.testing.StreamingInputCallResponse" do + optional :aggregated_payload_size, :int32, 1 + end + add_message "grpc.testing.ResponseParameters" do + optional :size, :int32, 1 + optional :interval_us, :int32, 2 + end + add_message "grpc.testing.StreamingOutputCallRequest" do + optional :response_type, :enum, 1, "grpc.testing.PayloadType" + repeated :response_parameters, :message, 2, "grpc.testing.ResponseParameters" + optional :payload, :message, 3, "grpc.testing.Payload" + end + add_message "grpc.testing.StreamingOutputCallResponse" do + optional :payload, :message, 1, "grpc.testing.Payload" + end + add_enum "grpc.testing.PayloadType" do + value :COMPRESSABLE, 0 + value :UNCOMPRESSABLE, 1 + value :RANDOM, 2 + end +end + +module Grpc + module Testing + Payload = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Payload").msgclass + SimpleRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.SimpleRequest").msgclass + SimpleResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.SimpleResponse").msgclass + StreamingInputCallRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingInputCallRequest").msgclass + StreamingInputCallResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingInputCallResponse").msgclass + ResponseParameters = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ResponseParameters").msgclass + StreamingOutputCallRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallRequest").msgclass + StreamingOutputCallResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallResponse").msgclass + PayloadType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PayloadType").enummodule + end +end diff --git a/src/ruby/bin/interop/test/cpp/interop/test.rb b/src/ruby/bin/interop/test/cpp/interop/test.rb new file mode 100644 index 0000000000..0b391ed6af --- /dev/null +++ b/src/ruby/bin/interop/test/cpp/interop/test.rb @@ -0,0 +1,43 @@ +# Copyright 2014, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: test/cpp/interop/test.proto + +require 'google/protobuf' + +require 'test/cpp/interop/empty' +require 'test/cpp/interop/messages' +Google::Protobuf::DescriptorPool.generated_pool.build do +end + +module Grpc + module Testing + end +end diff --git a/src/ruby/bin/interop/test/cpp/interop/test_services.rb b/src/ruby/bin/interop/test/cpp/interop/test_services.rb new file mode 100644 index 0000000000..464d5e24f6 --- /dev/null +++ b/src/ruby/bin/interop/test/cpp/interop/test_services.rb @@ -0,0 +1,59 @@ +# Copyright 2014, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: test/cpp/interop/test.proto for package 'grpc.testing' + +require 'grpc' +require 'test/cpp/interop/test' + +module Grpc + module Testing + module TestService + + # TODO: add proto service documentation here + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + + rpc :EmptyCall, Empty, Empty + rpc :UnaryCall, SimpleRequest, SimpleResponse + rpc :StreamingOutputCall, StreamingOutputCallRequest, stream(StreamingOutputCallResponse) + rpc :StreamingInputCall, stream(StreamingInputCallRequest), StreamingInputCallResponse + rpc :FullDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse) + rpc :HalfDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse) + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/src/ruby/bin/interop/third_party/stubby/testing/proto/messages.pb.rb b/src/ruby/bin/interop/third_party/stubby/testing/proto/messages.pb.rb deleted file mode 100755 index 9a913f93e5..0000000000 --- a/src/ruby/bin/interop/third_party/stubby/testing/proto/messages.pb.rb +++ /dev/null @@ -1,94 +0,0 @@ -## Generated from third_party/stubby/testing/proto/messages.proto for grpc.testing -require 'beefcake' - -require 'net/proto2/bridge/proto/message_set.pb' - -module Grpc - module Testing - - module PayloadType - COMPRESSABLE = 0 - UNCOMPRESSABLE = 1 - RANDOM = 2 - end - - class Payload - include Beefcake::Message - end - - class SimpleRequest - include Beefcake::Message - end - - class SimpleResponse - include Beefcake::Message - end - - class SimpleContext - include Beefcake::Message - end - - class StreamingInputCallRequest - include Beefcake::Message - end - - class StreamingInputCallResponse - include Beefcake::Message - end - - class ResponseParameters - include Beefcake::Message - end - - class StreamingOutputCallRequest - include Beefcake::Message - end - - class StreamingOutputCallResponse - include Beefcake::Message - end - - class Payload - optional :type, PayloadType, 1 - optional :body, :bytes, 2 - end - - class SimpleRequest - optional :response_type, PayloadType, 1 - optional :response_size, :int32, 2 - optional :payload, Payload, 3 - end - - class SimpleResponse - optional :payload, Payload, 1 - optional :effective_gaia_user_id, :int64, 2 - end - - class SimpleContext - optional :value, :string, 1 - end - - class StreamingInputCallRequest - optional :payload, Payload, 1 - end - - class StreamingInputCallResponse - optional :aggregated_payload_size, :int32, 1 - end - - class ResponseParameters - optional :size, :int32, 1 - optional :interval_us, :int32, 2 - end - - class StreamingOutputCallRequest - optional :response_type, PayloadType, 1 - repeated :response_parameters, ResponseParameters, 2 - optional :payload, Payload, 3 - end - - class StreamingOutputCallResponse - optional :payload, Payload, 1 - end - end -end diff --git a/src/ruby/bin/interop/third_party/stubby/testing/proto/test.pb.rb b/src/ruby/bin/interop/third_party/stubby/testing/proto/test.pb.rb deleted file mode 100755 index 2e21460fe6..0000000000 --- a/src/ruby/bin/interop/third_party/stubby/testing/proto/test.pb.rb +++ /dev/null @@ -1,30 +0,0 @@ -## Generated from third_party/stubby/testing/proto/test.proto for grpc.testing -require 'beefcake' -require 'grpc' - -require 'third_party/stubby/testing/proto/messages.pb' -require 'net/proto2/proto/empty.pb' - -module Grpc - module Testing - - module TestService - - class Service - include GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - - rpc :EmptyCall, Proto2::Empty, Proto2::Empty - rpc :UnaryCall, SimpleRequest, SimpleResponse - rpc :StreamingOutputCall, StreamingOutputCallRequest, stream(StreamingOutputCallResponse) - rpc :StreamingInputCall, stream(StreamingInputCallRequest), StreamingInputCallResponse - rpc :FullDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse) - rpc :HalfDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse) - end - Stub = Service.rpc_stub_class - - end - end -end |