diff options
author | ncteisen <ncteisen@gmail.com> | 2018-06-19 14:00:52 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-06-19 14:00:52 -0700 |
commit | 68d4f50f77641f80794134f0d4149034df1706f0 (patch) | |
tree | a8a6a2221c5b408e63d4c51b6cb9773ecca8e566 /src/ruby | |
parent | 4d1da600b525a514f0a5c1d768fa3a58d65ecded (diff) | |
parent | 9e3e64604d9a3bb4bea9202ede844e6f7b592eeb (diff) |
Merge branch 'master' of https://github.com/grpc/grpc into channelz
Diffstat (limited to 'src/ruby')
26 files changed, 78 insertions, 73 deletions
diff --git a/src/ruby/end2end/package_with_underscore_checker.rb b/src/ruby/end2end/package_with_underscore_checker.rb new file mode 100644 index 0000000000..27ea00ffa7 --- /dev/null +++ b/src/ruby/end2end/package_with_underscore_checker.rb @@ -0,0 +1,54 @@ +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'open3' +require 'tmpdir' + +def main + root_dir = File.join(File.dirname(__FILE__), '..', '..', '..') + pb_dir = File.join(root_dir, 'src', 'ruby', 'end2end', 'protos') + + fail 'CONFIG env variable unexpectedly unset' unless ENV['CONFIG'] + bins_sub_dir = ENV['CONFIG'] + bins_dir = File.join(root_dir, 'bins', bins_sub_dir) + + plugin = File.join(bins_dir, 'grpc_ruby_plugin') + protoc = File.join(bins_dir, 'protobuf', 'protoc') + + got = nil + + Dir.mktmpdir do |tmp_dir| + gen_out = File.join(tmp_dir, 'package_with_underscore', 'service_services_pb.rb') + + pid = spawn( + protoc, + "--proto_path=#{pb_dir}", + 'package_with_underscore/service.proto', + "--grpc_out=#{tmp_dir}", + "--plugin=protoc-gen-grpc=#{plugin}" + ) + Process.waitpid2(pid) + File.open(gen_out) { |f| got = f.read } + end + + correct_modularized_rpc = 'rpc :TestOne, ' \ + 'Grpc::Testing::PackageWithUnderscore::Data::Request, ' \ + 'Grpc::Testing::PackageWithUnderscore::Data::Response' + + return if got.include?(correct_modularized_rpc) + + fail 'generated file does not match with correct_modularized_rpc' +end + +main diff --git a/src/ruby/spec/pb/package_with_underscore/data.proto b/src/ruby/end2end/protos/package_with_underscore/data.proto index 2706f1d7be..2706f1d7be 100644 --- a/src/ruby/spec/pb/package_with_underscore/data.proto +++ b/src/ruby/end2end/protos/package_with_underscore/data.proto diff --git a/src/ruby/spec/pb/package_with_underscore/service.proto b/src/ruby/end2end/protos/package_with_underscore/service.proto index 814c7898cd..814c7898cd 100644 --- a/src/ruby/spec/pb/package_with_underscore/service.proto +++ b/src/ruby/end2end/protos/package_with_underscore/service.proto diff --git a/src/ruby/ext/grpc/rb_channel_credentials.c b/src/ruby/ext/grpc/rb_channel_credentials.c index b23a32caf1..178224c6e0 100644 --- a/src/ruby/ext/grpc/rb_channel_credentials.c +++ b/src/ruby/ext/grpc/rb_channel_credentials.c @@ -159,12 +159,12 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE* argv, pem_root_certs_cstr = RSTRING_PTR(pem_root_certs); } if (pem_private_key == Qnil && pem_cert_chain == Qnil) { - creds = grpc_ssl_credentials_create(pem_root_certs_cstr, NULL, NULL); + creds = grpc_ssl_credentials_create(pem_root_certs_cstr, NULL, NULL, NULL); } else { key_cert_pair.private_key = RSTRING_PTR(pem_private_key); key_cert_pair.cert_chain = RSTRING_PTR(pem_cert_chain); - creds = - grpc_ssl_credentials_create(pem_root_certs_cstr, &key_cert_pair, NULL); + creds = grpc_ssl_credentials_create(pem_root_certs_cstr, &key_cert_pair, + NULL, NULL); } if (creds == NULL) { rb_raise(rb_eRuntimeError, "could not create a credentials, not sure why"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 3cc6492d04..474405ae3f 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -311,7 +311,7 @@ extern grpc_google_default_credentials_create_type grpc_google_default_credentia typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb); extern grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import; #define grpc_set_ssl_roots_override_callback grpc_set_ssl_roots_override_callback_import -typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, void* reserved); +typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const verify_peer_options* verify_options, void* reserved); extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; #define grpc_ssl_credentials_create grpc_ssl_credentials_create_import typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds); diff --git a/src/ruby/spec/call_credentials_spec.rb b/src/ruby/spec/call_credentials_spec.rb index 86f30b46f1..d949ba2235 100644 --- a/src/ruby/spec/call_credentials_spec.rb +++ b/src/ruby/spec/call_credentials_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' describe GRPC::Core::CallCredentials do CallCredentials = GRPC::Core::CallCredentials diff --git a/src/ruby/spec/call_spec.rb b/src/ruby/spec/call_spec.rb index 1cc0500242..22d345f658 100644 --- a/src/ruby/spec/call_spec.rb +++ b/src/ruby/spec/call_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' include GRPC::Core::StatusCodes diff --git a/src/ruby/spec/channel_credentials_spec.rb b/src/ruby/spec/channel_credentials_spec.rb index e53f316208..b05e5aebf8 100644 --- a/src/ruby/spec/channel_credentials_spec.rb +++ b/src/ruby/spec/channel_credentials_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' describe GRPC::Core::ChannelCredentials do ChannelCredentials = GRPC::Core::ChannelCredentials diff --git a/src/ruby/spec/channel_spec.rb b/src/ruby/spec/channel_spec.rb index 5b2e355963..3c9eca47ec 100644 --- a/src/ruby/spec/channel_spec.rb +++ b/src/ruby/spec/channel_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' def load_test_certs test_root = File.join(File.dirname(__FILE__), 'testdata') diff --git a/src/ruby/spec/client_auth_spec.rb b/src/ruby/spec/client_auth_spec.rb index b955ad231e..c12ed2e0f4 100644 --- a/src/ruby/spec/client_auth_spec.rb +++ b/src/ruby/spec/client_auth_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' def create_channel_creds test_root = File.join(File.dirname(__FILE__), 'testdata') diff --git a/src/ruby/spec/client_server_spec.rb b/src/ruby/spec/client_server_spec.rb index afbfb0bc43..afde5073a6 100644 --- a/src/ruby/spec/client_server_spec.rb +++ b/src/ruby/spec/client_server_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' include GRPC::Core diff --git a/src/ruby/spec/compression_options_spec.rb b/src/ruby/spec/compression_options_spec.rb index 03c3cd9f07..05318e6686 100644 --- a/src/ruby/spec/compression_options_spec.rb +++ b/src/ruby/spec/compression_options_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' describe GRPC::Core::CompressionOptions do # Note these constants should be updated diff --git a/src/ruby/spec/error_sanity_spec.rb b/src/ruby/spec/error_sanity_spec.rb index b8f0638695..c36635ea26 100644 --- a/src/ruby/spec/error_sanity_spec.rb +++ b/src/ruby/spec/error_sanity_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' StatusCodes = GRPC::Core::StatusCodes diff --git a/src/ruby/spec/generic/client_stub_spec.rb b/src/ruby/spec/generic/client_stub_spec.rb index da50f8d0c9..3f878cc100 100644 --- a/src/ruby/spec/generic/client_stub_spec.rb +++ b/src/ruby/spec/generic/client_stub_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' Thread.abort_on_exception = true diff --git a/src/ruby/spec/generic/rpc_desc_spec.rb b/src/ruby/spec/generic/rpc_desc_spec.rb index 6852b9804f..b4ffe5eb92 100644 --- a/src/ruby/spec/generic/rpc_desc_spec.rb +++ b/src/ruby/spec/generic/rpc_desc_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' require 'grpc/generic/rpc_desc' describe GRPC::RpcDesc do diff --git a/src/ruby/spec/generic/rpc_server_pool_spec.rb b/src/ruby/spec/generic/rpc_server_pool_spec.rb index 27a42c82c1..0f2dac272e 100644 --- a/src/ruby/spec/generic/rpc_server_pool_spec.rb +++ b/src/ruby/spec/generic/rpc_server_pool_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' Thread.abort_on_exception = true diff --git a/src/ruby/spec/generic/service_spec.rb b/src/ruby/spec/generic/service_spec.rb index ad1c268d32..57aec89ce5 100644 --- a/src/ruby/spec/generic/service_spec.rb +++ b/src/ruby/spec/generic/service_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' require 'grpc/generic/rpc_desc' require 'grpc/generic/service' diff --git a/src/ruby/spec/google_rpc_status_utils_spec.rb b/src/ruby/spec/google_rpc_status_utils_spec.rb index 3263589b6a..1f67d3a916 100644 --- a/src/ruby/spec/google_rpc_status_utils_spec.rb +++ b/src/ruby/spec/google_rpc_status_utils_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' require_relative '../lib/grpc/google_rpc_status_utils' require_relative '../pb/src/proto/grpc/testing/messages_pb' require_relative '../pb/src/proto/grpc/testing/messages_pb' diff --git a/src/ruby/spec/pb/duplicate/codegen_spec.rb b/src/ruby/spec/pb/duplicate/codegen_spec.rb index 9f82858d15..fed7c1c8be 100644 --- a/src/ruby/spec/pb/duplicate/codegen_spec.rb +++ b/src/ruby/spec/pb/duplicate/codegen_spec.rb @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +require 'spec_helper' require 'open3' require 'tmpdir' diff --git a/src/ruby/spec/pb/health/checker_spec.rb b/src/ruby/spec/pb/health/checker_spec.rb index 58a602327c..84e63c2e54 100644 --- a/src/ruby/spec/pb/health/checker_spec.rb +++ b/src/ruby/spec/pb/health/checker_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' require 'grpc/health/v1/health_pb' require 'grpc/health/checker' require 'open3' diff --git a/src/ruby/spec/pb/package_with_underscore/checker_spec.rb b/src/ruby/spec/pb/package_with_underscore/checker_spec.rb deleted file mode 100644 index dac7c14a9a..0000000000 --- a/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2016 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require 'open3' -require 'tmpdir' - -describe 'Package with underscore protobuf code generation' do - it 'should have the same content as created by code generation' do - root_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..') - pb_dir = File.join(root_dir, 'src', 'ruby', 'spec', 'pb') - - fail 'CONFIG env variable unexpectedly unset' unless ENV['CONFIG'] - bins_sub_dir = ENV['CONFIG'] - bins_dir = File.join(root_dir, 'bins', bins_sub_dir) - - plugin = File.join(bins_dir, 'grpc_ruby_plugin') - protoc = File.join(bins_dir, 'protobuf', 'protoc') - - got = nil - - Dir.mktmpdir do |tmp_dir| - gen_out = File.join(tmp_dir, 'package_with_underscore', 'service_services_pb.rb') - - pid = spawn( - protoc, - '-I.', - 'package_with_underscore/service.proto', - "--grpc_out=#{tmp_dir}", - "--plugin=protoc-gen-grpc=#{plugin}", - chdir: pb_dir) - Process.waitpid2(pid) - File.open(gen_out) { |f| got = f.read } - end - - correct_modularized_rpc = 'rpc :TestOne, ' \ - 'Grpc::Testing::PackageWithUnderscore::Data::Request, ' \ - 'Grpc::Testing::PackageWithUnderscore::Data::Response' - expect(got).to include(correct_modularized_rpc) - end -end diff --git a/src/ruby/spec/server_credentials_spec.rb b/src/ruby/spec/server_credentials_spec.rb index 673d832f62..f773a5f701 100644 --- a/src/ruby/spec/server_credentials_spec.rb +++ b/src/ruby/spec/server_credentials_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' def load_test_certs test_root = File.join(File.dirname(__FILE__), 'testdata') diff --git a/src/ruby/spec/server_spec.rb b/src/ruby/spec/server_spec.rb index 6eaac5ded1..76038d8b8b 100644 --- a/src/ruby/spec/server_spec.rb +++ b/src/ruby/spec/server_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' def load_test_certs test_root = File.join(File.dirname(__FILE__), 'testdata') diff --git a/src/ruby/spec/spec_helper.rb b/src/ruby/spec/spec_helper.rb index 8fe9e6e808..8fe2c16b35 100644 --- a/src/ruby/spec/spec_helper.rb +++ b/src/ruby/spec/spec_helper.rb @@ -31,6 +31,7 @@ end if ENV['COVERAGE_NAME'] require 'rspec' require 'logging' require 'rspec/logging_helper' +require 'grpc' require_relative 'support/services' require_relative 'support/helpers' diff --git a/src/ruby/spec/support/services.rb b/src/ruby/spec/support/services.rb index 27cc8e61ac..27239cd66c 100644 --- a/src/ruby/spec/support/services.rb +++ b/src/ruby/spec/support/services.rb @@ -13,7 +13,7 @@ # limitations under the License. # Test stubs for various scenarios -require 'grpc' +require 'spec_helper' # A test message class EchoMsg diff --git a/src/ruby/spec/time_consts_spec.rb b/src/ruby/spec/time_consts_spec.rb index f7afe6b70a..41655ab106 100644 --- a/src/ruby/spec/time_consts_spec.rb +++ b/src/ruby/spec/time_consts_spec.rb @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'grpc' +require 'spec_helper' TimeConsts = GRPC::Core::TimeConsts |