From aef398bd8811dd292bb90c69f73c6d7c6e918e69 Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 7 Mar 2017 15:43:53 -0800 Subject: Only cleanup the listeners when shutdown is set --- src/core/lib/iomgr/tcp_server_posix.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/core/lib/iomgr/tcp_server_posix.c b/src/core/lib/iomgr/tcp_server_posix.c index 36f878fdd4..ed9c9c56cf 100644 --- a/src/core/lib/iomgr/tcp_server_posix.c +++ b/src/core/lib/iomgr/tcp_server_posix.c @@ -258,10 +258,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { /* delete ALL the things */ gpr_mu_lock(&s->mu); - if (!s->shutdown) { - gpr_mu_unlock(&s->mu); - return; - } + GPR_ASSERT(s->shutdown); if (s->head) { grpc_tcp_listener *sp; @@ -465,7 +462,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) { error: gpr_mu_lock(&sp->server->mu); - if (0 == --sp->server->active_ports) { + if (0 == --sp->server->active_ports && sp->server->shutdown) { gpr_mu_unlock(&sp->server->mu); deactivated_all_ports(exec_ctx, sp->server); } else { -- cgit v1.2.3 From ffe1a99bb1653d63f6f6e140a90b87f02588de8e Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 9 Mar 2017 10:04:11 -0800 Subject: Switch Node back to using libuv iomgr by default --- binding.gyp | 8 +++----- templates/binding.gyp.template | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/binding.gyp b/binding.gyp index c521a27c30..178d9e952d 100644 --- a/binding.gyp +++ b/binding.gyp @@ -39,11 +39,9 @@ { 'variables': { 'runtime%': 'node', - # UV integration in C core is disabled by default while bugs are ironed - # out. It can be re-enabled for one build by setting the npm config - # variable grpc_uv to true, and it can be re-enabled permanently by - # setting it to true here. - 'grpc_uv%': 'false', + # UV integration in C core is enabled by default. It can be disabled + # by setting this argument to anything else. + 'grpc_uv%': 'true', # Some Node installations use the system installation of OpenSSL, and on # some systems, the system OpenSSL still does not have ALPN support. This # will let users recompile gRPC to work without ALPN. diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template index 5e401e8977..5f30d645fa 100644 --- a/templates/binding.gyp.template +++ b/templates/binding.gyp.template @@ -41,11 +41,9 @@ { 'variables': { 'runtime%': 'node', - # UV integration in C core is disabled by default while bugs are ironed - # out. It can be re-enabled for one build by setting the npm config - # variable grpc_uv to true, and it can be re-enabled permanently by - # setting it to true here. - 'grpc_uv%': 'false', + # UV integration in C core is enabled by default. It can be disabled + # by setting this argument to anything else. + 'grpc_uv%': 'true', # Some Node installations use the system installation of OpenSSL, and on # some systems, the system OpenSSL still does not have ALPN support. This # will let users recompile gRPC to work without ALPN. -- cgit v1.2.3 From 37d274a0c6a9424ad4d67072998197d60bf9bd83 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 Mar 2017 09:44:44 -0800 Subject: Node add service: allow exact match to name in proto file, improve error reporting --- src/node/src/common.js | 1 + src/node/src/server.js | 13 ++++++++++--- src/node/test/surface_test.js | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/node/src/common.js b/src/node/src/common.js index 98eabf5c0b..a0fe4480ea 100644 --- a/src/node/src/common.js +++ b/src/node/src/common.js @@ -149,6 +149,7 @@ exports.getProtobufServiceAttrs = function getProtobufServiceAttrs(service, return _.camelCase(method.name); }), _.map(service.children, function(method) { return { + originalName: method.name, path: prefix + method.name, requestStream: method.requestStream, responseStream: method.responseStream, diff --git a/src/node/src/server.js b/src/node/src/server.js index 8a7eff507d..3d06c07ab4 100644 --- a/src/node/src/server.js +++ b/src/node/src/server.js @@ -755,9 +755,16 @@ Server.prototype.addService = function(service, implementation) { } var impl; if (implementation[name] === undefined) { - common.log(grpc.logVerbosity.ERROR, 'Method handler for ' + - attrs.path + ' expected but not provided'); - impl = defaultHandler[method_type]; + /* Handle the case where the method is passed with the name exactly as + written in the proto file, instead of using JavaScript function + naming style */ + if (implementation[attrs.originalName] === undefined) { + common.log(grpc.logVerbosity.ERROR, 'Method handler ' + name + ' for ' + + attrs.path + ' expected but not provided'); + impl = defaultHandler[method_type]; + } else { + impl = _.bind(implementation[attrs.originalName], implementation); + } } else { impl = _.bind(implementation[name], implementation); } diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js index 2636ea85ac..1d739562a6 100644 --- a/src/node/test/surface_test.js +++ b/src/node/test/surface_test.js @@ -143,6 +143,32 @@ describe('Server.prototype.addProtoService', function() { server.addProtoService(mathService, dummyImpls); }); }); + it('Should allow method names as originally written', function() { + var altDummyImpls = { + 'Div': function() {}, + 'DivMany': function() {}, + 'Fib': function() {}, + 'Sum': function() {} + }; + assert.doesNotThrow(function() { + server.addProtoService(mathService, altDummyImpls); + }); + }); + it('Should have a conflict between name variations', function() { + /* This is really testing that both name variations are actually used, + by checking that the method actually gets registered, for the + corresponding function, in both cases */ + var altDummyImpls = { + 'Div': function() {}, + 'DivMany': function() {}, + 'Fib': function() {}, + 'Sum': function() {} + }; + server.addProtoService(mathService, altDummyImpls); + assert.throws(function() { + server.addProtoService(mathService, dummyImpls); + }); + }); it('Should fail if the server has been started', function() { server.start(); assert.throws(function() { -- cgit v1.2.3 From 78354300bfa7ff66d7ecc1c847fde22e932b7388 Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Mon, 6 Mar 2017 09:28:16 -0800 Subject: Add package details to gRPC Packages --- setup.py | 4 ++++ src/python/grpcio_health_checking/setup.py | 4 ++++ src/python/grpcio_reflection/setup.py | 4 ++++ tools/distrib/python/grpcio_tools/setup.py | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/setup.py b/setup.py index d5b843fdac..00694bddf1 100644 --- a/setup.py +++ b/setup.py @@ -265,6 +265,10 @@ PACKAGES = setuptools.find_packages(PYTHON_STEM) setuptools.setup( name='grpcio', version=grpc_version.VERSION, + description='HTTP/2-based RPC framework', + author='The gRPC Authors', + author_email='grpc-io@googlegroups.com', + url='http://www.grpc.io', license=LICENSE, long_description=open(README).read(), ext_modules=CYTHON_EXTENSION_MODULES, diff --git a/src/python/grpcio_health_checking/setup.py b/src/python/grpcio_health_checking/setup.py index 52ee98a2d5..17bb3ab616 100644 --- a/src/python/grpcio_health_checking/setup.py +++ b/src/python/grpcio_health_checking/setup.py @@ -59,6 +59,10 @@ COMMAND_CLASS = { setuptools.setup( name='grpcio-health-checking', version=grpc_version.VERSION, + description='Standard Health Checking Service for gRPC', + author='The gRPC Authors', + author_email='grpc-io@googlegroups.com', + url='http://www.grpc.io', license='3-clause BSD', package_dir=PACKAGE_DIRECTORIES, packages=setuptools.find_packages('.'), diff --git a/src/python/grpcio_reflection/setup.py b/src/python/grpcio_reflection/setup.py index e85092db57..e6cf54745e 100644 --- a/src/python/grpcio_reflection/setup.py +++ b/src/python/grpcio_reflection/setup.py @@ -60,6 +60,10 @@ setuptools.setup( name='grpcio-reflection', version=grpc_version.VERSION, license='3-clause BSD', + description='Standard Protobuf Reflection Service for gRPC', + author='The gRPC Authors', + author_email='grpc-io@googlegroups.com', + url='http://www.grpc.io', package_dir=PACKAGE_DIRECTORIES, packages=setuptools.find_packages('.'), install_requires=INSTALL_REQUIRES, diff --git a/tools/distrib/python/grpcio_tools/setup.py b/tools/distrib/python/grpcio_tools/setup.py index ed27f1f835..211d442f17 100644 --- a/tools/distrib/python/grpcio_tools/setup.py +++ b/tools/distrib/python/grpcio_tools/setup.py @@ -203,6 +203,10 @@ def extension_modules(): setuptools.setup( name='grpcio-tools', version=grpc_version.VERSION, + description='Protobuf code generator for gRPC', + author='The gRPC Authors', + author_email='grpc-io@googlegroups.com', + url='http://www.grpc.io', license='3-clause BSD', ext_modules=extension_modules(), packages=setuptools.find_packages('.'), -- cgit v1.2.3 From 6bd07c656b8d0170eb499e9ee61cf9ca827d59c9 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 10 Mar 2017 10:48:57 -0800 Subject: Stop gRPC timers from keeping the UV loop open --- src/core/lib/iomgr/timer_uv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/lib/iomgr/timer_uv.c b/src/core/lib/iomgr/timer_uv.c index f28a14405d..8e8a07578c 100644 --- a/src/core/lib/iomgr/timer_uv.c +++ b/src/core/lib/iomgr/timer_uv.c @@ -78,6 +78,10 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, uv_timer->data = timer; timer->uv_timer = uv_timer; uv_timer_start(uv_timer, run_expired_timer, timeout, 0); + /* We assume that gRPC timers are only used alongside other active gRPC + objects, and that there will therefore always be something else keeping + the uv loop alive whenever there is a timer */ + uv_unref((uv_handle_t *)uv_timer); } void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) { -- cgit v1.2.3 From e57cd90c11285c8643bbfd2fb778093129806ac9 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 2 Mar 2017 16:13:46 -0800 Subject: fix channel connectivity state function --- src/ruby/ext/grpc/rb_channel.c | 20 ++++++++++++-------- src/ruby/spec/channel_spec.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 84e43d3f7b..a284852500 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -175,19 +175,23 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { /* call-seq: - insecure_channel = Channel:new("myhost:8080", {'arg1': 'value1'}) - creds = ... - secure_channel = Channel:new("myhost:443", {'arg1': 'value1'}, creds) + ch.connectivity_state -> state + ch.connectivity_state(true) -> state - Creates channel instances. */ + Indicates the current state of the channel, whose value is one of the + constants defined in GRPC::Core::ConnectivityStates. + + It also tries to connect if the chennel is idle in the second form. */ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, VALUE self) { - VALUE try_to_connect = Qfalse; + VALUE try_to_connect_param = Qfalse; + int grpc_try_to_connect = 0; grpc_rb_channel *wrapper = NULL; grpc_channel *ch = NULL; /* "01" == 0 mandatory args, 1 (try_to_connect) is optional */ - rb_scan_args(argc, argv, "01", try_to_connect); + rb_scan_args(argc, argv, "01", &try_to_connect_param); + grpc_try_to_connect = try_to_connect_param == Qtrue? 1 : 0; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); ch = wrapper->wrapped; @@ -195,8 +199,8 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, rb_raise(rb_eRuntimeError, "closed!"); return Qnil; } - return NUM2LONG( - grpc_channel_check_connectivity_state(ch, (int)try_to_connect)); + return LONG2NUM( + grpc_channel_check_connectivity_state(ch, grpc_try_to_connect)); } /* Watch for a change in connectivity state. diff --git a/src/ruby/spec/channel_spec.rb b/src/ruby/spec/channel_spec.rb index 740eac631a..a289a00f04 100644 --- a/src/ruby/spec/channel_spec.rb +++ b/src/ruby/spec/channel_spec.rb @@ -153,6 +153,35 @@ describe GRPC::Core::Channel do end end + describe '#connectivity_state' do + it 'returns an enum' do + ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure) + valid_states = [ + GRPC::Core::ConnectivityStates::IDLE, + GRPC::Core::ConnectivityStates::CONNECTING, + GRPC::Core::ConnectivityStates::READY, + GRPC::Core::ConnectivityStates::TRANSIENT_FAILURE, + GRPC::Core::ConnectivityStates::FATAL_FAILURE + ] + + expect(valid_states).to include(ch.connectivity_state) + end + + it 'returns an enum when trying to connect' do + ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure) + ch.connectivity_state(true) + valid_states = [ + GRPC::Core::ConnectivityStates::IDLE, + GRPC::Core::ConnectivityStates::CONNECTING, + GRPC::Core::ConnectivityStates::READY, + GRPC::Core::ConnectivityStates::TRANSIENT_FAILURE, + GRPC::Core::ConnectivityStates::FATAL_FAILURE + ] + + expect(valid_states).to include(ch.connectivity_state) + end + end + describe '::SSL_TARGET' do it 'is a symbol' do expect(GRPC::Core::Channel::SSL_TARGET).to be_a(Symbol) -- cgit v1.2.3 From 9f4986603caec7ff569158ed07d9c201dbc00ccb Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 2 Mar 2017 19:20:07 -0800 Subject: add in background connectivity state poller --- src/ruby/ext/grpc/rb_channel.c | 219 +++++++++++++++++++++++++------ src/ruby/spec/channel_connection_spec.rb | 93 +++++++++++++ 2 files changed, 271 insertions(+), 41 deletions(-) create mode 100644 src/ruby/spec/channel_connection_spec.rb diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index a284852500..ccdca15c98 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -32,21 +32,21 @@ */ #include +#include -#include "rb_grpc_imports.generated.h" -#include "rb_channel.h" #include "rb_byte_buffer.h" +#include "rb_channel.h" #include #include #include #include #include -#include "rb_grpc.h" #include "rb_call.h" #include "rb_channel_args.h" #include "rb_channel_credentials.h" #include "rb_completion_queue.h" +#include "rb_grpc.h" #include "rb_server.h" /* id_channel is the name of the hidden ivar that preserves a reference to the @@ -74,8 +74,22 @@ typedef struct grpc_rb_channel { /* The actual channel */ grpc_channel *wrapped; grpc_completion_queue *queue; + int request_safe_destroy; + int safe_to_destroy; + gpr_mu safe_destroy_mu; + gpr_cv safe_destroy_cv; } grpc_rb_channel; +/* Forward declarations of functions involved in temporary fix to + * https://github.com/grpc/grpc/issues/9941 */ +static void grpc_rb_channel_try_register_connection_polling( + grpc_rb_channel *wrapper); +static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper); + +static grpc_completion_queue *channel_polling_cq; +static gpr_mu channel_polling_mu; +static int abort_channel_polling = 0; + /* Destroys Channel instances. */ static void grpc_rb_channel_free(void *p) { grpc_rb_channel *ch = NULL; @@ -85,8 +99,9 @@ static void grpc_rb_channel_free(void *p) { ch = (grpc_rb_channel *)p; if (ch->wrapped != NULL) { - grpc_channel_destroy(ch->wrapped); + grpc_rb_channel_safe_destroy(ch); grpc_rb_completion_queue_destroy(ch->queue); + ch->wrapped = NULL; } xfree(p); @@ -104,13 +119,15 @@ static void grpc_rb_channel_mark(void *p) { } } -static rb_data_type_t grpc_channel_data_type = { - "grpc_channel", - {grpc_rb_channel_mark, grpc_rb_channel_free, GRPC_RB_MEMSIZE_UNAVAILABLE, - {NULL, NULL}}, - NULL, NULL, +static rb_data_type_t grpc_channel_data_type = {"grpc_channel", + {grpc_rb_channel_mark, + grpc_rb_channel_free, + GRPC_RB_MEMSIZE_UNAVAILABLE, + {NULL, NULL}}, + NULL, + NULL, #ifdef RUBY_TYPED_FREE_IMMEDIATELY - RUBY_TYPED_FREE_IMMEDIATELY + RUBY_TYPED_FREE_IMMEDIATELY #endif }; @@ -159,6 +176,18 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { creds = grpc_rb_get_wrapped_channel_credentials(credentials); ch = grpc_secure_channel_create(creds, target_chars, &args, NULL); } + + GPR_ASSERT(ch); + + wrapper->wrapped = ch; + gpr_mu_init(&wrapper->safe_destroy_mu); + gpr_cv_init(&wrapper->safe_destroy_cv); + gpr_mu_lock(&wrapper->safe_destroy_mu); + wrapper->safe_to_destroy = 0; + wrapper->request_safe_destroy = 0; + gpr_mu_unlock(&wrapper->safe_destroy_mu); + grpc_rb_channel_try_register_connection_polling(wrapper); + if (args.args != NULL) { xfree(args.args); /* Allocated by grpc_rb_hash_convert_to_channel_args */ } @@ -191,7 +220,7 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, /* "01" == 0 mandatory args, 1 (try_to_connect) is optional */ rb_scan_args(argc, argv, "01", &try_to_connect_param); - grpc_try_to_connect = try_to_connect_param == Qtrue? 1 : 0; + grpc_try_to_connect = try_to_connect_param == Qtrue ? 1 : 0; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); ch = wrapper->wrapped; @@ -229,14 +258,11 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, return Qnil; } grpc_channel_watch_connectivity_state( - ch, - (grpc_connectivity_state)NUM2LONG(last_state), - grpc_rb_time_timeval(deadline, /* absolute time */ 0), - cq, - tag); + ch, (grpc_connectivity_state)NUM2LONG(last_state), + grpc_rb_time_timeval(deadline, /* absolute time */ 0), cq, tag); - event = rb_completion_queue_pluck(cq, tag, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + event = rb_completion_queue_pluck(cq, tag, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); if (event.success) { return Qtrue; @@ -247,9 +273,9 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, /* Create a call given a grpc_channel, in order to call method. The request is not sent until grpc_call_invoke is called. */ -static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, - VALUE mask, VALUE method, - VALUE host, VALUE deadline) { +static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask, + VALUE method, VALUE host, + VALUE deadline) { VALUE res = Qnil; grpc_rb_channel *wrapper = NULL; grpc_call *call = NULL; @@ -260,10 +286,11 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, grpc_slice method_slice; grpc_slice host_slice; grpc_slice *host_slice_ptr = NULL; - char* tmp_str = NULL; + char *tmp_str = NULL; if (host != Qnil) { - host_slice = grpc_slice_from_copied_buffer(RSTRING_PTR(host), RSTRING_LEN(host)); + host_slice = + grpc_slice_from_copied_buffer(RSTRING_PTR(host), RSTRING_LEN(host)); host_slice_ptr = &host_slice; } if (mask != Qnil) { @@ -281,17 +308,18 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, return Qnil; } - method_slice = grpc_slice_from_copied_buffer(RSTRING_PTR(method), RSTRING_LEN(method)); + method_slice = + grpc_slice_from_copied_buffer(RSTRING_PTR(method), RSTRING_LEN(method)); call = grpc_channel_create_call(ch, parent_call, flags, cq, method_slice, - host_slice_ptr, grpc_rb_time_timeval( - deadline, - /* absolute time */ 0), NULL); + host_slice_ptr, + grpc_rb_time_timeval(deadline, + /* absolute time */ 0), + NULL); if (call == NULL) { tmp_str = grpc_slice_to_c_string(method_slice); - rb_raise(rb_eRuntimeError, "cannot create call with method %s", - tmp_str); + rb_raise(rb_eRuntimeError, "cannot create call with method %s", tmp_str); return Qnil; } @@ -308,7 +336,6 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, return res; } - /* Closes the channel, calling it's destroy method */ static VALUE grpc_rb_channel_destroy(VALUE self) { grpc_rb_channel *wrapper = NULL; @@ -317,19 +344,20 @@ static VALUE grpc_rb_channel_destroy(VALUE self) { TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); ch = wrapper->wrapped; if (ch != NULL) { - grpc_channel_destroy(ch); + grpc_rb_channel_safe_destroy(wrapper); + GPR_ASSERT(wrapper->queue != NULL); + grpc_rb_completion_queue_destroy(wrapper->queue); wrapper->wrapped = NULL; } return Qnil; } - /* Called to obtain the target that this channel accesses. */ static VALUE grpc_rb_channel_get_target(VALUE self) { grpc_rb_channel *wrapper = NULL; VALUE res = Qnil; - char* target = NULL; + char *target = NULL; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); target = grpc_channel_get_target(wrapper->wrapped); @@ -339,10 +367,119 @@ static VALUE grpc_rb_channel_get_target(VALUE self) { return res; } +// Either start polling channel connection state or signal that it's free to +// destroy. +// Not safe to call while a channel's connection state is polled. +static void grpc_rb_channel_try_register_connection_polling( + grpc_rb_channel *wrapper) { + grpc_connectivity_state conn_state; + gpr_timespec sleep_time = gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); + + GPR_ASSERT(wrapper); + GPR_ASSERT(wrapper->wrapped); + gpr_mu_lock(&wrapper->safe_destroy_mu); + if (wrapper->request_safe_destroy) { + wrapper->safe_to_destroy = 1; + gpr_cv_signal(&wrapper->safe_destroy_cv); + gpr_mu_unlock(&wrapper->safe_destroy_mu); + return; + } + gpr_mu_lock(&channel_polling_mu); + conn_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); + // avoid posting work to the channel polling cq if it's been shutdown + if (!abort_channel_polling && conn_state != GRPC_CHANNEL_SHUTDOWN) { + grpc_channel_watch_connectivity_state( + wrapper->wrapped, conn_state, sleep_time, channel_polling_cq, wrapper); + } else { + wrapper->safe_to_destroy = 1; + gpr_cv_signal(&wrapper->safe_destroy_cv); + } + gpr_mu_unlock(&channel_polling_mu); + gpr_mu_unlock(&wrapper->safe_destroy_mu); +} + +// Note requires wrapper->wrapped, wrapper->safe_destroy_mu/cv initialized +static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper) { + gpr_mu_lock(&wrapper->safe_destroy_mu); + if (!wrapper->safe_to_destroy) { + wrapper->request_safe_destroy = 1; + gpr_cv_wait(&wrapper->safe_destroy_cv, &wrapper->safe_destroy_mu, + gpr_inf_future(GPR_CLOCK_REALTIME)); + } + GPR_ASSERT(wrapper->safe_to_destroy); + gpr_mu_unlock(&wrapper->safe_destroy_mu); + + gpr_mu_destroy(&wrapper->safe_destroy_mu); + gpr_cv_destroy(&wrapper->safe_destroy_cv); + + grpc_channel_destroy(wrapper->wrapped); +} + +// Note this loop breaks out when a single call of +// "grpc_rb_event_unblocking_func". +// TODO (apolcyn) does a ruby call to the unblocking func +// necesarily mean process shutdown? +// In the worst case, this stops polling channel connectivity +// early and falls back to current behavior. +static void *run_poll_channels_loop_no_gil(void *arg) { + grpc_event event; + grpc_rb_channel *wrapper; + (void)arg; + for (;;) { + event = grpc_completion_queue_next( + channel_polling_cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + if (event.type == GRPC_QUEUE_SHUTDOWN) { + // TODO (apolcyn) is it guaranteed that this cq is empty by now? + break; + } + if (event.type == GRPC_OP_COMPLETE) { + wrapper = (grpc_rb_channel *)event.tag; + grpc_rb_channel_try_register_connection_polling(wrapper); + } + } + grpc_completion_queue_destroy(channel_polling_cq); + return NULL; +} + +// Notify the channel polling loop to cleanup and shutdown. +static void grpc_rb_event_unblocking_func(void *arg) { + (void)arg; + gpr_mu_lock(&channel_polling_mu); + abort_channel_polling = 1; + grpc_completion_queue_shutdown(channel_polling_cq); + gpr_mu_unlock(&channel_polling_mu); +} + +// Poll channel connectivity states in background thread without the GIL. +static VALUE run_poll_channels_loop(VALUE arg) { + (void)arg; + rb_thread_call_without_gvl(run_poll_channels_loop_no_gil, NULL, + grpc_rb_event_unblocking_func, NULL); + return Qnil; +} + +/* Temporary fix for + * https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues/899. + * Transports in idle channels can get destroyed. Normally c-core re-connects, + * but in grpc-ruby core never gets a thread until an RPC is made, because ruby + * only calls c-core's "completion_queu_pluck" API. + * This uses a global background thread that calls + * "completion_queue_next" on registered "watch_channel_connectivity_state" + * calls - so that c-core can reconnect if needed, when there aren't any RPC's. + * TODO(apolcyn) remove this when core handles new RPCs on dead connections. + */ +static void start_poll_channels_loop() { + channel_polling_cq = grpc_completion_queue_create(NULL); + gpr_mu_init(&channel_polling_mu); + abort_channel_polling = 0; + rb_thread_create(run_poll_channels_loop, NULL); +} + static void Init_grpc_propagate_masks() { /* Constants representing call propagation masks in grpc.h */ - VALUE grpc_rb_mPropagateMasks = rb_define_module_under( - grpc_rb_mGrpcCore, "PropagateMasks"); + VALUE grpc_rb_mPropagateMasks = + rb_define_module_under(grpc_rb_mGrpcCore, "PropagateMasks"); rb_define_const(grpc_rb_mPropagateMasks, "DEADLINE", UINT2NUM(GRPC_PROPAGATE_DEADLINE)); rb_define_const(grpc_rb_mPropagateMasks, "CENSUS_STATS_CONTEXT", @@ -357,8 +494,8 @@ static void Init_grpc_propagate_masks() { static void Init_grpc_connectivity_states() { /* Constants representing call propagation masks in grpc.h */ - VALUE grpc_rb_mConnectivityStates = rb_define_module_under( - grpc_rb_mGrpcCore, "ConnectivityStates"); + VALUE grpc_rb_mConnectivityStates = + rb_define_module_under(grpc_rb_mGrpcCore, "ConnectivityStates"); rb_define_const(grpc_rb_mConnectivityStates, "IDLE", LONG2NUM(GRPC_CHANNEL_IDLE)); rb_define_const(grpc_rb_mConnectivityStates, "CONNECTING", @@ -386,12 +523,11 @@ void Init_grpc_channel() { /* Add ruby analogues of the Channel methods. */ rb_define_method(grpc_rb_cChannel, "connectivity_state", - grpc_rb_channel_get_connectivity_state, - -1); + grpc_rb_channel_get_connectivity_state, -1); rb_define_method(grpc_rb_cChannel, "watch_connectivity_state", grpc_rb_channel_watch_connectivity_state, 4); - rb_define_method(grpc_rb_cChannel, "create_call", - grpc_rb_channel_create_call, 5); + rb_define_method(grpc_rb_cChannel, "create_call", grpc_rb_channel_create_call, + 5); rb_define_method(grpc_rb_cChannel, "target", grpc_rb_channel_get_target, 0); rb_define_method(grpc_rb_cChannel, "destroy", grpc_rb_channel_destroy, 0); rb_define_alias(grpc_rb_cChannel, "close", "destroy"); @@ -409,6 +545,7 @@ void Init_grpc_channel() { id_insecure_channel = rb_intern("this_channel_is_insecure"); Init_grpc_propagate_masks(); Init_grpc_connectivity_states(); + start_poll_channels_loop(); } /* Gets the wrapped channel from the ruby wrapper */ diff --git a/src/ruby/spec/channel_connection_spec.rb b/src/ruby/spec/channel_connection_spec.rb new file mode 100644 index 0000000000..58ab37d7bc --- /dev/null +++ b/src/ruby/spec/channel_connection_spec.rb @@ -0,0 +1,93 @@ +# Copyright 2015, 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. + +require 'grpc' + +# A test message +class EchoMsg + def self.marshal(_o) + '' + end + + def self.unmarshal(_o) + EchoMsg.new + end +end + +# A test service with an echo implementation. +class EchoService + include GRPC::GenericService + rpc :an_rpc, EchoMsg, EchoMsg + attr_reader :received_md + + def initialize(**kw) + @trailing_metadata = kw + @received_md = [] + end + + def an_rpc(req, call) + GRPC.logger.info('echo service received a request') + call.output_metadata.update(@trailing_metadata) + @received_md << call.metadata unless call.metadata.nil? + req + end +end + +EchoStub = EchoService.rpc_stub_class + +def start_server(port = 0) + @srv = GRPC::RpcServer.new + server_port = @srv.add_http2_port("0.0.0.0:#{port}", :this_port_is_insecure) + @srv.handle(EchoService) + @server_thd = Thread.new { @srv.run } + @srv.wait_till_running + server_port +end + +def stop_server + expect(@srv.stopped?).to be(false) + @srv.stop + @server_thd.join + expect(@srv.stopped?).to be(true) +end + +describe 'channel connection behavior' do + it 'the client channel handles temporary loss of a transport' do + port = start_server + stub = EchoStub.new("localhost:#{port}", :this_channel_is_insecure) + req = EchoMsg.new + expect(stub.an_rpc(req)).to be_a(EchoMsg) + stop_server + expect { stub.an_rpc(req) }.to raise_error(GRPC::Unavailable) + # TODO(apolcyn) grabbing the same port might fail, is this stable enough? + start_server(port) + expect(stub.an_rpc(req)).to be_a(EchoMsg) + stop_server + end +end -- cgit v1.2.3 From 89d62d30612433770f85ba4fafb348e0cb990d8a Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 9 Mar 2017 13:28:03 -0800 Subject: debug print in docker file --- third_party/rake-compiler-dock/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/rake-compiler-dock/Dockerfile b/third_party/rake-compiler-dock/Dockerfile index 475c6a8d3d..ad902dfe66 100644 --- a/third_party/rake-compiler-dock/Dockerfile +++ b/third_party/rake-compiler-dock/Dockerfile @@ -169,6 +169,8 @@ RUN bash -c " \ USER root +RUN echo "HERE IS VERSION OF LINUX KERNEL USED: $(uname -r)" + # Fix paths in rake-compiler/config.yml and add rvm and mingw-tools to the global bashrc RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml && \ echo "source /etc/profile.d/rvm.sh" >> /etc/bash.bashrc && \ -- cgit v1.2.3 From b7e1f535f3af352dfb708fd3261314f3333a70f1 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Fri, 10 Mar 2017 10:37:06 -0800 Subject: revert changes to rake-compiler-dock dockerfile --- third_party/rake-compiler-dock/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/third_party/rake-compiler-dock/Dockerfile b/third_party/rake-compiler-dock/Dockerfile index ad902dfe66..475c6a8d3d 100644 --- a/third_party/rake-compiler-dock/Dockerfile +++ b/third_party/rake-compiler-dock/Dockerfile @@ -169,8 +169,6 @@ RUN bash -c " \ USER root -RUN echo "HERE IS VERSION OF LINUX KERNEL USED: $(uname -r)" - # Fix paths in rake-compiler/config.yml and add rvm and mingw-tools to the global bashrc RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml && \ echo "source /etc/profile.d/rvm.sh" >> /etc/bash.bashrc && \ -- cgit v1.2.3 From 181085694d86fdd3ee59675a96f89283b9f942ad Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Mar 2017 11:21:48 +0100 Subject: deprecate ChannelOptions.MaxMessageSize --- src/csharp/Grpc.Core/ChannelOptions.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/csharp/Grpc.Core/ChannelOptions.cs b/src/csharp/Grpc.Core/ChannelOptions.cs index b6eeceabc4..46a2c6695f 100644 --- a/src/csharp/Grpc.Core/ChannelOptions.cs +++ b/src/csharp/Grpc.Core/ChannelOptions.cs @@ -151,7 +151,14 @@ namespace Grpc.Core public const string MaxConcurrentStreams = "grpc.max_concurrent_streams"; /// Maximum message length that the channel can receive - public const string MaxMessageLength = "grpc.max_message_length"; + public const string MaxReceiveMessageLength = "grpc.max_receive_message_length"; + + /// Maximum message length that the channel can send + public const string MaxSendMessageLength = "grpc.max_send_message_length"; + + /// Obsolete, for backward compatibility only. + [Obsolete("Use MaxReceiveMessageLength instead.")] + public const string MaxMessageLength = MaxReceiveMessageLength; /// Initial sequence number for http2 transports public const string Http2InitialSequenceNumber = "grpc.http2.initial_sequence_number"; -- cgit v1.2.3 From 69719089da708a4630a792131e8cf1ee579e15d5 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 13 Mar 2017 12:00:42 -0700 Subject: remove a TODO --- src/ruby/ext/grpc/rb_channel.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index ccdca15c98..9a3f82c2b7 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -416,10 +416,10 @@ static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper) { grpc_channel_destroy(wrapper->wrapped); } -// Note this loop breaks out when a single call of +// Note this loop breaks out with a single call of // "grpc_rb_event_unblocking_func". -// TODO (apolcyn) does a ruby call to the unblocking func -// necesarily mean process shutdown? +// This assumes that a ruby call the unblocking func +// indicates process shutdown. // In the worst case, this stops polling channel connectivity // early and falls back to current behavior. static void *run_poll_channels_loop_no_gil(void *arg) { @@ -430,7 +430,6 @@ static void *run_poll_channels_loop_no_gil(void *arg) { event = grpc_completion_queue_next( channel_polling_cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); if (event.type == GRPC_QUEUE_SHUTDOWN) { - // TODO (apolcyn) is it guaranteed that this cq is empty by now? break; } if (event.type == GRPC_OP_COMPLETE) { -- cgit v1.2.3 From 55bff48335809baaab083bbf1189c3ab69a65f2b Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Mon, 13 Mar 2017 13:09:43 -0700 Subject: PHP: proto3 API change --- src/php/lib/Grpc/AbstractCall.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php index 40387abdc0..4833fdc7b6 100644 --- a/src/php/lib/Grpc/AbstractCall.php +++ b/src/php/lib/Grpc/AbstractCall.php @@ -131,6 +131,8 @@ abstract class AbstractCall // Proto3 implementation if (method_exists($data, 'encode')) { return $data->encode(); + } else if (method_exists($data, 'serializeToString')) { + return $data->serializeToString(); } // Protobuf-PHP implementation @@ -154,7 +156,11 @@ abstract class AbstractCall if (is_array($this->deserialize)) { list($className, $deserializeFunc) = $this->deserialize; $obj = new $className(); - $obj->$deserializeFunc($value); + if (method_exists($obj, $deserializeFunc)) { + $obj->$deserializeFunc($value); + } else { + $obj->mergeFromString($value); + } return $obj; } -- cgit v1.2.3 From 427ec5e433e006b7095e68029f5e99a6b11ce962 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 13 Mar 2017 17:57:47 -0700 Subject: change if to while to avoid unsafe wakeup --- src/ruby/ext/grpc/rb_channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 9a3f82c2b7..2489ec2fef 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -402,7 +402,7 @@ static void grpc_rb_channel_try_register_connection_polling( // Note requires wrapper->wrapped, wrapper->safe_destroy_mu/cv initialized static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper) { gpr_mu_lock(&wrapper->safe_destroy_mu); - if (!wrapper->safe_to_destroy) { + while (!wrapper->safe_to_destroy) { wrapper->request_safe_destroy = 1; gpr_cv_wait(&wrapper->safe_destroy_cv, &wrapper->safe_destroy_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); -- cgit v1.2.3 From 482e2d2010628d34e114639aef1205fc00ea3e06 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 14 Mar 2017 09:25:11 +0100 Subject: prevent name clashes in C# generated code --- src/compiler/csharp_generator.cc | 77 ++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index cc7a7a96ae..ce1e6b94c3 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -203,13 +203,13 @@ std::string GetServerClassName(const ServiceDescriptor *service) { std::string GetCSharpMethodType(MethodType method_type) { switch (method_type) { case METHODTYPE_NO_STREAMING: - return "MethodType.Unary"; + return "grpc::MethodType.Unary"; case METHODTYPE_CLIENT_STREAMING: - return "MethodType.ClientStreaming"; + return "grpc::MethodType.ClientStreaming"; case METHODTYPE_SERVER_STREAMING: - return "MethodType.ServerStreaming"; + return "grpc::MethodType.ServerStreaming"; case METHODTYPE_BIDI_STREAMING: - return "MethodType.DuplexStreaming"; + return "grpc::MethodType.DuplexStreaming"; } GOOGLE_LOG(FATAL) << "Can't get here."; return ""; @@ -243,16 +243,19 @@ std::string GetAccessLevel(bool internal_access) { std::string GetMethodReturnTypeClient(const MethodDescriptor *method) { switch (GetMethodType(method)) { case METHODTYPE_NO_STREAMING: - return "AsyncUnaryCall<" + GetClassName(method->output_type()) + ">"; + return "grpc::AsyncUnaryCall<" + GetClassName(method->output_type()) + + ">"; case METHODTYPE_CLIENT_STREAMING: - return "AsyncClientStreamingCall<" + GetClassName(method->input_type()) + - ", " + GetClassName(method->output_type()) + ">"; + return "grpc::AsyncClientStreamingCall<" + + GetClassName(method->input_type()) + ", " + + GetClassName(method->output_type()) + ">"; case METHODTYPE_SERVER_STREAMING: - return "AsyncServerStreamingCall<" + GetClassName(method->output_type()) + - ">"; + return "grpc::AsyncServerStreamingCall<" + + GetClassName(method->output_type()) + ">"; case METHODTYPE_BIDI_STREAMING: - return "AsyncDuplexStreamingCall<" + GetClassName(method->input_type()) + - ", " + GetClassName(method->output_type()) + ">"; + return "grpc::AsyncDuplexStreamingCall<" + + GetClassName(method->input_type()) + ", " + + GetClassName(method->output_type()) + ">"; } GOOGLE_LOG(FATAL) << "Can't get here."; return ""; @@ -265,7 +268,7 @@ std::string GetMethodRequestParamServer(const MethodDescriptor *method) { return GetClassName(method->input_type()) + " request"; case METHODTYPE_CLIENT_STREAMING: case METHODTYPE_BIDI_STREAMING: - return "IAsyncStreamReader<" + GetClassName(method->input_type()) + + return "grpc::IAsyncStreamReader<" + GetClassName(method->input_type()) + "> requestStream"; } GOOGLE_LOG(FATAL) << "Can't get here."; @@ -293,8 +296,8 @@ std::string GetMethodResponseStreamMaybe(const MethodDescriptor *method) { return ""; case METHODTYPE_SERVER_STREAMING: case METHODTYPE_BIDI_STREAMING: - return ", IServerStreamWriter<" + GetClassName(method->output_type()) + - "> responseStream"; + return ", grpc::IServerStreamWriter<" + + GetClassName(method->output_type()) + "> responseStream"; } GOOGLE_LOG(FATAL) << "Can't get here."; return ""; @@ -325,8 +328,8 @@ void GenerateMarshallerFields(Printer *out, const ServiceDescriptor *service) { for (size_t i = 0; i < used_messages.size(); i++) { const Descriptor *message = used_messages[i]; out->Print( - "static readonly Marshaller<$type$> $fieldname$ = " - "Marshallers.Create((arg) => " + "static readonly grpc::Marshaller<$type$> $fieldname$ = " + "grpc::Marshallers.Create((arg) => " "global::Google.Protobuf.MessageExtensions.ToByteArray(arg), " "$type$.Parser.ParseFrom);\n", "fieldname", GetMarshallerFieldName(message), "type", @@ -337,8 +340,8 @@ void GenerateMarshallerFields(Printer *out, const ServiceDescriptor *service) { void GenerateStaticMethodField(Printer *out, const MethodDescriptor *method) { out->Print( - "static readonly Method<$request$, $response$> $fieldname$ = new " - "Method<$request$, $response$>(\n", + "static readonly grpc::Method<$request$, $response$> $fieldname$ = new " + "grpc::Method<$request$, $response$>(\n", "fieldname", GetMethodFieldName(method), "request", GetClassName(method->input_type()), "response", GetClassName(method->output_type())); @@ -389,7 +392,7 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) { out->Print( "public virtual $returntype$ " "$methodname$($request$$response_stream_maybe$, " - "ServerCallContext context)\n", + "grpc::ServerCallContext context)\n", "methodname", method->name(), "returntype", GetMethodReturnTypeServer(method), "request", GetMethodRequestParamServer(method), "response_stream_maybe", @@ -397,8 +400,8 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) { out->Print("{\n"); out->Indent(); out->Print( - "throw new RpcException(" - "new Status(StatusCode.Unimplemented, \"\"));\n"); + "throw new grpc::RpcException(" + "new grpc::Status(grpc::StatusCode.Unimplemented, \"\"));\n"); out->Outdent(); out->Print("}\n\n"); } @@ -410,7 +413,7 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) { void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { out->Print("/// Client for $servicename$\n", "servicename", GetServiceClassName(service)); - out->Print("public partial class $name$ : ClientBase<$name$>\n", "name", + out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", "name", GetClientClassName(service)); out->Print("{\n"); out->Indent(); @@ -421,7 +424,7 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { "/// The channel to use to make remote " "calls.\n", "servicename", GetServiceClassName(service)); - out->Print("public $name$(Channel channel) : base(channel)\n", "name", + out->Print("public $name$(grpc::Channel channel) : base(channel)\n", "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); @@ -431,8 +434,9 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { "/// The callInvoker to use to make remote " "calls.\n", "servicename", GetServiceClassName(service)); - out->Print("public $name$(CallInvoker callInvoker) : base(callInvoker)\n", - "name", GetClientClassName(service)); + out->Print( + "public $name$(grpc::CallInvoker callInvoker) : base(callInvoker)\n", + "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); out->Print( @@ -461,7 +465,8 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { // unary calls have an extra synchronous stub method GenerateDocCommentClientMethod(out, method, true, false); out->Print( - "public virtual $response$ $methodname$($request$ request, Metadata " + "public virtual $response$ $methodname$($request$ request, " + "grpc::Metadata " "headers = null, DateTime? deadline = null, CancellationToken " "cancellationToken = default(CancellationToken))\n", "methodname", method->name(), "request", @@ -470,7 +475,8 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { out->Print("{\n"); out->Indent(); out->Print( - "return $methodname$(request, new CallOptions(headers, deadline, " + "return $methodname$(request, new grpc::CallOptions(headers, " + "deadline, " "cancellationToken));\n", "methodname", method->name()); out->Outdent(); @@ -480,7 +486,7 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { GenerateDocCommentClientMethod(out, method, true, true); out->Print( "public virtual $response$ $methodname$($request$ request, " - "CallOptions options)\n", + "grpc::CallOptions options)\n", "methodname", method->name(), "request", GetClassName(method->input_type()), "response", GetClassName(method->output_type())); @@ -500,7 +506,8 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { } GenerateDocCommentClientMethod(out, method, false, false); out->Print( - "public virtual $returntype$ $methodname$($request_maybe$Metadata " + "public virtual $returntype$ " + "$methodname$($request_maybe$grpc::Metadata " "headers = null, DateTime? deadline = null, CancellationToken " "cancellationToken = default(CancellationToken))\n", "methodname", method_name, "request_maybe", @@ -510,7 +517,8 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { out->Indent(); out->Print( - "return $methodname$($request_maybe$new CallOptions(headers, deadline, " + "return $methodname$($request_maybe$new grpc::CallOptions(headers, " + "deadline, " "cancellationToken));\n", "methodname", method_name, "request_maybe", GetMethodRequestParamMaybe(method, true)); @@ -520,7 +528,8 @@ void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { // overload taking CallOptions as a param GenerateDocCommentClientMethod(out, method, false, true); out->Print( - "public virtual $returntype$ $methodname$($request_maybe$CallOptions " + "public virtual $returntype$ " + "$methodname$($request_maybe$grpc::CallOptions " "options)\n", "methodname", method_name, "request_maybe", GetMethodRequestParamMaybe(method), "returntype", @@ -587,13 +596,13 @@ void GenerateBindServiceMethod(Printer *out, const ServiceDescriptor *service) { "/// An object implementing the server-side" " handling logic.\n"); out->Print( - "public static ServerServiceDefinition BindService($implclass$ " + "public static grpc::ServerServiceDefinition BindService($implclass$ " "serviceImpl)\n", "implclass", GetServerClassName(service)); out->Print("{\n"); out->Indent(); - out->Print("return ServerServiceDefinition.CreateBuilder()\n"); + out->Print("return grpc::ServerServiceDefinition.CreateBuilder()\n"); out->Indent(); out->Indent(); for (int i = 0; i < service->method_count(); i++) { @@ -681,7 +690,7 @@ grpc::string GetServices(const FileDescriptor *file, bool generate_client, out.Print("using System;\n"); out.Print("using System.Threading;\n"); out.Print("using System.Threading.Tasks;\n"); - out.Print("using Grpc.Core;\n"); + out.Print("using grpc = global::Grpc.Core;\n"); out.Print("\n"); out.Print("namespace $namespace$ {\n", "namespace", GetFileNamespace(file)); -- cgit v1.2.3 From ff4fc13bd2994cee363ae7569052e6b9aea2a7d5 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 14 Mar 2017 09:27:50 +0100 Subject: regenerate code --- src/csharp/Grpc.Examples/MathGrpc.cs | 82 +++---- src/csharp/Grpc.HealthCheck/HealthGrpc.cs | 36 +-- src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs | 52 ++--- src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs | 142 ++++++------ src/csharp/Grpc.IntegrationTesting/TestGrpc.cs | 250 ++++++++++----------- src/csharp/Grpc.Reflection/ReflectionGrpc.cs | 30 +-- 6 files changed, 296 insertions(+), 296 deletions(-) diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index 3364b8ce8e..1f2e67d916 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -35,41 +35,41 @@ using System; using System.Threading; using System.Threading.Tasks; -using Grpc.Core; +using grpc = global::Grpc.Core; namespace Math { public static partial class Math { static readonly string __ServiceName = "math.Math"; - static readonly Marshaller __Marshaller_DivArgs = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivArgs.Parser.ParseFrom); - static readonly Marshaller __Marshaller_DivReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivReply.Parser.ParseFrom); - static readonly Marshaller __Marshaller_FibArgs = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.FibArgs.Parser.ParseFrom); - static readonly Marshaller __Marshaller_Num = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.Num.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_DivArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivArgs.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_DivReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.DivReply.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_FibArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.FibArgs.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_Num = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Math.Num.Parser.ParseFrom); - static readonly Method __Method_Div = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_Div = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "Div", __Marshaller_DivArgs, __Marshaller_DivReply); - static readonly Method __Method_DivMany = new Method( - MethodType.DuplexStreaming, + static readonly grpc::Method __Method_DivMany = new grpc::Method( + grpc::MethodType.DuplexStreaming, __ServiceName, "DivMany", __Marshaller_DivArgs, __Marshaller_DivReply); - static readonly Method __Method_Fib = new Method( - MethodType.ServerStreaming, + static readonly grpc::Method __Method_Fib = new grpc::Method( + grpc::MethodType.ServerStreaming, __ServiceName, "Fib", __Marshaller_FibArgs, __Marshaller_Num); - static readonly Method __Method_Sum = new Method( - MethodType.ClientStreaming, + static readonly grpc::Method __Method_Sum = new grpc::Method( + grpc::MethodType.ClientStreaming, __ServiceName, "Sum", __Marshaller_Num, @@ -91,9 +91,9 @@ namespace Math { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task Div(global::Math.DivArgs request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task Div(global::Math.DivArgs request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -106,9 +106,9 @@ namespace Math { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task DivMany(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task DivMany(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -120,9 +120,9 @@ namespace Math { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task Fib(global::Math.FibArgs request, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task Fib(global::Math.FibArgs request, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -132,24 +132,24 @@ namespace Math { /// Used for reading requests from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task Sum(IAsyncStreamReader requestStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task Sum(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for Math - public partial class MathClient : ClientBase + public partial class MathClient : grpc::ClientBase { /// Creates a new client for Math /// The channel to use to make remote calls. - public MathClient(Channel channel) : base(channel) + public MathClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for Math that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public MathClient(CallInvoker callInvoker) : base(callInvoker) + public MathClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -171,9 +171,9 @@ namespace Math { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Math.DivReply Div(global::Math.DivArgs request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Math.DivReply Div(global::Math.DivArgs request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Div(request, new CallOptions(headers, deadline, cancellationToken)); + return Div(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient @@ -182,7 +182,7 @@ namespace Math { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Math.DivReply Div(global::Math.DivArgs request, CallOptions options) + public virtual global::Math.DivReply Div(global::Math.DivArgs request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_Div, null, options, request); } @@ -195,9 +195,9 @@ namespace Math { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall DivAsync(global::Math.DivArgs request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall DivAsync(global::Math.DivArgs request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return DivAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return DivAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient @@ -206,7 +206,7 @@ namespace Math { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall DivAsync(global::Math.DivArgs request, CallOptions options) + public virtual grpc::AsyncUnaryCall DivAsync(global::Math.DivArgs request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_Div, null, options, request); } @@ -220,9 +220,9 @@ namespace Math { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncDuplexStreamingCall DivMany(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall DivMany(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return DivMany(new CallOptions(headers, deadline, cancellationToken)); + return DivMany(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// DivMany accepts an arbitrary number of division args from the client stream @@ -232,7 +232,7 @@ namespace Math { /// /// The options for the call. /// The call object. - public virtual AsyncDuplexStreamingCall DivMany(CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall DivMany(grpc::CallOptions options) { return CallInvoker.AsyncDuplexStreamingCall(__Method_DivMany, null, options); } @@ -246,9 +246,9 @@ namespace Math { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncServerStreamingCall Fib(global::Math.FibArgs request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncServerStreamingCall Fib(global::Math.FibArgs request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Fib(request, new CallOptions(headers, deadline, cancellationToken)); + return Fib(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib @@ -258,7 +258,7 @@ namespace Math { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncServerStreamingCall Fib(global::Math.FibArgs request, CallOptions options) + public virtual grpc::AsyncServerStreamingCall Fib(global::Math.FibArgs request, grpc::CallOptions options) { return CallInvoker.AsyncServerStreamingCall(__Method_Fib, null, options, request); } @@ -270,9 +270,9 @@ namespace Math { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncClientStreamingCall Sum(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncClientStreamingCall Sum(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Sum(new CallOptions(headers, deadline, cancellationToken)); + return Sum(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Sum sums a stream of numbers, returning the final result once the stream @@ -280,7 +280,7 @@ namespace Math { /// /// The options for the call. /// The call object. - public virtual AsyncClientStreamingCall Sum(CallOptions options) + public virtual grpc::AsyncClientStreamingCall Sum(grpc::CallOptions options) { return CallInvoker.AsyncClientStreamingCall(__Method_Sum, null, options); } @@ -293,9 +293,9 @@ namespace Math { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(MathBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(MathBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_Div, serviceImpl.Div) .AddMethod(__Method_DivMany, serviceImpl.DivMany) .AddMethod(__Method_Fib, serviceImpl.Fib) diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs index 020c2df565..d3115f3da1 100644 --- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs +++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs @@ -35,18 +35,18 @@ using System; using System.Threading; using System.Threading.Tasks; -using Grpc.Core; +using grpc = global::Grpc.Core; namespace Grpc.Health.V1 { public static partial class Health { static readonly string __ServiceName = "grpc.health.v1.Health"; - static readonly Marshaller __Marshaller_HealthCheckRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckRequest.Parser.ParseFrom); - static readonly Marshaller __Marshaller_HealthCheckResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_HealthCheckRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_HealthCheckResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckResponse.Parser.ParseFrom); - static readonly Method __Method_Check = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_Check = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "Check", __Marshaller_HealthCheckRequest, @@ -61,24 +61,24 @@ namespace Grpc.Health.V1 { /// Base class for server-side implementations of Health public abstract partial class HealthBase { - public virtual global::System.Threading.Tasks.Task Check(global::Grpc.Health.V1.HealthCheckRequest request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task Check(global::Grpc.Health.V1.HealthCheckRequest request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for Health - public partial class HealthClient : ClientBase + public partial class HealthClient : grpc::ClientBase { /// Creates a new client for Health /// The channel to use to make remote calls. - public HealthClient(Channel channel) : base(channel) + public HealthClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for Health that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public HealthClient(CallInvoker callInvoker) : base(callInvoker) + public HealthClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -91,19 +91,19 @@ namespace Grpc.Health.V1 { { } - public virtual global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Check(request, new CallOptions(headers, deadline, cancellationToken)); + return Check(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } - public virtual global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, CallOptions options) + public virtual global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_Check, null, options, request); } - public virtual AsyncUnaryCall CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return CheckAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return CheckAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } - public virtual AsyncUnaryCall CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, CallOptions options) + public virtual grpc::AsyncUnaryCall CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_Check, null, options, request); } @@ -116,9 +116,9 @@ namespace Grpc.Health.V1 { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(HealthBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(HealthBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_Check, serviceImpl.Check).Build(); } diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs index 8b58622d53..c80ffa8cf6 100644 --- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs @@ -41,26 +41,26 @@ using System; using System.Threading; using System.Threading.Tasks; -using Grpc.Core; +using grpc = global::Grpc.Core; namespace Grpc.Testing { public static partial class MetricsService { static readonly string __ServiceName = "grpc.testing.MetricsService"; - static readonly Marshaller __Marshaller_EmptyMessage = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.EmptyMessage.Parser.ParseFrom); - static readonly Marshaller __Marshaller_GaugeResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeResponse.Parser.ParseFrom); - static readonly Marshaller __Marshaller_GaugeRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_EmptyMessage = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.EmptyMessage.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_GaugeResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_GaugeRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeRequest.Parser.ParseFrom); - static readonly Method __Method_GetAllGauges = new Method( - MethodType.ServerStreaming, + static readonly grpc::Method __Method_GetAllGauges = new grpc::Method( + grpc::MethodType.ServerStreaming, __ServiceName, "GetAllGauges", __Marshaller_EmptyMessage, __Marshaller_GaugeResponse); - static readonly Method __Method_GetGauge = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_GetGauge = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "GetGauge", __Marshaller_GaugeRequest, @@ -83,9 +83,9 @@ namespace Grpc.Testing { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task GetAllGauges(global::Grpc.Testing.EmptyMessage request, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task GetAllGauges(global::Grpc.Testing.EmptyMessage request, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -94,24 +94,24 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task GetGauge(global::Grpc.Testing.GaugeRequest request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task GetGauge(global::Grpc.Testing.GaugeRequest request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for MetricsService - public partial class MetricsServiceClient : ClientBase + public partial class MetricsServiceClient : grpc::ClientBase { /// Creates a new client for MetricsService /// The channel to use to make remote calls. - public MetricsServiceClient(Channel channel) : base(channel) + public MetricsServiceClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for MetricsService that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public MetricsServiceClient(CallInvoker callInvoker) : base(callInvoker) + public MetricsServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -133,9 +133,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncServerStreamingCall GetAllGauges(global::Grpc.Testing.EmptyMessage request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncServerStreamingCall GetAllGauges(global::Grpc.Testing.EmptyMessage request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return GetAllGauges(request, new CallOptions(headers, deadline, cancellationToken)); + return GetAllGauges(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Returns the values of all the gauges that are currently being maintained by @@ -144,7 +144,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncServerStreamingCall GetAllGauges(global::Grpc.Testing.EmptyMessage request, CallOptions options) + public virtual grpc::AsyncServerStreamingCall GetAllGauges(global::Grpc.Testing.EmptyMessage request, grpc::CallOptions options) { return CallInvoker.AsyncServerStreamingCall(__Method_GetAllGauges, null, options, request); } @@ -156,9 +156,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return GetGauge(request, new CallOptions(headers, deadline, cancellationToken)); + return GetGauge(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Returns the value of one gauge @@ -166,7 +166,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, CallOptions options) + public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_GetGauge, null, options, request); } @@ -178,9 +178,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return GetGaugeAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return GetGaugeAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Returns the value of one gauge @@ -188,7 +188,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, CallOptions options) + public virtual grpc::AsyncUnaryCall GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_GetGauge, null, options, request); } @@ -201,9 +201,9 @@ namespace Grpc.Testing { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(MetricsServiceBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(MetricsServiceBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_GetAllGauges, serviceImpl.GetAllGauges) .AddMethod(__Method_GetGauge, serviceImpl.GetGauge).Build(); } diff --git a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs index 5135d9ab66..bb95c8a549 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs @@ -37,25 +37,25 @@ using System; using System.Threading; using System.Threading.Tasks; -using Grpc.Core; +using grpc = global::Grpc.Core; namespace Grpc.Testing { public static partial class BenchmarkService { static readonly string __ServiceName = "grpc.testing.BenchmarkService"; - static readonly Marshaller __Marshaller_SimpleRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); - static readonly Marshaller __Marshaller_SimpleResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); - static readonly Method __Method_UnaryCall = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_UnaryCall = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "UnaryCall", __Marshaller_SimpleRequest, __Marshaller_SimpleResponse); - static readonly Method __Method_StreamingCall = new Method( - MethodType.DuplexStreaming, + static readonly grpc::Method __Method_StreamingCall = new grpc::Method( + grpc::MethodType.DuplexStreaming, __ServiceName, "StreamingCall", __Marshaller_SimpleRequest, @@ -77,9 +77,9 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task UnaryCall(global::Grpc.Testing.SimpleRequest request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task UnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -90,24 +90,24 @@ namespace Grpc.Testing { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task StreamingCall(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task StreamingCall(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for BenchmarkService - public partial class BenchmarkServiceClient : ClientBase + public partial class BenchmarkServiceClient : grpc::ClientBase { /// Creates a new client for BenchmarkService /// The channel to use to make remote calls. - public BenchmarkServiceClient(Channel channel) : base(channel) + public BenchmarkServiceClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for BenchmarkService that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public BenchmarkServiceClient(CallInvoker callInvoker) : base(callInvoker) + public BenchmarkServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -129,9 +129,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnaryCall(request, new CallOptions(headers, deadline, cancellationToken)); + return UnaryCall(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by one response. @@ -140,7 +140,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, CallOptions options) + public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_UnaryCall, null, options, request); } @@ -153,9 +153,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnaryCallAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return UnaryCallAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by one response. @@ -164,7 +164,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, CallOptions options) + public virtual grpc::AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_UnaryCall, null, options, request); } @@ -176,9 +176,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncDuplexStreamingCall StreamingCall(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall StreamingCall(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return StreamingCall(new CallOptions(headers, deadline, cancellationToken)); + return StreamingCall(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by one response. @@ -186,7 +186,7 @@ namespace Grpc.Testing { /// /// The options for the call. /// The call object. - public virtual AsyncDuplexStreamingCall StreamingCall(CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall StreamingCall(grpc::CallOptions options) { return CallInvoker.AsyncDuplexStreamingCall(__Method_StreamingCall, null, options); } @@ -199,9 +199,9 @@ namespace Grpc.Testing { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(BenchmarkServiceBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(BenchmarkServiceBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_UnaryCall, serviceImpl.UnaryCall) .AddMethod(__Method_StreamingCall, serviceImpl.StreamingCall).Build(); } @@ -211,37 +211,37 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.WorkerService"; - static readonly Marshaller __Marshaller_ServerArgs = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerArgs.Parser.ParseFrom); - static readonly Marshaller __Marshaller_ServerStatus = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerStatus.Parser.ParseFrom); - static readonly Marshaller __Marshaller_ClientArgs = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientArgs.Parser.ParseFrom); - static readonly Marshaller __Marshaller_ClientStatus = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientStatus.Parser.ParseFrom); - static readonly Marshaller __Marshaller_CoreRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreRequest.Parser.ParseFrom); - static readonly Marshaller __Marshaller_CoreResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreResponse.Parser.ParseFrom); - static readonly Marshaller __Marshaller_Void = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ServerArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerArgs.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ServerStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerStatus.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ClientArgs = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientArgs.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ClientStatus = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientStatus.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_CoreRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_CoreResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); - static readonly Method __Method_RunServer = new Method( - MethodType.DuplexStreaming, + static readonly grpc::Method __Method_RunServer = new grpc::Method( + grpc::MethodType.DuplexStreaming, __ServiceName, "RunServer", __Marshaller_ServerArgs, __Marshaller_ServerStatus); - static readonly Method __Method_RunClient = new Method( - MethodType.DuplexStreaming, + static readonly grpc::Method __Method_RunClient = new grpc::Method( + grpc::MethodType.DuplexStreaming, __ServiceName, "RunClient", __Marshaller_ClientArgs, __Marshaller_ClientStatus); - static readonly Method __Method_CoreCount = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_CoreCount = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "CoreCount", __Marshaller_CoreRequest, __Marshaller_CoreResponse); - static readonly Method __Method_QuitWorker = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_QuitWorker = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "QuitWorker", __Marshaller_Void, @@ -268,9 +268,9 @@ namespace Grpc.Testing { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task RunServer(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task RunServer(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -285,9 +285,9 @@ namespace Grpc.Testing { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task RunClient(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task RunClient(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -296,9 +296,9 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task CoreCount(global::Grpc.Testing.CoreRequest request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task CoreCount(global::Grpc.Testing.CoreRequest request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -307,24 +307,24 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task QuitWorker(global::Grpc.Testing.Void request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task QuitWorker(global::Grpc.Testing.Void request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for WorkerService - public partial class WorkerServiceClient : ClientBase + public partial class WorkerServiceClient : grpc::ClientBase { /// Creates a new client for WorkerService /// The channel to use to make remote calls. - public WorkerServiceClient(Channel channel) : base(channel) + public WorkerServiceClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for WorkerService that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public WorkerServiceClient(CallInvoker callInvoker) : base(callInvoker) + public WorkerServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -349,9 +349,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncDuplexStreamingCall RunServer(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall RunServer(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return RunServer(new CallOptions(headers, deadline, cancellationToken)); + return RunServer(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Start server with specified workload. @@ -363,7 +363,7 @@ namespace Grpc.Testing { /// /// The options for the call. /// The call object. - public virtual AsyncDuplexStreamingCall RunServer(CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall RunServer(grpc::CallOptions options) { return CallInvoker.AsyncDuplexStreamingCall(__Method_RunServer, null, options); } @@ -379,9 +379,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncDuplexStreamingCall RunClient(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall RunClient(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return RunClient(new CallOptions(headers, deadline, cancellationToken)); + return RunClient(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Start client with specified workload. @@ -393,7 +393,7 @@ namespace Grpc.Testing { /// /// The options for the call. /// The call object. - public virtual AsyncDuplexStreamingCall RunClient(CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall RunClient(grpc::CallOptions options) { return CallInvoker.AsyncDuplexStreamingCall(__Method_RunClient, null, options); } @@ -405,9 +405,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return CoreCount(request, new CallOptions(headers, deadline, cancellationToken)); + return CoreCount(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Just return the core count - unary call @@ -415,7 +415,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, CallOptions options) + public virtual global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_CoreCount, null, options, request); } @@ -427,9 +427,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return CoreCountAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return CoreCountAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Just return the core count - unary call @@ -437,7 +437,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, CallOptions options) + public virtual grpc::AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_CoreCount, null, options, request); } @@ -449,9 +449,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return QuitWorker(request, new CallOptions(headers, deadline, cancellationToken)); + return QuitWorker(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Quit this worker @@ -459,7 +459,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, CallOptions options) + public virtual global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_QuitWorker, null, options, request); } @@ -471,9 +471,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return QuitWorkerAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return QuitWorkerAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// Quit this worker @@ -481,7 +481,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, CallOptions options) + public virtual grpc::AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_QuitWorker, null, options, request); } @@ -494,9 +494,9 @@ namespace Grpc.Testing { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(WorkerServiceBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(WorkerServiceBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_RunServer, serviceImpl.RunServer) .AddMethod(__Method_RunClient, serviceImpl.RunClient) .AddMethod(__Method_CoreCount, serviceImpl.CoreCount) diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs index 0265f8e821..77f76ebbe9 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs @@ -38,7 +38,7 @@ using System; using System.Threading; using System.Threading.Tasks; -using Grpc.Core; +using grpc = global::Grpc.Core; namespace Grpc.Testing { /// @@ -49,65 +49,65 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.TestService"; - static readonly Marshaller __Marshaller_Empty = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); - static readonly Marshaller __Marshaller_SimpleRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); - static readonly Marshaller __Marshaller_SimpleResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); - static readonly Marshaller __Marshaller_StreamingOutputCallRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallRequest.Parser.ParseFrom); - static readonly Marshaller __Marshaller_StreamingOutputCallResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallResponse.Parser.ParseFrom); - static readonly Marshaller __Marshaller_StreamingInputCallRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallRequest.Parser.ParseFrom); - static readonly Marshaller __Marshaller_StreamingInputCallResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_SimpleRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_SimpleResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.SimpleResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_StreamingOutputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_StreamingOutputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingOutputCallResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_StreamingInputCallRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_StreamingInputCallResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.StreamingInputCallResponse.Parser.ParseFrom); - static readonly Method __Method_EmptyCall = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_EmptyCall = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "EmptyCall", __Marshaller_Empty, __Marshaller_Empty); - static readonly Method __Method_UnaryCall = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_UnaryCall = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "UnaryCall", __Marshaller_SimpleRequest, __Marshaller_SimpleResponse); - static readonly Method __Method_CacheableUnaryCall = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_CacheableUnaryCall = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "CacheableUnaryCall", __Marshaller_SimpleRequest, __Marshaller_SimpleResponse); - static readonly Method __Method_StreamingOutputCall = new Method( - MethodType.ServerStreaming, + static readonly grpc::Method __Method_StreamingOutputCall = new grpc::Method( + grpc::MethodType.ServerStreaming, __ServiceName, "StreamingOutputCall", __Marshaller_StreamingOutputCallRequest, __Marshaller_StreamingOutputCallResponse); - static readonly Method __Method_StreamingInputCall = new Method( - MethodType.ClientStreaming, + static readonly grpc::Method __Method_StreamingInputCall = new grpc::Method( + grpc::MethodType.ClientStreaming, __ServiceName, "StreamingInputCall", __Marshaller_StreamingInputCallRequest, __Marshaller_StreamingInputCallResponse); - static readonly Method __Method_FullDuplexCall = new Method( - MethodType.DuplexStreaming, + static readonly grpc::Method __Method_FullDuplexCall = new grpc::Method( + grpc::MethodType.DuplexStreaming, __ServiceName, "FullDuplexCall", __Marshaller_StreamingOutputCallRequest, __Marshaller_StreamingOutputCallResponse); - static readonly Method __Method_HalfDuplexCall = new Method( - MethodType.DuplexStreaming, + static readonly grpc::Method __Method_HalfDuplexCall = new grpc::Method( + grpc::MethodType.DuplexStreaming, __ServiceName, "HalfDuplexCall", __Marshaller_StreamingOutputCallRequest, __Marshaller_StreamingOutputCallResponse); - static readonly Method __Method_UnimplementedCall = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_UnimplementedCall = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "UnimplementedCall", __Marshaller_Empty, @@ -128,9 +128,9 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task EmptyCall(global::Grpc.Testing.Empty request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task EmptyCall(global::Grpc.Testing.Empty request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -139,9 +139,9 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task UnaryCall(global::Grpc.Testing.SimpleRequest request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task UnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -152,9 +152,9 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -165,9 +165,9 @@ namespace Grpc.Testing { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task StreamingOutputCall(global::Grpc.Testing.StreamingOutputCallRequest request, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task StreamingOutputCall(global::Grpc.Testing.StreamingOutputCallRequest request, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -177,9 +177,9 @@ namespace Grpc.Testing { /// Used for reading requests from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task StreamingInputCall(IAsyncStreamReader requestStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task StreamingInputCall(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -191,9 +191,9 @@ namespace Grpc.Testing { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task FullDuplexCall(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task FullDuplexCall(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -206,9 +206,9 @@ namespace Grpc.Testing { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task HalfDuplexCall(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task HalfDuplexCall(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } /// @@ -218,24 +218,24 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task UnimplementedCall(global::Grpc.Testing.Empty request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task UnimplementedCall(global::Grpc.Testing.Empty request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for TestService - public partial class TestServiceClient : ClientBase + public partial class TestServiceClient : grpc::ClientBase { /// Creates a new client for TestService /// The channel to use to make remote calls. - public TestServiceClient(Channel channel) : base(channel) + public TestServiceClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for TestService that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public TestServiceClient(CallInvoker callInvoker) : base(callInvoker) + public TestServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -256,9 +256,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.Empty EmptyCall(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.Empty EmptyCall(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return EmptyCall(request, new CallOptions(headers, deadline, cancellationToken)); + return EmptyCall(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One empty request followed by one empty response. @@ -266,7 +266,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.Empty EmptyCall(global::Grpc.Testing.Empty request, CallOptions options) + public virtual global::Grpc.Testing.Empty EmptyCall(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_EmptyCall, null, options, request); } @@ -278,9 +278,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall EmptyCallAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall EmptyCallAsync(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return EmptyCallAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return EmptyCallAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One empty request followed by one empty response. @@ -288,7 +288,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall EmptyCallAsync(global::Grpc.Testing.Empty request, CallOptions options) + public virtual grpc::AsyncUnaryCall EmptyCallAsync(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_EmptyCall, null, options, request); } @@ -300,9 +300,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnaryCall(request, new CallOptions(headers, deadline, cancellationToken)); + return UnaryCall(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by one response. @@ -310,7 +310,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, CallOptions options) + public virtual global::Grpc.Testing.SimpleResponse UnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_UnaryCall, null, options, request); } @@ -322,9 +322,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnaryCallAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return UnaryCallAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by one response. @@ -332,7 +332,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, CallOptions options) + public virtual grpc::AsyncUnaryCall UnaryCallAsync(global::Grpc.Testing.SimpleRequest request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_UnaryCall, null, options, request); } @@ -346,9 +346,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.SimpleResponse CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.SimpleResponse CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return CacheableUnaryCall(request, new CallOptions(headers, deadline, cancellationToken)); + return CacheableUnaryCall(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by one response. Response has cache control @@ -358,7 +358,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.SimpleResponse CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, CallOptions options) + public virtual global::Grpc.Testing.SimpleResponse CacheableUnaryCall(global::Grpc.Testing.SimpleRequest request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_CacheableUnaryCall, null, options, request); } @@ -372,9 +372,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall CacheableUnaryCallAsync(global::Grpc.Testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall CacheableUnaryCallAsync(global::Grpc.Testing.SimpleRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return CacheableUnaryCallAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return CacheableUnaryCallAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by one response. Response has cache control @@ -384,7 +384,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall CacheableUnaryCallAsync(global::Grpc.Testing.SimpleRequest request, CallOptions options) + public virtual grpc::AsyncUnaryCall CacheableUnaryCallAsync(global::Grpc.Testing.SimpleRequest request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_CacheableUnaryCall, null, options, request); } @@ -397,9 +397,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncServerStreamingCall StreamingOutputCall(global::Grpc.Testing.StreamingOutputCallRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncServerStreamingCall StreamingOutputCall(global::Grpc.Testing.StreamingOutputCallRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return StreamingOutputCall(request, new CallOptions(headers, deadline, cancellationToken)); + return StreamingOutputCall(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// One request followed by a sequence of responses (streamed download). @@ -408,7 +408,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncServerStreamingCall StreamingOutputCall(global::Grpc.Testing.StreamingOutputCallRequest request, CallOptions options) + public virtual grpc::AsyncServerStreamingCall StreamingOutputCall(global::Grpc.Testing.StreamingOutputCallRequest request, grpc::CallOptions options) { return CallInvoker.AsyncServerStreamingCall(__Method_StreamingOutputCall, null, options, request); } @@ -420,9 +420,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncClientStreamingCall StreamingInputCall(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncClientStreamingCall StreamingInputCall(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return StreamingInputCall(new CallOptions(headers, deadline, cancellationToken)); + return StreamingInputCall(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// A sequence of requests followed by one response (streamed upload). @@ -430,7 +430,7 @@ namespace Grpc.Testing { /// /// The options for the call. /// The call object. - public virtual AsyncClientStreamingCall StreamingInputCall(CallOptions options) + public virtual grpc::AsyncClientStreamingCall StreamingInputCall(grpc::CallOptions options) { return CallInvoker.AsyncClientStreamingCall(__Method_StreamingInputCall, null, options); } @@ -443,9 +443,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncDuplexStreamingCall FullDuplexCall(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall FullDuplexCall(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return FullDuplexCall(new CallOptions(headers, deadline, cancellationToken)); + return FullDuplexCall(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// A sequence of requests with each request served by the server immediately. @@ -454,7 +454,7 @@ namespace Grpc.Testing { /// /// The options for the call. /// The call object. - public virtual AsyncDuplexStreamingCall FullDuplexCall(CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall FullDuplexCall(grpc::CallOptions options) { return CallInvoker.AsyncDuplexStreamingCall(__Method_FullDuplexCall, null, options); } @@ -468,9 +468,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncDuplexStreamingCall HalfDuplexCall(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall HalfDuplexCall(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return HalfDuplexCall(new CallOptions(headers, deadline, cancellationToken)); + return HalfDuplexCall(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// A sequence of requests followed by a sequence of responses. @@ -480,7 +480,7 @@ namespace Grpc.Testing { /// /// The options for the call. /// The call object. - public virtual AsyncDuplexStreamingCall HalfDuplexCall(CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall HalfDuplexCall(grpc::CallOptions options) { return CallInvoker.AsyncDuplexStreamingCall(__Method_HalfDuplexCall, null, options); } @@ -493,9 +493,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnimplementedCall(request, new CallOptions(headers, deadline, cancellationToken)); + return UnimplementedCall(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// The test server will not implement this method. It will be used @@ -504,7 +504,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, CallOptions options) + public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_UnimplementedCall, null, options, request); } @@ -517,9 +517,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnimplementedCallAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return UnimplementedCallAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// The test server will not implement this method. It will be used @@ -528,7 +528,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, CallOptions options) + public virtual grpc::AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_UnimplementedCall, null, options, request); } @@ -541,9 +541,9 @@ namespace Grpc.Testing { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(TestServiceBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(TestServiceBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_EmptyCall, serviceImpl.EmptyCall) .AddMethod(__Method_UnaryCall, serviceImpl.UnaryCall) .AddMethod(__Method_CacheableUnaryCall, serviceImpl.CacheableUnaryCall) @@ -563,10 +563,10 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.UnimplementedService"; - static readonly Marshaller __Marshaller_Empty = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); - static readonly Method __Method_UnimplementedCall = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_UnimplementedCall = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "UnimplementedCall", __Marshaller_Empty, @@ -587,24 +587,24 @@ namespace Grpc.Testing { /// The request received from the client. /// The context of the server-side call handler being invoked. /// The response to send back to the client (wrapped by a task). - public virtual global::System.Threading.Tasks.Task UnimplementedCall(global::Grpc.Testing.Empty request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task UnimplementedCall(global::Grpc.Testing.Empty request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for UnimplementedService - public partial class UnimplementedServiceClient : ClientBase + public partial class UnimplementedServiceClient : grpc::ClientBase { /// Creates a new client for UnimplementedService /// The channel to use to make remote calls. - public UnimplementedServiceClient(Channel channel) : base(channel) + public UnimplementedServiceClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for UnimplementedService that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public UnimplementedServiceClient(CallInvoker callInvoker) : base(callInvoker) + public UnimplementedServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -625,9 +625,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The response received from the server. - public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnimplementedCall(request, new CallOptions(headers, deadline, cancellationToken)); + return UnimplementedCall(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// A call that no server should implement @@ -635,7 +635,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The response received from the server. - public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, CallOptions options) + public virtual global::Grpc.Testing.Empty UnimplementedCall(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_UnimplementedCall, null, options, request); } @@ -647,9 +647,9 @@ namespace Grpc.Testing { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return UnimplementedCallAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return UnimplementedCallAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// A call that no server should implement @@ -657,7 +657,7 @@ namespace Grpc.Testing { /// The request to send to the server. /// The options for the call. /// The call object. - public virtual AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, CallOptions options) + public virtual grpc::AsyncUnaryCall UnimplementedCallAsync(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_UnimplementedCall, null, options, request); } @@ -670,9 +670,9 @@ namespace Grpc.Testing { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(UnimplementedServiceBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(UnimplementedServiceBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall).Build(); } @@ -684,19 +684,19 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.ReconnectService"; - static readonly Marshaller __Marshaller_ReconnectParams = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectParams.Parser.ParseFrom); - static readonly Marshaller __Marshaller_Empty = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); - static readonly Marshaller __Marshaller_ReconnectInfo = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectInfo.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ReconnectParams = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectParams.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ReconnectInfo = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectInfo.Parser.ParseFrom); - static readonly Method __Method_Start = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_Start = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "Start", __Marshaller_ReconnectParams, __Marshaller_Empty); - static readonly Method __Method_Stop = new Method( - MethodType.Unary, + static readonly grpc::Method __Method_Stop = new grpc::Method( + grpc::MethodType.Unary, __ServiceName, "Stop", __Marshaller_Empty, @@ -711,29 +711,29 @@ namespace Grpc.Testing { /// Base class for server-side implementations of ReconnectService public abstract partial class ReconnectServiceBase { - public virtual global::System.Threading.Tasks.Task Start(global::Grpc.Testing.ReconnectParams request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task Start(global::Grpc.Testing.ReconnectParams request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } - public virtual global::System.Threading.Tasks.Task Stop(global::Grpc.Testing.Empty request, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task Stop(global::Grpc.Testing.Empty request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for ReconnectService - public partial class ReconnectServiceClient : ClientBase + public partial class ReconnectServiceClient : grpc::ClientBase { /// Creates a new client for ReconnectService /// The channel to use to make remote calls. - public ReconnectServiceClient(Channel channel) : base(channel) + public ReconnectServiceClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for ReconnectService that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public ReconnectServiceClient(CallInvoker callInvoker) : base(callInvoker) + public ReconnectServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -746,35 +746,35 @@ namespace Grpc.Testing { { } - public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Start(request, new CallOptions(headers, deadline, cancellationToken)); + return Start(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } - public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, CallOptions options) + public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_Start, null, options, request); } - public virtual AsyncUnaryCall StartAsync(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall StartAsync(global::Grpc.Testing.ReconnectParams request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return StartAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return StartAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } - public virtual AsyncUnaryCall StartAsync(global::Grpc.Testing.ReconnectParams request, CallOptions options) + public virtual grpc::AsyncUnaryCall StartAsync(global::Grpc.Testing.ReconnectParams request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_Start, null, options, request); } - public virtual global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Stop(request, new CallOptions(headers, deadline, cancellationToken)); + return Stop(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } - public virtual global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, CallOptions options) + public virtual global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_Stop, null, options, request); } - public virtual AsyncUnaryCall StopAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncUnaryCall StopAsync(global::Grpc.Testing.Empty request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return StopAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return StopAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } - public virtual AsyncUnaryCall StopAsync(global::Grpc.Testing.Empty request, CallOptions options) + public virtual grpc::AsyncUnaryCall StopAsync(global::Grpc.Testing.Empty request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_Stop, null, options, request); } @@ -787,9 +787,9 @@ namespace Grpc.Testing { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(ReconnectServiceBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(ReconnectServiceBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_Start, serviceImpl.Start) .AddMethod(__Method_Stop, serviceImpl.Stop).Build(); } diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs index 5bd7558be5..45321587f5 100644 --- a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs +++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs @@ -37,18 +37,18 @@ using System; using System.Threading; using System.Threading.Tasks; -using Grpc.Core; +using grpc = global::Grpc.Core; namespace Grpc.Reflection.V1Alpha { public static partial class ServerReflection { static readonly string __ServiceName = "grpc.reflection.v1alpha.ServerReflection"; - static readonly Marshaller __Marshaller_ServerReflectionRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser.ParseFrom); - static readonly Marshaller __Marshaller_ServerReflectionResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ServerReflectionRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_ServerReflectionResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser.ParseFrom); - static readonly Method __Method_ServerReflectionInfo = new Method( - MethodType.DuplexStreaming, + static readonly grpc::Method __Method_ServerReflectionInfo = new grpc::Method( + grpc::MethodType.DuplexStreaming, __ServiceName, "ServerReflectionInfo", __Marshaller_ServerReflectionRequest, @@ -71,24 +71,24 @@ namespace Grpc.Reflection.V1Alpha { /// Used for sending responses back to the client. /// The context of the server-side call handler being invoked. /// A task indicating completion of the handler. - public virtual global::System.Threading.Tasks.Task ServerReflectionInfo(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + public virtual global::System.Threading.Tasks.Task ServerReflectionInfo(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// Client for ServerReflection - public partial class ServerReflectionClient : ClientBase + public partial class ServerReflectionClient : grpc::ClientBase { /// Creates a new client for ServerReflection /// The channel to use to make remote calls. - public ServerReflectionClient(Channel channel) : base(channel) + public ServerReflectionClient(grpc::Channel channel) : base(channel) { } /// Creates a new client for ServerReflection that uses a custom CallInvoker. /// The callInvoker to use to make remote calls. - public ServerReflectionClient(CallInvoker callInvoker) : base(callInvoker) + public ServerReflectionClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// Protected parameterless constructor to allow creation of test doubles. @@ -109,9 +109,9 @@ namespace Grpc.Reflection.V1Alpha { /// An optional deadline for the call. The call will be cancelled if deadline is hit. /// An optional token for canceling the call. /// The call object. - public virtual AsyncDuplexStreamingCall ServerReflectionInfo(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual grpc::AsyncDuplexStreamingCall ServerReflectionInfo(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return ServerReflectionInfo(new CallOptions(headers, deadline, cancellationToken)); + return ServerReflectionInfo(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// /// The reflection service is structured as a bidirectional stream, ensuring @@ -119,7 +119,7 @@ namespace Grpc.Reflection.V1Alpha { /// /// The options for the call. /// The call object. - public virtual AsyncDuplexStreamingCall ServerReflectionInfo(CallOptions options) + public virtual grpc::AsyncDuplexStreamingCall ServerReflectionInfo(grpc::CallOptions options) { return CallInvoker.AsyncDuplexStreamingCall(__Method_ServerReflectionInfo, null, options); } @@ -132,9 +132,9 @@ namespace Grpc.Reflection.V1Alpha { /// Creates service definition that can be registered with a server /// An object implementing the server-side handling logic. - public static ServerServiceDefinition BindService(ServerReflectionBase serviceImpl) + public static grpc::ServerServiceDefinition BindService(ServerReflectionBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_ServerReflectionInfo, serviceImpl.ServerReflectionInfo).Build(); } -- cgit v1.2.3 From d8cbead37b049d5bfd583dd8e0b36a708e5fe405 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 14 Mar 2017 11:05:24 -0700 Subject: Updated version number in BUILD --- BUILD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index ca0a1c5607..585c26ad1c 100644 --- a/BUILD +++ b/BUILD @@ -37,11 +37,11 @@ package(default_visibility = ["//visibility:public"]) load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_proto_plugin") -g_stands_for = "good" +g_stands_for = "green" -core_version = "2.0.0-dev" +core_version = "3.0.0-dev" -version = "1.1.0-dev" +version = "1.2.0-pre1" grpc_cc_library( name = "gpr", -- cgit v1.2.3 From aaef11aa298c9b760fa7a634ce6a1be1ed8d6595 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 14 Mar 2017 11:19:25 -0700 Subject: Drop support for io.js, fix minor issue with node extension --- package.json | 2 +- src/node/ext/server_uv.cc | 2 +- templates/package.json.template | 2 +- tools/run_tests/artifacts/build_artifact_node.bat | 2 +- tools/run_tests/artifacts/build_artifact_node.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2228884816..588425d0e0 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "poisson-process": "^0.2.1" }, "engines": { - "node": ">=1.1.0" + "node": ">=4" }, "binary": { "module_name": "grpc_node", diff --git a/src/node/ext/server_uv.cc b/src/node/ext/server_uv.cc index bf8b609a63..c5e5ca9f42 100644 --- a/src/node/ext/server_uv.cc +++ b/src/node/ext/server_uv.cc @@ -47,12 +47,12 @@ namespace grpc { namespace node { using Nan::Callback; +using Nan::MaybeLocal; using v8::External; using v8::Function; using v8::FunctionTemplate; using v8::Local; -using v8::MaybeLocal; using v8::Object; using v8::Value; diff --git a/templates/package.json.template b/templates/package.json.template index 316c28e478..272a17562f 100644 --- a/templates/package.json.template +++ b/templates/package.json.template @@ -54,7 +54,7 @@ "poisson-process": "^0.2.1" }, "engines": { - "node": ">=1.1.0" + "node": ">=4" }, "binary": { "module_name": "grpc_node", diff --git a/tools/run_tests/artifacts/build_artifact_node.bat b/tools/run_tests/artifacts/build_artifact_node.bat index 0a2bc4b9d7..336a63b9f5 100644 --- a/tools/run_tests/artifacts/build_artifact_node.bat +++ b/tools/run_tests/artifacts/build_artifact_node.bat @@ -27,7 +27,7 @@ @rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -set node_versions=1.1.0 2.0.0 3.0.0 4.0.0 5.0.0 6.0.0 7.0.0 +set node_versions=4.0.0 5.0.0 6.0.0 7.0.0 set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 diff --git a/tools/run_tests/artifacts/build_artifact_node.sh b/tools/run_tests/artifacts/build_artifact_node.sh index 47b1f339fb..a33ab45ac2 100755 --- a/tools/run_tests/artifacts/build_artifact_node.sh +++ b/tools/run_tests/artifacts/build_artifact_node.sh @@ -42,7 +42,7 @@ mkdir -p artifacts npm update -node_versions=( 1.1.0 2.0.0 3.0.0 4.0.0 5.0.0 6.0.0 7.0.0 ) +node_versions=( 4.0.0 5.0.0 6.0.0 7.0.0 ) electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 ) -- cgit v1.2.3 From fcad5799b4c785d428ed30340d79581a5d97026c Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 14 Mar 2017 12:26:17 -0700 Subject: in the middle of fixing watch and get connectivity state to work with new changes --- src/ruby/ext/grpc/rb_channel.c | 113 ++++++++++++++++++++----------- src/ruby/spec/channel_connection_spec.rb | 49 ++++++++++++++ 2 files changed, 121 insertions(+), 41 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 2489ec2fef..8cd489345d 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -76,8 +76,10 @@ typedef struct grpc_rb_channel { grpc_completion_queue *queue; int request_safe_destroy; int safe_to_destroy; - gpr_mu safe_destroy_mu; - gpr_cv safe_destroy_cv; + grpc_connectivity_state current_connectivity_state; + + gpr_mu channel_mu; + gpr_cv channel_cv; } grpc_rb_channel; /* Forward declarations of functions involved in temporary fix to @@ -180,12 +182,19 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { GPR_ASSERT(ch); wrapper->wrapped = ch; - gpr_mu_init(&wrapper->safe_destroy_mu); - gpr_cv_init(&wrapper->safe_destroy_cv); - gpr_mu_lock(&wrapper->safe_destroy_mu); + + gpr_mu_init(&wrapper->channel_mu); + gpr_cv_init(&wrapper->channel_cv); + + gpr_mu_lock(&wrapper->channel_mu); + wrapper->current_connectivity_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); + gpr_cv_signal(&wrapper->channel_cv); + gpr_mu_unlock(&wrapper->channel_mu); + + gpr_mu_lock(&wrapper->channel_mu); wrapper->safe_to_destroy = 0; wrapper->request_safe_destroy = 0; - gpr_mu_unlock(&wrapper->safe_destroy_mu); + gpr_mu_unlock(&wrapper->channel_mu); grpc_rb_channel_try_register_connection_polling(wrapper); if (args.args != NULL) { @@ -232,43 +241,57 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, grpc_channel_check_connectivity_state(ch, grpc_try_to_connect)); } -/* Watch for a change in connectivity state. - - Once the channel connectivity state is different from the last observed - state, tag will be enqueued on cq with success=1 - - If deadline expires BEFORE the state is changed, tag will be enqueued on - the completion queue with success=0 */ +/* Wait until the channel's connectivity state becomes different from + * "last_state", or "deadline" expires. + * Returns true if the the channel's connectivity state becomes + * different from "last_state" within "deadline". + * Returns false if "deadline" expires before the channel's connectivity + * state changes from "last_state". + * */ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, VALUE last_state, VALUE deadline) { grpc_rb_channel *wrapper = NULL; - grpc_channel *ch = NULL; - grpc_completion_queue *cq = NULL; - - void *tag = wrapper; - - grpc_event event; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); - ch = wrapper->wrapped; - cq = wrapper->queue; - if (ch == NULL) { + + if (wrapper->wrapped == NULL) { rb_raise(rb_eRuntimeError, "closed!"); return Qnil; } - grpc_channel_watch_connectivity_state( - ch, (grpc_connectivity_state)NUM2LONG(last_state), - grpc_rb_time_timeval(deadline, /* absolute time */ 0), cq, tag); - event = rb_completion_queue_pluck(cq, tag, gpr_inf_future(GPR_CLOCK_REALTIME), - NULL); + if (!FIXNUM_P(last_state)) { + rb_raise(rb_eTypeError, "bad type for last_state. want a GRPC::Core::ChannelState constant"); + return Qnil; + } - if (event.success) { + gpr_mu_lock(&wrapper->channel_mu); + if (wrapper->current_connectivity_state != NUM2LONG(last_state)) { + gpr_mu_unlock(&wrapper->channel_mu); return Qtrue; - } else { + } + if (wrapper->request_safe_destroy) { + gpr_mu_unlock(&wrapper->channel_mu); + rb_raise(rb_eRuntimeError, "watch_connectivity_state called on closed channel"); + return Qfalse; + } + if (wrapper->safe_to_destroy) { + gpr_mu_unlock(&wrapper->channel_mu); + gpr_log(GPR_DEBUG, "GRPC_RUBY_RB_CHANNEL: attempt to watch_connectivity_state on a non-state-polled channel"); + return Qfalse; + } + gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, grpc_rb_time_timeval(deadline, /* absolute time */ 0)); + if (wrapper->request_safe_destroy) { + gpr_mu_unlock(&wrapper->channel_mu); + rb_raise(rb_eRuntimeError, "channel closed during call to watch_connectivity_state"); return Qfalse; } + if (wrapper->current_connectivity_state != NUM2LONG(last_state)) { + gpr_mu_unlock(&wrapper->channel_mu); + return Qtrue; + } + gpr_mu_unlock(&wrapper->channel_mu); + return Qfalse; } /* Create a call given a grpc_channel, in order to call method. The request @@ -378,40 +401,47 @@ static void grpc_rb_channel_try_register_connection_polling( GPR_ASSERT(wrapper); GPR_ASSERT(wrapper->wrapped); - gpr_mu_lock(&wrapper->safe_destroy_mu); + gpr_mu_lock(&wrapper->channel_mu); if (wrapper->request_safe_destroy) { wrapper->safe_to_destroy = 1; - gpr_cv_signal(&wrapper->safe_destroy_cv); - gpr_mu_unlock(&wrapper->safe_destroy_mu); + gpr_cv_signal(&wrapper->channel_cv); + gpr_mu_unlock(&wrapper->channel_mu); return; } gpr_mu_lock(&channel_polling_mu); + + gpr_mu_lock(&wrapper->channel_mu); conn_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); + if (conn_state != wrapper->current_connectivity_state) { + wrapper->current_connectivity_state = conn_state; + gpr_cv_signal(&wrapper->channel_cv); + } // avoid posting work to the channel polling cq if it's been shutdown if (!abort_channel_polling && conn_state != GRPC_CHANNEL_SHUTDOWN) { grpc_channel_watch_connectivity_state( wrapper->wrapped, conn_state, sleep_time, channel_polling_cq, wrapper); } else { wrapper->safe_to_destroy = 1; - gpr_cv_signal(&wrapper->safe_destroy_cv); + gpr_cv_signal(&wrapper->channel_cv); } + gpr_mu_unlock(&wrapper->channel_mu); gpr_mu_unlock(&channel_polling_mu); - gpr_mu_unlock(&wrapper->safe_destroy_mu); + gpr_mu_unlock(&wrapper->channel_mu); } -// Note requires wrapper->wrapped, wrapper->safe_destroy_mu/cv initialized +// Note requires wrapper->wrapped, wrapper->channel_mu/cv initialized static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper) { - gpr_mu_lock(&wrapper->safe_destroy_mu); + gpr_mu_lock(&wrapper->channel_mu); while (!wrapper->safe_to_destroy) { wrapper->request_safe_destroy = 1; - gpr_cv_wait(&wrapper->safe_destroy_cv, &wrapper->safe_destroy_mu, + gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } GPR_ASSERT(wrapper->safe_to_destroy); - gpr_mu_unlock(&wrapper->safe_destroy_mu); + gpr_mu_unlock(&wrapper->channel_mu); - gpr_mu_destroy(&wrapper->safe_destroy_mu); - gpr_cv_destroy(&wrapper->safe_destroy_cv); + gpr_mu_destroy(&wrapper->channel_mu); + gpr_cv_destroy(&wrapper->channel_cv); grpc_channel_destroy(wrapper->wrapped); } @@ -434,6 +464,7 @@ static void *run_poll_channels_loop_no_gil(void *arg) { } if (event.type == GRPC_OP_COMPLETE) { wrapper = (grpc_rb_channel *)event.tag; + grpc_rb_channel_try_register_connection_polling(wrapper); } } @@ -524,7 +555,7 @@ void Init_grpc_channel() { rb_define_method(grpc_rb_cChannel, "connectivity_state", grpc_rb_channel_get_connectivity_state, -1); rb_define_method(grpc_rb_cChannel, "watch_connectivity_state", - grpc_rb_channel_watch_connectivity_state, 4); + grpc_rb_channel_watch_connectivity_state, 2); rb_define_method(grpc_rb_cChannel, "create_call", grpc_rb_channel_create_call, 5); rb_define_method(grpc_rb_cChannel, "target", grpc_rb_channel_get_target, 0); diff --git a/src/ruby/spec/channel_connection_spec.rb b/src/ruby/spec/channel_connection_spec.rb index 58ab37d7bc..d8e10f7b76 100644 --- a/src/ruby/spec/channel_connection_spec.rb +++ b/src/ruby/spec/channel_connection_spec.rb @@ -90,4 +90,53 @@ describe 'channel connection behavior' do expect(stub.an_rpc(req)).to be_a(EchoMsg) stop_server end + + it 'observably connects and reconnects to transient server when using the channel state API', trial: true do + port = start_server + ch = GRPC::Core::Channel.new("localhost:#{port}", {}, :this_channel_is_insecure) + + expect(ch.connectivity_state).to be(GRPC::Core::ConnectivityStates::IDLE) + + state = ch.connectivity_state(true) + + count = 0 + while count < 20 and state != GRPC::Core::ConnectivityStates::READY do + STDERR.puts "first round of waiting for state to become READY" + ch.watch_connectivity_state(state, Time.now + 60) + state = ch.connectivity_state(true) + count += 1 + end + + expect(state).to be(GRPC::Core::ConnectivityStates::READY) + + stop_server + + state = ch.connectivity_state + + count = 0 + while count < 20 and state == GRPC::Core::ConnectivityStates::READY do + STDERR.puts "server shut down. waiting for state to not be READY" + ch.watch_connectivity_state(state, Time.now + 60) + state = ch.connectivity_state + count += 1 + end + + expect(state).to_not be(GRPC::Core::ConnectivityStates::READY) + + start_server(port) + + state = ch.connectivity_state(true) + + count = 0 + while count < 20 and state != GRPC::Core::ConnectivityStates::READY do + STDERR.puts "second round of waiting for state to become READY" + ch.watch_connectivity_state(state, Time.now + 60) + state = ch.connectivity_state(true) + count += 1 + end + + expect(state).to be(GRPC::Core::ConnectivityStates::READY) + + stop_server + end end -- cgit v1.2.3 From 62e9596c614b5570d6a8811851aec12faf6a30fc Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 14 Mar 2017 13:00:11 -0700 Subject: Advance ProtoCompiler version --- src/objective-c/!ProtoCompiler.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/!ProtoCompiler.podspec b/src/objective-c/!ProtoCompiler.podspec index dc4d8e964e..2e9b944f33 100644 --- a/src/objective-c/!ProtoCompiler.podspec +++ b/src/objective-c/!ProtoCompiler.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler' - v = '3.1.0' + v = '3.2.0' s.version = v s.summary = 'The Protobuf Compiler (protoc) generates Objective-C files from .proto files' s.description = <<-DESC @@ -110,7 +110,7 @@ Pod::Spec.new do |s| # Restrict the protobuf runtime version to the one supported by this version of protoc. s.dependency 'Protobuf', '~> 3.0' # For the Protobuf dependency not to complain: - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' # This is only for local development of protoc: If the Podfile brings this pod from a local -- cgit v1.2.3 From c6f3a00b1364961d9f9f9beea7eba6756fee954a Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Tue, 14 Mar 2017 01:16:09 -0700 Subject: Fix SetSocketMutator --- src/cpp/common/channel_arguments.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index 65f3277499..33a10c0b8e 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -101,8 +101,10 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) { for (auto it = args_.begin(); it != args_.end(); ++it) { if (it->type == mutator_arg.type && grpc::string(it->key) == grpc::string(mutator_arg.key)) { + GPR_ASSERT(!replaced); it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p); it->value.pointer = mutator_arg.value.pointer; + replaced = true; } } grpc_exec_ctx_finish(&exec_ctx); -- cgit v1.2.3 From be30114a3b95b6dc843f8338d2b8a5470bec2553 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 14 Mar 2017 16:33:44 -0700 Subject: fix up tests and remove two unlocks in a row bug --- examples/ruby/greeter_client.rb | 32 +++++++++++++++++++++++++++++-- src/ruby/ext/grpc/rb_channel.c | 33 +++++++++++++++----------------- src/ruby/spec/channel_connection_spec.rb | 19 +++++++++--------- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/examples/ruby/greeter_client.rb b/examples/ruby/greeter_client.rb index 1cdf79ebf4..379f41536e 100755 --- a/examples/ruby/greeter_client.rb +++ b/examples/ruby/greeter_client.rb @@ -40,11 +40,39 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) require 'grpc' require 'helloworld_services_pb' +$int_count = 0 + +def shut_down_term + puts "term sig" + $int_count += 1 + if $int_count > 4 + exit + end +end + +def shut_down_kill + puts "kill sig" + $int_count += 1 + if $int_count > 4 + exit + end +end + + def main stub = Helloworld::Greeter::Stub.new('localhost:50051', :this_channel_is_insecure) user = ARGV.size > 0 ? ARGV[0] : 'world' - message = stub.say_hello(Helloworld::HelloRequest.new(name: user)).message - p "Greeting: #{message}" + Signal.trap("TERM") do + shut_down_term + end + Signal.trap("INT") do + shut_down_kill + end + loop do + message = stub.say_hello(Helloworld::HelloRequest.new(name: user)).message + p "Greeting: #{message}" + sleep 4 + end end main diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 8cd489345d..d143c54d21 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -89,7 +89,7 @@ static void grpc_rb_channel_try_register_connection_polling( static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper); static grpc_completion_queue *channel_polling_cq; -static gpr_mu channel_polling_mu; +static gpr_mu global_connection_polling_mu; static int abort_channel_polling = 0; /* Destroys Channel instances. */ @@ -188,13 +188,13 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { gpr_mu_lock(&wrapper->channel_mu); wrapper->current_connectivity_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); - gpr_cv_signal(&wrapper->channel_cv); - gpr_mu_unlock(&wrapper->channel_mu); - - gpr_mu_lock(&wrapper->channel_mu); wrapper->safe_to_destroy = 0; wrapper->request_safe_destroy = 0; + + gpr_cv_signal(&wrapper->channel_cv); gpr_mu_unlock(&wrapper->channel_mu); + + grpc_rb_channel_try_register_connection_polling(wrapper); if (args.args != NULL) { @@ -277,7 +277,6 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, } if (wrapper->safe_to_destroy) { gpr_mu_unlock(&wrapper->channel_mu); - gpr_log(GPR_DEBUG, "GRPC_RUBY_RB_CHANNEL: attempt to watch_connectivity_state on a non-state-polled channel"); return Qfalse; } gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, grpc_rb_time_timeval(deadline, /* absolute time */ 0)); @@ -394,7 +393,7 @@ static VALUE grpc_rb_channel_get_target(VALUE self) { // destroy. // Not safe to call while a channel's connection state is polled. static void grpc_rb_channel_try_register_connection_polling( - grpc_rb_channel *wrapper) { + grpc_rb_channel *wrapper) { grpc_connectivity_state conn_state; gpr_timespec sleep_time = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); @@ -408,9 +407,8 @@ static void grpc_rb_channel_try_register_connection_polling( gpr_mu_unlock(&wrapper->channel_mu); return; } - gpr_mu_lock(&channel_polling_mu); + gpr_mu_lock(&global_connection_polling_mu); - gpr_mu_lock(&wrapper->channel_mu); conn_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); if (conn_state != wrapper->current_connectivity_state) { wrapper->current_connectivity_state = conn_state; @@ -424,8 +422,7 @@ static void grpc_rb_channel_try_register_connection_polling( wrapper->safe_to_destroy = 1; gpr_cv_signal(&wrapper->channel_cv); } - gpr_mu_unlock(&wrapper->channel_mu); - gpr_mu_unlock(&channel_polling_mu); + gpr_mu_unlock(&global_connection_polling_mu); gpr_mu_unlock(&wrapper->channel_mu); } @@ -454,7 +451,6 @@ static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper) { // early and falls back to current behavior. static void *run_poll_channels_loop_no_gil(void *arg) { grpc_event event; - grpc_rb_channel *wrapper; (void)arg; for (;;) { event = grpc_completion_queue_next( @@ -463,27 +459,28 @@ static void *run_poll_channels_loop_no_gil(void *arg) { break; } if (event.type == GRPC_OP_COMPLETE) { - wrapper = (grpc_rb_channel *)event.tag; - - grpc_rb_channel_try_register_connection_polling(wrapper); + grpc_rb_channel_try_register_connection_polling((grpc_rb_channel *)event.tag); } } grpc_completion_queue_destroy(channel_polling_cq); + gpr_log(GPR_DEBUG, "GRPC_RUBY: run_poll_channels_loop_no_gil - exit connection polling loop"); return NULL; } // Notify the channel polling loop to cleanup and shutdown. static void grpc_rb_event_unblocking_func(void *arg) { (void)arg; - gpr_mu_lock(&channel_polling_mu); + gpr_mu_lock(&global_connection_polling_mu); + gpr_log(GPR_DEBUG, "GRPC_RUBY: grpc_rb_event_unblocking_func - begin aborting connection polling"); abort_channel_polling = 1; grpc_completion_queue_shutdown(channel_polling_cq); - gpr_mu_unlock(&channel_polling_mu); + gpr_mu_unlock(&global_connection_polling_mu); } // Poll channel connectivity states in background thread without the GIL. static VALUE run_poll_channels_loop(VALUE arg) { (void)arg; + gpr_log(GPR_DEBUG, "GRPC_RUBY: run_poll_channels_loop - create connection polling thread"); rb_thread_call_without_gvl(run_poll_channels_loop_no_gil, NULL, grpc_rb_event_unblocking_func, NULL); return Qnil; @@ -501,7 +498,7 @@ static VALUE run_poll_channels_loop(VALUE arg) { */ static void start_poll_channels_loop() { channel_polling_cq = grpc_completion_queue_create(NULL); - gpr_mu_init(&channel_polling_mu); + gpr_mu_init(&global_connection_polling_mu); abort_channel_polling = 0; rb_thread_create(run_poll_channels_loop, NULL); } diff --git a/src/ruby/spec/channel_connection_spec.rb b/src/ruby/spec/channel_connection_spec.rb index d8e10f7b76..b344052a21 100644 --- a/src/ruby/spec/channel_connection_spec.rb +++ b/src/ruby/spec/channel_connection_spec.rb @@ -63,7 +63,7 @@ EchoStub = EchoService.rpc_stub_class def start_server(port = 0) @srv = GRPC::RpcServer.new - server_port = @srv.add_http2_port("0.0.0.0:#{port}", :this_port_is_insecure) + server_port = @srv.add_http2_port("localhost:#{port}", :this_port_is_insecure) @srv.handle(EchoService) @server_thd = Thread.new { @srv.run } @srv.wait_till_running @@ -84,24 +84,25 @@ describe 'channel connection behavior' do req = EchoMsg.new expect(stub.an_rpc(req)).to be_a(EchoMsg) stop_server - expect { stub.an_rpc(req) }.to raise_error(GRPC::Unavailable) + sleep 1 # TODO(apolcyn) grabbing the same port might fail, is this stable enough? start_server(port) expect(stub.an_rpc(req)).to be_a(EchoMsg) stop_server end - it 'observably connects and reconnects to transient server when using the channel state API', trial: true do + it 'observably connects and reconnects to transient server' \ + 'when using the channel state API' do port = start_server - ch = GRPC::Core::Channel.new("localhost:#{port}", {}, :this_channel_is_insecure) + ch = GRPC::Core::Channel.new("localhost:#{port}", {}, + :this_channel_is_insecure) expect(ch.connectivity_state).to be(GRPC::Core::ConnectivityStates::IDLE) state = ch.connectivity_state(true) count = 0 - while count < 20 and state != GRPC::Core::ConnectivityStates::READY do - STDERR.puts "first round of waiting for state to become READY" + while count < 20 && state != GRPC::Core::ConnectivityStates::READY ch.watch_connectivity_state(state, Time.now + 60) state = ch.connectivity_state(true) count += 1 @@ -114,8 +115,7 @@ describe 'channel connection behavior' do state = ch.connectivity_state count = 0 - while count < 20 and state == GRPC::Core::ConnectivityStates::READY do - STDERR.puts "server shut down. waiting for state to not be READY" + while count < 20 && state == GRPC::Core::ConnectivityStates::READY ch.watch_connectivity_state(state, Time.now + 60) state = ch.connectivity_state count += 1 @@ -128,8 +128,7 @@ describe 'channel connection behavior' do state = ch.connectivity_state(true) count = 0 - while count < 20 and state != GRPC::Core::ConnectivityStates::READY do - STDERR.puts "second round of waiting for state to become READY" + while count < 20 && state != GRPC::Core::ConnectivityStates::READY ch.watch_connectivity_state(state, Time.now + 60) state = ch.connectivity_state(true) count += 1 -- cgit v1.2.3 From c44c16e330a8532c8c917c2aa64ffd1aeafe0126 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 14 Mar 2017 17:44:21 -0700 Subject: add initial framework for full end2end tests outside of rspec --- src/ruby/end2end/echo_server.rb | 68 ++++++++++++++++ src/ruby/end2end/gen_protos.sh | 2 + src/ruby/end2end/lib/client_control_pb.rb | 21 +++++ src/ruby/end2end/lib/client_control_services_pb.rb | 54 +++++++++++++ src/ruby/end2end/lib/echo_pb.rb | 18 +++++ src/ruby/end2end/lib/echo_services_pb.rb | 52 +++++++++++++ src/ruby/end2end/protos/client_control.proto | 48 ++++++++++++ src/ruby/end2end/protos/echo.proto | 46 +++++++++++ src/ruby/end2end/sig_handling_client.rb | 91 ++++++++++++++++++++++ src/ruby/end2end/sig_handling_driver.rb | 88 +++++++++++++++++++++ src/ruby/qps/worker.rb | 2 + .../helper_scripts/run_ruby_end2end_tests.sh | 36 +++++++++ tools/run_tests/run_tests.py | 11 ++- 13 files changed, 534 insertions(+), 3 deletions(-) create mode 100755 src/ruby/end2end/echo_server.rb create mode 100644 src/ruby/end2end/gen_protos.sh create mode 100644 src/ruby/end2end/lib/client_control_pb.rb create mode 100644 src/ruby/end2end/lib/client_control_services_pb.rb create mode 100644 src/ruby/end2end/lib/echo_pb.rb create mode 100644 src/ruby/end2end/lib/echo_services_pb.rb create mode 100644 src/ruby/end2end/protos/client_control.proto create mode 100644 src/ruby/end2end/protos/echo.proto create mode 100755 src/ruby/end2end/sig_handling_client.rb create mode 100755 src/ruby/end2end/sig_handling_driver.rb create mode 100755 tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh diff --git a/src/ruby/end2end/echo_server.rb b/src/ruby/end2end/echo_server.rb new file mode 100755 index 0000000000..5e80740aa0 --- /dev/null +++ b/src/ruby/end2end/echo_server.rb @@ -0,0 +1,68 @@ +#!/usr/bin/env ruby + +# Copyright 2015, 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. + +this_dir = File.expand_path(File.dirname(__FILE__)) +protos_lib_dir = File.join(this_dir, 'lib') +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) +$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) +$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) + +require 'grpc' +require 'echo_services_pb' + +# GreeterServer is simple server that implements the Helloworld Greeter server. +class EchoServerImpl < Echo::EchoServer::Service + # say_hello implements the SayHello rpc method. + def echo(echo_req, _) + Echo::EchoReply.new(response: echo_req.request) + end +end + +class ServerRunner + def initialize(port) + @port = port + end + def run + @srv = GRPC::RpcServer.new + @thd = Thread.new do + @srv.add_http2_port("localhost:#{@port}", :this_port_is_insecure) + @srv.handle(EchoServerImpl) + @srv.run + end + @srv.wait_till_running + end + def stop + @srv.stop + @thd.join + raise "server not stopped" unless @srv.stopped? + end +end diff --git a/src/ruby/end2end/gen_protos.sh b/src/ruby/end2end/gen_protos.sh new file mode 100644 index 0000000000..c26b5572da --- /dev/null +++ b/src/ruby/end2end/gen_protos.sh @@ -0,0 +1,2 @@ +#!/bin/bash +grpc_tools_ruby_protoc -I protos --ruby_out=lib --grpc_out=lib protos/echo.proto protos/client_control.proto diff --git a/src/ruby/end2end/lib/client_control_pb.rb b/src/ruby/end2end/lib/client_control_pb.rb new file mode 100644 index 0000000000..866095a80a --- /dev/null +++ b/src/ruby/end2end/lib/client_control_pb.rb @@ -0,0 +1,21 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: client_control.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "client_control.DoEchoRpcRequest" do + optional :request, :string, 1 + end + add_message "client_control.CreateClientStubRequest" do + optional :server_address, :string, 1 + end + add_message "client_control.Void" do + end +end + +module ClientControl + DoEchoRpcRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("client_control.DoEchoRpcRequest").msgclass + CreateClientStubRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("client_control.CreateClientStubRequest").msgclass + Void = Google::Protobuf::DescriptorPool.generated_pool.lookup("client_control.Void").msgclass +end diff --git a/src/ruby/end2end/lib/client_control_services_pb.rb b/src/ruby/end2end/lib/client_control_services_pb.rb new file mode 100644 index 0000000000..4c31f3e590 --- /dev/null +++ b/src/ruby/end2end/lib/client_control_services_pb.rb @@ -0,0 +1,54 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: client_control.proto for package 'client_control' +# Original file comments: +# Copyright 2015, 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. +# + +require 'grpc' +require 'client_control_pb' + +module ClientControl + module ClientController + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'client_control.ClientController' + + rpc :DoEchoRpc, DoEchoRpcRequest, Void + rpc :CreateClientStub, CreateClientStubRequest, Void + rpc :Shutdown, Void, Void + end + + Stub = Service.rpc_stub_class + end +end diff --git a/src/ruby/end2end/lib/echo_pb.rb b/src/ruby/end2end/lib/echo_pb.rb new file mode 100644 index 0000000000..c62adc0753 --- /dev/null +++ b/src/ruby/end2end/lib/echo_pb.rb @@ -0,0 +1,18 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: echo.proto + +require 'google/protobuf' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "echo.EchoRequest" do + optional :request, :string, 1 + end + add_message "echo.EchoReply" do + optional :response, :string, 1 + end +end + +module Echo + EchoRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("echo.EchoRequest").msgclass + EchoReply = Google::Protobuf::DescriptorPool.generated_pool.lookup("echo.EchoReply").msgclass +end diff --git a/src/ruby/end2end/lib/echo_services_pb.rb b/src/ruby/end2end/lib/echo_services_pb.rb new file mode 100644 index 0000000000..c66e975bf3 --- /dev/null +++ b/src/ruby/end2end/lib/echo_services_pb.rb @@ -0,0 +1,52 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: echo.proto for package 'echo' +# Original file comments: +# Copyright 2015, 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. +# + +require 'grpc' +require 'echo_pb' + +module Echo + module EchoServer + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'echo.EchoServer' + + rpc :Echo, EchoRequest, EchoReply + end + + Stub = Service.rpc_stub_class + end +end diff --git a/src/ruby/end2end/protos/client_control.proto b/src/ruby/end2end/protos/client_control.proto new file mode 100644 index 0000000000..5e11876cb4 --- /dev/null +++ b/src/ruby/end2end/protos/client_control.proto @@ -0,0 +1,48 @@ +// Copyright 2015, 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. + +syntax = "proto3"; + +package client_control; + +service ClientController { + rpc DoEchoRpc (DoEchoRpcRequest) returns (Void) {} + rpc CreateClientStub(CreateClientStubRequest) returns (Void) {} + rpc Shutdown(Void) returns (Void) {} +} + +message DoEchoRpcRequest { + string request = 1; +} + +message CreateClientStubRequest { + string server_address = 1; +} + +message Void{} diff --git a/src/ruby/end2end/protos/echo.proto b/src/ruby/end2end/protos/echo.proto new file mode 100644 index 0000000000..d47afef70f --- /dev/null +++ b/src/ruby/end2end/protos/echo.proto @@ -0,0 +1,46 @@ +// Copyright 2015, 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. + +syntax = "proto3"; + +package echo; + +service EchoServer { + rpc Echo (EchoRequest) returns (EchoReply) {} +} + +// The request message containing the user's name. +message EchoRequest { + string request = 1; +} + +// The response message containing the greetings +message EchoReply { + string response = 1; +} diff --git a/src/ruby/end2end/sig_handling_client.rb b/src/ruby/end2end/sig_handling_client.rb new file mode 100755 index 0000000000..860c6b5f0d --- /dev/null +++ b/src/ruby/end2end/sig_handling_client.rb @@ -0,0 +1,91 @@ +#!/usr/bin/env ruby + +# Copyright 2015, 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. + +this_dir = File.expand_path(File.dirname(__FILE__)) +protos_lib_dir = File.join(this_dir, 'lib') +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) +$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) +$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) + +require 'grpc' +require 'echo_services_pb' +require 'client_control_services_pb' +require 'optparse' +require 'thread' + +class SigHandlingClientController < ClientControl::ClientController::Service + def initialize(srv) + @srv = srv + end + def do_echo_rpc(req, _) + response = @stub.echo(Echo::EchoRequest.new(request: req.request)) + raise "bad response" unless response.response == req.request + ClientControl::Void.new + end + def create_client_stub(req, _) + @stub = Echo::EchoServer::Stub.new(req.server_address, :this_channel_is_insecure) + ClientControl::Void.new + end + def shutdown(_, _) + Thread.new do + #TODO(apolcyn) There is a race between stopping the server and the "shutdown" rpc completing, + # See if stop method on server can end active RPC cleanly, to avoid this sleep. + sleep 3 + @srv.stop + end + ClientControl::Void.new + end +end + +def main + client_control_port = '' + OptionParser.new do |opts| + opts.on('--client_control_port=P', String) do |p| + client_control_port = p + end + end.parse! + + Signal.trap("TERM") do + STDERR.puts "SIGTERM received" + end + + Signal.trap("INT") do + STDERR.puts "SIGINT received" + end + + srv = GRPC::RpcServer.new + srv.add_http2_port("localhost:#{client_control_port}", :this_port_is_insecure) + srv.handle(SigHandlingClientController.new(srv)) + srv.run +end + +main diff --git a/src/ruby/end2end/sig_handling_driver.rb b/src/ruby/end2end/sig_handling_driver.rb new file mode 100755 index 0000000000..524f0cebe8 --- /dev/null +++ b/src/ruby/end2end/sig_handling_driver.rb @@ -0,0 +1,88 @@ +#!/usr/bin/env ruby + +# Copyright 2016, 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. + +# smoke test for a grpc-using app that receives and +# handles process-ending signals + +this_dir = File.expand_path(File.dirname(__FILE__)) +protos_lib_dir = File.join(this_dir, 'lib') +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) +$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) +$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) + +require 'grpc' +require 'echo_server' +require 'client_control_services_pb' + +def main + this_dir = File.expand_path(File.dirname(__FILE__)) + lib_dir = File.join(File.dirname(this_dir), 'lib') + + server_port = '50051' + STDERR.puts "start server" + server_runner = ServerRunner.new(server_port) + server_runner.run + + sleep 1 + + client_control_port = '50052' + + STDERR.puts "start client" + client_path = File.join(this_dir, "sig_handling_client.rb") + client_pid = Process.spawn(RbConfig.ruby, client_path, "--client_control_port=#{client_control_port}") + control_stub = ClientControl::ClientController::Stub.new("localhost:#{client_control_port}", :this_channel_is_insecure) + + sleep 1 + + control_stub.create_client_stub(ClientControl::CreateClientStubRequest.new(server_address: "localhost:#{server_port}")) + + count = 0 + while count < 5 + control_stub.do_echo_rpc(ClientControl::DoEchoRpcRequest.new(request: 'hello')) + Process.kill('SIGTERM', client_pid) + Process.kill('SIGINT', client_pid) + count += 1 + end + + control_stub.shutdown(ClientControl::Void.new) + Process.wait(client_pid) + + client_exit_code = $?.exitstatus + + if client_exit_code != 0 + raise "term sig test failure: client exit code: #{client_exit_code}" + end + + server_runner.stop +end + +main diff --git a/src/ruby/qps/worker.rb b/src/ruby/qps/worker.rb index 61a0b723a3..318c1f9e22 100755 --- a/src/ruby/qps/worker.rb +++ b/src/ruby/qps/worker.rb @@ -36,6 +36,8 @@ lib_dir = File.join(File.dirname(this_dir), 'lib') $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) +puts $LOAD_PATH + require 'grpc' require 'optparse' require 'histogram' diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh new file mode 100755 index 0000000000..7ccbcfca70 --- /dev/null +++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright 2015, 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. + +set -ex + +# change to grpc repo root +cd $(dirname $0)/../../.. + +ruby src/ruby/end2end/sig_handling_driver.rb diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 43b8f8184e..dc17e738e6 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -692,9 +692,14 @@ class RubyLanguage(object): _check_compiler(self.args.compiler, ['default']) def test_specs(self): - return [self.config.job_spec(['tools/run_tests/helper_scripts/run_ruby.sh'], - timeout_seconds=10*60, - environ=_FORCE_ENVIRON_FOR_WRAPPERS)] + tests = [self.config.job_spec(['tools/run_tests/helper_scripts/run_ruby.sh'], + timeout_seconds=10*60, + environ=_FORCE_ENVIRON_FOR_WRAPPERS)] + # note these aren't getting ran on windows since no workers + tests.append(self.config.job_spec(['tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh'], + timeout_seconds=10*60, + environ=_FORCE_ENVIRON_FOR_WRAPPERS)) + return tests def pre_build_steps(self): return [['tools/run_tests/helper_scripts/pre_build_ruby.sh']] -- cgit v1.2.3 From 7a32e8a499e94efb5dab6e19459f9b9968382000 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 14 Mar 2017 23:35:29 -0700 Subject: Revert changes to example greeter client --- examples/ruby/greeter_client.rb | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/examples/ruby/greeter_client.rb b/examples/ruby/greeter_client.rb index 379f41536e..1cdf79ebf4 100755 --- a/examples/ruby/greeter_client.rb +++ b/examples/ruby/greeter_client.rb @@ -40,39 +40,11 @@ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) require 'grpc' require 'helloworld_services_pb' -$int_count = 0 - -def shut_down_term - puts "term sig" - $int_count += 1 - if $int_count > 4 - exit - end -end - -def shut_down_kill - puts "kill sig" - $int_count += 1 - if $int_count > 4 - exit - end -end - - def main stub = Helloworld::Greeter::Stub.new('localhost:50051', :this_channel_is_insecure) user = ARGV.size > 0 ? ARGV[0] : 'world' - Signal.trap("TERM") do - shut_down_term - end - Signal.trap("INT") do - shut_down_kill - end - loop do - message = stub.say_hello(Helloworld::HelloRequest.new(name: user)).message - p "Greeting: #{message}" - sleep 4 - end + message = stub.say_hello(Helloworld::HelloRequest.new(name: user)).message + p "Greeting: #{message}" end main -- cgit v1.2.3 From f8dc32e9e2153b2ea97091b611d8c83cbc37c05e Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 00:04:33 -0700 Subject: make end2end test ports dynamic and slight refactor --- src/ruby/end2end/echo_server.rb | 68 -------------- src/ruby/end2end/end2end_common.rb | 102 +++++++++++++++++++++ src/ruby/end2end/lib/client_control_pb.rb | 4 - src/ruby/end2end/lib/client_control_services_pb.rb | 1 - src/ruby/end2end/protos/client_control.proto | 5 - src/ruby/end2end/sig_handling_client.rb | 29 ++---- src/ruby/end2end/sig_handling_driver.rb | 38 +------- 7 files changed, 117 insertions(+), 130 deletions(-) delete mode 100755 src/ruby/end2end/echo_server.rb create mode 100755 src/ruby/end2end/end2end_common.rb diff --git a/src/ruby/end2end/echo_server.rb b/src/ruby/end2end/echo_server.rb deleted file mode 100755 index 5e80740aa0..0000000000 --- a/src/ruby/end2end/echo_server.rb +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env ruby - -# Copyright 2015, 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. - -this_dir = File.expand_path(File.dirname(__FILE__)) -protos_lib_dir = File.join(this_dir, 'lib') -grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') -$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) -$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) -$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) - -require 'grpc' -require 'echo_services_pb' - -# GreeterServer is simple server that implements the Helloworld Greeter server. -class EchoServerImpl < Echo::EchoServer::Service - # say_hello implements the SayHello rpc method. - def echo(echo_req, _) - Echo::EchoReply.new(response: echo_req.request) - end -end - -class ServerRunner - def initialize(port) - @port = port - end - def run - @srv = GRPC::RpcServer.new - @thd = Thread.new do - @srv.add_http2_port("localhost:#{@port}", :this_port_is_insecure) - @srv.handle(EchoServerImpl) - @srv.run - end - @srv.wait_till_running - end - def stop - @srv.stop - @thd.join - raise "server not stopped" unless @srv.stopped? - end -end diff --git a/src/ruby/end2end/end2end_common.rb b/src/ruby/end2end/end2end_common.rb new file mode 100755 index 0000000000..67961cdf97 --- /dev/null +++ b/src/ruby/end2end/end2end_common.rb @@ -0,0 +1,102 @@ +#!/usr/bin/env ruby + +# Copyright 2015, 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. + +this_dir = File.expand_path(File.dirname(__FILE__)) +protos_lib_dir = File.join(this_dir, 'lib') +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) +$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) +$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) + +require 'grpc' +require 'echo_services_pb' +require 'client_control_services_pb' +require 'socket' +require 'optparse' +require 'thread' + +# GreeterServer is simple server that implements the Helloworld Greeter server. +class EchoServerImpl < Echo::EchoServer::Service + # say_hello implements the SayHello rpc method. + def echo(echo_req, _) + Echo::EchoReply.new(response: echo_req.request) + end +end + +class ServerRunner + def initialize + end + def run + @srv = GRPC::RpcServer.new + port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure) + @srv.handle(EchoServerImpl) + + @thd = Thread.new do + @srv.run + end + @srv.wait_till_running + port + end + def stop + @srv.stop + @thd.join + raise "server not stopped" unless @srv.stopped? + end +end + +def start_client(client_main, server_port) + this_dir = File.expand_path(File.dirname(__FILE__)) + + tmp_server = TCPServer.new(0) + client_control_port = tmp_server.local_address.ip_port + tmp_server.close + + client_path = File.join(this_dir, client_main) + client_pid = Process.spawn(RbConfig.ruby, client_path, + "--client_control_port=#{client_control_port}", + "--server_port=#{server_port}") + sleep 1 + control_stub = ClientControl::ClientController::Stub.new("localhost:#{client_control_port}", :this_channel_is_insecure) + return control_stub, client_pid +end + +def cleanup(control_stub, server_runner) + control_stub.shutdown(ClientControl::Void.new) + Process.wait(client_pid) + + client_exit_code = $?.exitstatus + + if client_exit_code != 0 + raise "term sig test failure: client exit code: #{client_exit_code}" + end + + server_runner.stop +end diff --git a/src/ruby/end2end/lib/client_control_pb.rb b/src/ruby/end2end/lib/client_control_pb.rb index 866095a80a..1a938f1b5a 100644 --- a/src/ruby/end2end/lib/client_control_pb.rb +++ b/src/ruby/end2end/lib/client_control_pb.rb @@ -7,15 +7,11 @@ Google::Protobuf::DescriptorPool.generated_pool.build do add_message "client_control.DoEchoRpcRequest" do optional :request, :string, 1 end - add_message "client_control.CreateClientStubRequest" do - optional :server_address, :string, 1 - end add_message "client_control.Void" do end end module ClientControl DoEchoRpcRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("client_control.DoEchoRpcRequest").msgclass - CreateClientStubRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("client_control.CreateClientStubRequest").msgclass Void = Google::Protobuf::DescriptorPool.generated_pool.lookup("client_control.Void").msgclass end diff --git a/src/ruby/end2end/lib/client_control_services_pb.rb b/src/ruby/end2end/lib/client_control_services_pb.rb index 4c31f3e590..04b2291bc7 100644 --- a/src/ruby/end2end/lib/client_control_services_pb.rb +++ b/src/ruby/end2end/lib/client_control_services_pb.rb @@ -45,7 +45,6 @@ module ClientControl self.service_name = 'client_control.ClientController' rpc :DoEchoRpc, DoEchoRpcRequest, Void - rpc :CreateClientStub, CreateClientStubRequest, Void rpc :Shutdown, Void, Void end diff --git a/src/ruby/end2end/protos/client_control.proto b/src/ruby/end2end/protos/client_control.proto index 5e11876cb4..f985bb486d 100644 --- a/src/ruby/end2end/protos/client_control.proto +++ b/src/ruby/end2end/protos/client_control.proto @@ -33,7 +33,6 @@ package client_control; service ClientController { rpc DoEchoRpc (DoEchoRpcRequest) returns (Void) {} - rpc CreateClientStub(CreateClientStubRequest) returns (Void) {} rpc Shutdown(Void) returns (Void) {} } @@ -41,8 +40,4 @@ message DoEchoRpcRequest { string request = 1; } -message CreateClientStubRequest { - string server_address = 1; -} - message Void{} diff --git a/src/ruby/end2end/sig_handling_client.rb b/src/ruby/end2end/sig_handling_client.rb index 860c6b5f0d..f0b2ba61ca 100755 --- a/src/ruby/end2end/sig_handling_client.rb +++ b/src/ruby/end2end/sig_handling_client.rb @@ -29,32 +29,18 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -this_dir = File.expand_path(File.dirname(__FILE__)) -protos_lib_dir = File.join(this_dir, 'lib') -grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') -$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) -$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) -$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) - -require 'grpc' -require 'echo_services_pb' -require 'client_control_services_pb' -require 'optparse' -require 'thread' +require_relative './end2end_common' class SigHandlingClientController < ClientControl::ClientController::Service - def initialize(srv) + def initialize(srv, stub) @srv = srv + @stub = stub end def do_echo_rpc(req, _) response = @stub.echo(Echo::EchoRequest.new(request: req.request)) raise "bad response" unless response.response == req.request ClientControl::Void.new end - def create_client_stub(req, _) - @stub = Echo::EchoServer::Stub.new(req.server_address, :this_channel_is_insecure) - ClientControl::Void.new - end def shutdown(_, _) Thread.new do #TODO(apolcyn) There is a race between stopping the server and the "shutdown" rpc completing, @@ -68,10 +54,14 @@ end def main client_control_port = '' + server_port = '' OptionParser.new do |opts| opts.on('--client_control_port=P', String) do |p| client_control_port = p end + opts.on('--server_port=P', String) do |p| + server_port = p + end end.parse! Signal.trap("TERM") do @@ -83,8 +73,9 @@ def main end srv = GRPC::RpcServer.new - srv.add_http2_port("localhost:#{client_control_port}", :this_port_is_insecure) - srv.handle(SigHandlingClientController.new(srv)) + srv.add_http2_port("0.0.0.0:#{client_control_port}", :this_port_is_insecure) + stub = Echo::EchoServer::Stub.new("localhost:#{server_port}", :this_channel_is_insecure) + srv.handle(SigHandlingClientController.new(srv, stub)) srv.run end diff --git a/src/ruby/end2end/sig_handling_driver.rb b/src/ruby/end2end/sig_handling_driver.rb index 524f0cebe8..bda5c03c16 100755 --- a/src/ruby/end2end/sig_handling_driver.rb +++ b/src/ruby/end2end/sig_handling_driver.rb @@ -32,39 +32,20 @@ # smoke test for a grpc-using app that receives and # handles process-ending signals -this_dir = File.expand_path(File.dirname(__FILE__)) -protos_lib_dir = File.join(this_dir, 'lib') -grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') -$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) -$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) -$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) - -require 'grpc' -require 'echo_server' -require 'client_control_services_pb' +require_relative './end2end_common' def main - this_dir = File.expand_path(File.dirname(__FILE__)) - lib_dir = File.join(File.dirname(this_dir), 'lib') - - server_port = '50051' STDERR.puts "start server" - server_runner = ServerRunner.new(server_port) - server_runner.run + server_runner = ServerRunner.new + server_port = server_runner.run sleep 1 - client_control_port = '50052' - STDERR.puts "start client" - client_path = File.join(this_dir, "sig_handling_client.rb") - client_pid = Process.spawn(RbConfig.ruby, client_path, "--client_control_port=#{client_control_port}") - control_stub = ClientControl::ClientController::Stub.new("localhost:#{client_control_port}", :this_channel_is_insecure) + control_stub, client_pid = start_client("sig_handling_client.rb", server_port) sleep 1 - control_stub.create_client_stub(ClientControl::CreateClientStubRequest.new(server_address: "localhost:#{server_port}")) - count = 0 while count < 5 control_stub.do_echo_rpc(ClientControl::DoEchoRpcRequest.new(request: 'hello')) @@ -73,16 +54,7 @@ def main count += 1 end - control_stub.shutdown(ClientControl::Void.new) - Process.wait(client_pid) - - client_exit_code = $?.exitstatus - - if client_exit_code != 0 - raise "term sig test failure: client exit code: #{client_exit_code}" - end - - server_runner.stop + cleanup(control_stub, server_runner) end main -- cgit v1.2.3 From 16d97edf56b036c28dbe60d1184ef89b71bf8a90 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 10:01:13 -0700 Subject: add failing test revealing bug in channel state api --- src/ruby/end2end/channel_state_client.rb | 53 ++++++++++++++++++ src/ruby/end2end/channel_state_driver.rb | 63 ++++++++++++++++++++++ src/ruby/end2end/end2end_common.rb | 3 +- src/ruby/end2end/sig_handling_driver.rb | 2 +- .../helper_scripts/run_ruby_end2end_tests.sh | 5 +- 5 files changed, 123 insertions(+), 3 deletions(-) create mode 100755 src/ruby/end2end/channel_state_client.rb create mode 100755 src/ruby/end2end/channel_state_driver.rb diff --git a/src/ruby/end2end/channel_state_client.rb b/src/ruby/end2end/channel_state_client.rb new file mode 100755 index 0000000000..476329ff73 --- /dev/null +++ b/src/ruby/end2end/channel_state_client.rb @@ -0,0 +1,53 @@ +#!/usr/bin/env ruby + +# Copyright 2015, 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. + +require_relative './end2end_common' + +def main + server_port = '' + OptionParser.new do |opts| + opts.on('--client_control_port=P', String) do |p| + STDERR.puts "client_control_port ignored" + end + opts.on('--server_port=P', String) do |p| + server_port = p + end + end.parse! + + ch = GRPC::Core::Channel.new("localhost:#{server_port}", {}, :this_channel_is_insecure) + + loop do + state = ch.connectivity_state + ch.watch_connectivity_state(state, Time.now + 360) + end +end + +main diff --git a/src/ruby/end2end/channel_state_driver.rb b/src/ruby/end2end/channel_state_driver.rb new file mode 100755 index 0000000000..cab0147e1f --- /dev/null +++ b/src/ruby/end2end/channel_state_driver.rb @@ -0,0 +1,63 @@ +#!/usr/bin/env ruby + +# Copyright 2016, 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. + +# smoke test for a grpc-using app that receives and +# handles process-ending signals + +require_relative './end2end_common' + +def main + STDERR.puts "start server" + server_runner = ServerRunner.new + server_port = server_runner.run + + sleep 1 + + STDERR.puts "start client" + _, client_pid = start_client("channel_state_client.rb", server_port) + + sleep 3 + + Process.kill('SIGTERM', client_pid) + + begin + Timeout.timeout(10) { Process.wait(client_pid) } + rescue Timeout::Error + STDERR.puts "timeout wait for client pid #{client_pid}" + Process.kill('SIGKILL', client_pid) + Process.wait(client_pid) + raise 'Timed out waiting for client process. It likely hangs' + end + + server_runner.stop +end + +main diff --git a/src/ruby/end2end/end2end_common.rb b/src/ruby/end2end/end2end_common.rb index 67961cdf97..d98e41f642 100755 --- a/src/ruby/end2end/end2end_common.rb +++ b/src/ruby/end2end/end2end_common.rb @@ -42,6 +42,7 @@ require 'client_control_services_pb' require 'socket' require 'optparse' require 'thread' +require 'timeout' # GreeterServer is simple server that implements the Helloworld Greeter server. class EchoServerImpl < Echo::EchoServer::Service @@ -88,7 +89,7 @@ def start_client(client_main, server_port) return control_stub, client_pid end -def cleanup(control_stub, server_runner) +def cleanup(control_stub, client_pid, server_runner) control_stub.shutdown(ClientControl::Void.new) Process.wait(client_pid) diff --git a/src/ruby/end2end/sig_handling_driver.rb b/src/ruby/end2end/sig_handling_driver.rb index bda5c03c16..4d205da9ae 100755 --- a/src/ruby/end2end/sig_handling_driver.rb +++ b/src/ruby/end2end/sig_handling_driver.rb @@ -54,7 +54,7 @@ def main count += 1 end - cleanup(control_stub, server_runner) + cleanup(control_stub, client_pid, server_runner) end main diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh index 7ccbcfca70..518848b950 100755 --- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh +++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh @@ -33,4 +33,7 @@ set -ex # change to grpc repo root cd $(dirname $0)/../../.. -ruby src/ruby/end2end/sig_handling_driver.rb +EXIT_CODE=0 +ruby src/ruby/end2end/sig_handling_driver.rb || EXIT_CODE=1 +ruby src/ruby/end2end/channel_state_driver.rb || EXIT_CODE=1 +exit $EXIT_CODE -- cgit v1.2.3 From f3147b3a7c92212ca6e2289222d9a7d52e0e0f78 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 11:34:08 -0700 Subject: watch channel state without the gil to fix deadlock on abrupt SIGTERM --- src/ruby/end2end/channel_state_driver.rb | 6 +++--- src/ruby/ext/grpc/rb_channel.c | 33 +++++++++++++++++++++++++++----- src/ruby/qps/worker.rb | 2 -- tools/run_tests/run_tests.py | 1 - 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/ruby/end2end/channel_state_driver.rb b/src/ruby/end2end/channel_state_driver.rb index cab0147e1f..8ef32acfff 100755 --- a/src/ruby/end2end/channel_state_driver.rb +++ b/src/ruby/end2end/channel_state_driver.rb @@ -29,8 +29,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# smoke test for a grpc-using app that receives and -# handles process-ending signals +# make sure that the client doesn't hang when process ended abruptly require_relative './end2end_common' @@ -54,7 +53,8 @@ def main STDERR.puts "timeout wait for client pid #{client_pid}" Process.kill('SIGKILL', client_pid) Process.wait(client_pid) - raise 'Timed out waiting for client process. It likely hangs' + STDERR.puts "killed client child" + raise 'Timed out waiting for client process. It likely hangs when ended abruptly' end server_runner.stop diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index d143c54d21..08d48f2a04 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -191,7 +191,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { wrapper->safe_to_destroy = 0; wrapper->request_safe_destroy = 0; - gpr_cv_signal(&wrapper->channel_cv); + gpr_cv_broadcast(&wrapper->channel_cv); gpr_mu_unlock(&wrapper->channel_mu); @@ -241,6 +241,26 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, grpc_channel_check_connectivity_state(ch, grpc_try_to_connect)); } +typedef struct watch_state_stack { + grpc_rb_channel *wrapper; + gpr_timespec deadline; +} watch_state_stack; + +static void *watch_channel_state_without_gvl(void *arg) { + gpr_timespec deadline = ((watch_state_stack*)arg)->deadline; + grpc_rb_channel *wrapper = ((watch_state_stack*)arg)->wrapper; + gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, deadline); + return NULL; +} + +static void watch_channel_state_unblocking_func(void *arg) { + grpc_rb_channel *wrapper = (grpc_rb_channel*)arg; + gpr_log(GPR_DEBUG, "GRPC_RUBY: watch channel state unblocking func called"); + gpr_mu_lock(&wrapper->channel_mu); + gpr_cv_broadcast(&wrapper->channel_cv); + gpr_mu_unlock(&wrapper->channel_mu); +} + /* Wait until the channel's connectivity state becomes different from * "last_state", or "deadline" expires. * Returns true if the the channel's connectivity state becomes @@ -252,6 +272,7 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, VALUE last_state, VALUE deadline) { grpc_rb_channel *wrapper = NULL; + watch_state_stack stack; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); @@ -279,7 +300,9 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, gpr_mu_unlock(&wrapper->channel_mu); return Qfalse; } - gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, grpc_rb_time_timeval(deadline, /* absolute time */ 0)); + stack.wrapper = wrapper; + stack.deadline = grpc_rb_time_timeval(deadline, 0); + rb_thread_call_without_gvl(watch_channel_state_without_gvl, &stack, watch_channel_state_unblocking_func, wrapper); if (wrapper->request_safe_destroy) { gpr_mu_unlock(&wrapper->channel_mu); rb_raise(rb_eRuntimeError, "channel closed during call to watch_connectivity_state"); @@ -403,7 +426,7 @@ static void grpc_rb_channel_try_register_connection_polling( gpr_mu_lock(&wrapper->channel_mu); if (wrapper->request_safe_destroy) { wrapper->safe_to_destroy = 1; - gpr_cv_signal(&wrapper->channel_cv); + gpr_cv_broadcast(&wrapper->channel_cv); gpr_mu_unlock(&wrapper->channel_mu); return; } @@ -412,7 +435,7 @@ static void grpc_rb_channel_try_register_connection_polling( conn_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); if (conn_state != wrapper->current_connectivity_state) { wrapper->current_connectivity_state = conn_state; - gpr_cv_signal(&wrapper->channel_cv); + gpr_cv_broadcast(&wrapper->channel_cv); } // avoid posting work to the channel polling cq if it's been shutdown if (!abort_channel_polling && conn_state != GRPC_CHANNEL_SHUTDOWN) { @@ -420,7 +443,7 @@ static void grpc_rb_channel_try_register_connection_polling( wrapper->wrapped, conn_state, sleep_time, channel_polling_cq, wrapper); } else { wrapper->safe_to_destroy = 1; - gpr_cv_signal(&wrapper->channel_cv); + gpr_cv_broadcast(&wrapper->channel_cv); } gpr_mu_unlock(&global_connection_polling_mu); gpr_mu_unlock(&wrapper->channel_mu); diff --git a/src/ruby/qps/worker.rb b/src/ruby/qps/worker.rb index 318c1f9e22..61a0b723a3 100755 --- a/src/ruby/qps/worker.rb +++ b/src/ruby/qps/worker.rb @@ -36,8 +36,6 @@ lib_dir = File.join(File.dirname(this_dir), 'lib') $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) -puts $LOAD_PATH - require 'grpc' require 'optparse' require 'histogram' diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index dc17e738e6..573196fbb7 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -695,7 +695,6 @@ class RubyLanguage(object): tests = [self.config.job_spec(['tools/run_tests/helper_scripts/run_ruby.sh'], timeout_seconds=10*60, environ=_FORCE_ENVIRON_FOR_WRAPPERS)] - # note these aren't getting ran on windows since no workers tests.append(self.config.job_spec(['tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh'], timeout_seconds=10*60, environ=_FORCE_ENVIRON_FOR_WRAPPERS)) -- cgit v1.2.3 From 70bc4921e15f813c118477e26ea4bc5267b5c7e0 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 14:00:46 -0700 Subject: add another currently failing test related to channels and deadlock --- src/ruby/end2end/channel_closing_client.rb | 80 ++++++++++++++++++++++ src/ruby/end2end/channel_closing_driver.rb | 65 ++++++++++++++++++ .../helper_scripts/run_ruby_end2end_tests.sh | 1 + 3 files changed, 146 insertions(+) create mode 100755 src/ruby/end2end/channel_closing_client.rb create mode 100755 src/ruby/end2end/channel_closing_driver.rb diff --git a/src/ruby/end2end/channel_closing_client.rb b/src/ruby/end2end/channel_closing_client.rb new file mode 100755 index 0000000000..88fa9ae5e6 --- /dev/null +++ b/src/ruby/end2end/channel_closing_client.rb @@ -0,0 +1,80 @@ +#!/usr/bin/env ruby + +# Copyright 2015, 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. + +require_relative './end2end_common' + +class ChannelClosingClientController < ClientControl::ClientController::Service + def initialize(ch) + @ch = ch + end + def shutdown(_, _) + STDERR.puts "about to close channel" + @ch.close + STDERR.puts "just closed channel" + end +end + +def main + client_control_port = '' + server_port = '' + OptionParser.new do |opts| + opts.on('--client_control_port=P', String) do |p| + client_control_port = p + end + opts.on('--server_port=P', String) do |p| + server_port = p + end + end.parse! + + ch = GRPC::Core::Channel.new("localhost:#{server_port}", {}, :this_channel_is_insecure) + + srv = GRPC::RpcServer.new + thd = Thread.new do + srv.add_http2_port("0.0.0.0:#{client_control_port}", :this_port_is_insecure) + srv.handle(ChannelClosingClientController.new(ch)) + srv.run + end + + # this should break out once the channel is closed + loop do + state = ch.connectivity_state(true) + begin + ch.watch_connectivity_state(state, Time.now + 360) + rescue RuntimeException => e + break + end + end + + srv.stop + thd.join +end + +main diff --git a/src/ruby/end2end/channel_closing_driver.rb b/src/ruby/end2end/channel_closing_driver.rb new file mode 100755 index 0000000000..924fbe3bee --- /dev/null +++ b/src/ruby/end2end/channel_closing_driver.rb @@ -0,0 +1,65 @@ +#!/usr/bin/env ruby + +# Copyright 2016, 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. + +# make sure that the client doesn't hang when process ended abruptly + +require_relative './end2end_common' + +def main + STDERR.puts "start server" + server_runner = ServerRunner.new + server_port = server_runner.run + + sleep 1 + + STDERR.puts "start client" + control_stub, client_pid = start_client("channel_closing_client.rb", server_port) + + sleep 3 + + + begin + Timeout.timeout(10) do + control_stub.shutdown(ClientControl::Void.new) + Process.wait(client_pid) + end + rescue Timeout::Error + STDERR.puts "timeout wait for client pid #{client_pid}" + Process.kill('SIGKILL', client_pid) + Process.wait(client_pid) + STDERR.puts "killed client child" + raise 'Timed out waiting for client process. It likely hangs when a channel is closed while connectivity is watched' + end + + server_runner.stop +end + +main diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh index 518848b950..eb75878caf 100755 --- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh +++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh @@ -36,4 +36,5 @@ cd $(dirname $0)/../../.. EXIT_CODE=0 ruby src/ruby/end2end/sig_handling_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/channel_state_driver.rb || EXIT_CODE=1 +ruby src/ruby/end2end/channel_closing_driver.rb || EXIT_CODE=1 exit $EXIT_CODE -- cgit v1.2.3 From 563ec5324f60b8ea521b41a1a440735b8bf6d2a6 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 15:54:49 -0700 Subject: stop mixing gpr mutexes and the ruby gil to fix channel closing deadlock --- src/ruby/end2end/channel_closing_client.rb | 10 ++--- src/ruby/ext/grpc/rb_channel.c | 69 +++++++++++++++++------------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/ruby/end2end/channel_closing_client.rb b/src/ruby/end2end/channel_closing_client.rb index 88fa9ae5e6..a9df078421 100755 --- a/src/ruby/end2end/channel_closing_client.rb +++ b/src/ruby/end2end/channel_closing_client.rb @@ -36,9 +36,8 @@ class ChannelClosingClientController < ClientControl::ClientController::Service @ch = ch end def shutdown(_, _) - STDERR.puts "about to close channel" @ch.close - STDERR.puts "just closed channel" + ClientControl::Void.new end end @@ -63,12 +62,13 @@ def main srv.run end - # this should break out once the channel is closed + # this should break out with an exception once the channel is closed loop do - state = ch.connectivity_state(true) begin + state = ch.connectivity_state(true) ch.watch_connectivity_state(state, Time.now + 360) - rescue RuntimeException => e + rescue RuntimeError => e + STDERR.puts "(expected) error occurred: #{e.inspect}" break end end diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 08d48f2a04..94a10faf3f 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -78,6 +78,7 @@ typedef struct grpc_rb_channel { int safe_to_destroy; grpc_connectivity_state current_connectivity_state; + int mu_init_done; gpr_mu channel_mu; gpr_cv channel_cv; } grpc_rb_channel; @@ -106,6 +107,11 @@ static void grpc_rb_channel_free(void *p) { ch->wrapped = NULL; } + if (ch->mu_init_done) { + gpr_mu_destroy(&ch->channel_mu); + gpr_cv_destroy(&ch->channel_cv); + } + xfree(p); } @@ -164,6 +170,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { rb_scan_args(argc, argv, "3", &target, &channel_args, &credentials); TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); + wrapper->mu_init_done = 0; target_chars = StringValueCStr(target); grpc_rb_hash_convert_to_channel_args(channel_args, &args); if (TYPE(credentials) == T_SYMBOL) { @@ -185,6 +192,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { gpr_mu_init(&wrapper->channel_mu); gpr_cv_init(&wrapper->channel_cv); + wrapper->mu_init_done = 1; gpr_mu_lock(&wrapper->channel_mu); wrapper->current_connectivity_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); @@ -244,13 +252,38 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, typedef struct watch_state_stack { grpc_rb_channel *wrapper; gpr_timespec deadline; + int last_state; } watch_state_stack; static void *watch_channel_state_without_gvl(void *arg) { - gpr_timespec deadline = ((watch_state_stack*)arg)->deadline; - grpc_rb_channel *wrapper = ((watch_state_stack*)arg)->wrapper; + watch_state_stack *stack = (watch_state_stack*)arg; + + gpr_timespec deadline = stack->deadline; + grpc_rb_channel *wrapper = stack->wrapper; + int last_state = stack->last_state; + + gpr_mu_lock(&wrapper->channel_mu); + if (wrapper->current_connectivity_state != last_state) { + gpr_mu_unlock(&wrapper->channel_mu); + return (void*)0; + } + if (wrapper->request_safe_destroy) { + gpr_mu_unlock(&wrapper->channel_mu); + return (void*)0; + } + if (wrapper->safe_to_destroy) { + gpr_mu_unlock(&wrapper->channel_mu); + return (void*)0; + } + gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, deadline); - return NULL; + + if (wrapper->current_connectivity_state != last_state) { + gpr_mu_unlock(&wrapper->channel_mu); + return (void*)1; + } + gpr_mu_unlock(&wrapper->channel_mu); + return (void*)0; } static void watch_channel_state_unblocking_func(void *arg) { @@ -273,6 +306,7 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, VALUE deadline) { grpc_rb_channel *wrapper = NULL; watch_state_stack stack; + void* out; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); @@ -286,33 +320,13 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, return Qnil; } - gpr_mu_lock(&wrapper->channel_mu); - if (wrapper->current_connectivity_state != NUM2LONG(last_state)) { - gpr_mu_unlock(&wrapper->channel_mu); - return Qtrue; - } - if (wrapper->request_safe_destroy) { - gpr_mu_unlock(&wrapper->channel_mu); - rb_raise(rb_eRuntimeError, "watch_connectivity_state called on closed channel"); - return Qfalse; - } - if (wrapper->safe_to_destroy) { - gpr_mu_unlock(&wrapper->channel_mu); - return Qfalse; - } stack.wrapper = wrapper; stack.deadline = grpc_rb_time_timeval(deadline, 0); - rb_thread_call_without_gvl(watch_channel_state_without_gvl, &stack, watch_channel_state_unblocking_func, wrapper); - if (wrapper->request_safe_destroy) { - gpr_mu_unlock(&wrapper->channel_mu); - rb_raise(rb_eRuntimeError, "channel closed during call to watch_connectivity_state"); - return Qfalse; - } - if (wrapper->current_connectivity_state != NUM2LONG(last_state)) { - gpr_mu_unlock(&wrapper->channel_mu); + stack.last_state = NUM2LONG(last_state); + out = rb_thread_call_without_gvl(watch_channel_state_without_gvl, &stack, watch_channel_state_unblocking_func, wrapper); + if (out) { return Qtrue; } - gpr_mu_unlock(&wrapper->channel_mu); return Qfalse; } @@ -460,9 +474,6 @@ static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper) { GPR_ASSERT(wrapper->safe_to_destroy); gpr_mu_unlock(&wrapper->channel_mu); - gpr_mu_destroy(&wrapper->channel_mu); - gpr_cv_destroy(&wrapper->channel_cv); - grpc_channel_destroy(wrapper->wrapped); } -- cgit v1.2.3 From 4109c23734d572cc19cd7e54571757c854db27f7 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 16:07:03 -0700 Subject: add a README for new test directory --- src/ruby/end2end/README | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/ruby/end2end/README diff --git a/src/ruby/end2end/README b/src/ruby/end2end/README new file mode 100644 index 0000000000..f0dc14fe9b --- /dev/null +++ b/src/ruby/end2end/README @@ -0,0 +1,18 @@ +This directory contains some grpc-ruby end to end tests. + +Each test here involves two files: a "driver" and a "client". For example, +the "channel_closing" test involves channel_closing_driver.rb +and channel_closing_client.rb. + +Typically, the "driver will start up a simple "echo" server, and then +spawn a client. It gives the client the address of the "echo" server as +well as an address to listen on for control rpcs. Depending on the test, the +client usually starts up a "ClientControl" grpc server for the driver to +interact with (the driver can tell the client process to do strange things at +different times, depending on the test). + +So far these tests are mostly useful for testing process-shutdown related +situations, since the client's run in separate processes. + +These tests are invoked through the "tools/run_tests/run_tests.py" script (the +Rakefile doesn't start these). -- cgit v1.2.3 From 8b371e23c0091b838807b0bc0e9a3026c6f02fc9 Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Wed, 15 Mar 2017 16:15:13 -0700 Subject: Change GIL aquire functions to make it c-core thread safe --- .../grpcio/grpc/_cython/_cygrpc/security.pxd.pxi | 2 +- .../grpcio/grpc/_cython/_cygrpc/security.pyx.pxi | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi index 3a952ca309..9915b0ed1a 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi @@ -29,4 +29,4 @@ cdef grpc_ssl_roots_override_result ssl_roots_override_callback( - char **pem_root_certs) with gil + char **pem_root_certs) nogil diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi index 20fc1c5fce..357b0330d5 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi @@ -33,12 +33,14 @@ import pkg_resources cdef grpc_ssl_roots_override_result ssl_roots_override_callback( - char **pem_root_certs) with gil: - temporary_pem_root_certs = pkg_resources.resource_string( - __name__.rstrip('.cygrpc'), '_credentials/roots.pem') - pem_root_certs[0] = gpr_malloc(len(temporary_pem_root_certs) + 1) - memcpy( - pem_root_certs[0], temporary_pem_root_certs, - len(temporary_pem_root_certs)) - pem_root_certs[0][len(temporary_pem_root_certs)] = '\0' + char **pem_root_certs) nogil: + with gil: + temporary_pem_root_certs = pkg_resources.resource_string( + __name__.rstrip('.cygrpc'), '_credentials/roots.pem') + pem_root_certs[0] = gpr_malloc(len(temporary_pem_root_certs) + 1) + memcpy( + pem_root_certs[0], temporary_pem_root_certs, + len(temporary_pem_root_certs)) + pem_root_certs[0][len(temporary_pem_root_certs)] = '\0' + return GRPC_SSL_ROOTS_OVERRIDE_OK -- cgit v1.2.3 From 38901585d43a7bb04b7f9696b358e04882be1351 Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Wed, 15 Mar 2017 16:23:36 -0700 Subject: Workaround new wget SSL failure --- tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile | 2 +- tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile index 7109862911..06be7bec18 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile @@ -39,7 +39,7 @@ RUN yum update -y RUN yum remove -y git RUN yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc RUN cd /usr/src && \ - wget https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ + curl -O -L https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ tar xzf git-2.0.5.tar.gz RUN cd /usr/src/git-2.0.5 && \ make prefix=/usr/local/git all && \ diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile index 36286bca53..8693e30cb4 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile @@ -39,7 +39,7 @@ RUN yum update -y RUN yum remove -y git RUN yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc RUN cd /usr/src && \ - wget https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ + curl -O -L https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ tar xzf git-2.0.5.tar.gz RUN cd /usr/src/git-2.0.5 && \ make prefix=/usr/local/git all && \ -- cgit v1.2.3 From af3213f38bb5c3737c94a685ee508d289552b5a1 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 16:44:52 -0700 Subject: remove now-unused channel completion queues --- src/ruby/ext/grpc/rb_channel.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 94a10faf3f..3b1111e5e2 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -73,7 +73,6 @@ typedef struct grpc_rb_channel { /* The actual channel */ grpc_channel *wrapped; - grpc_completion_queue *queue; int request_safe_destroy; int safe_to_destroy; grpc_connectivity_state current_connectivity_state; @@ -103,7 +102,6 @@ static void grpc_rb_channel_free(void *p) { if (ch->wrapped != NULL) { grpc_rb_channel_safe_destroy(ch); - grpc_rb_completion_queue_destroy(ch->queue); ch->wrapped = NULL; } @@ -215,7 +213,6 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { } rb_ivar_set(self, id_target, target); wrapper->wrapped = ch; - wrapper->queue = grpc_completion_queue_create(NULL); return self; } @@ -404,8 +401,6 @@ static VALUE grpc_rb_channel_destroy(VALUE self) { ch = wrapper->wrapped; if (ch != NULL) { grpc_rb_channel_safe_destroy(wrapper); - GPR_ASSERT(wrapper->queue != NULL); - grpc_rb_completion_queue_destroy(wrapper->queue); wrapper->wrapped = NULL; } -- cgit v1.2.3 From 42053039ff6515cdbb6192134266411e35a73823 Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Wed, 15 Mar 2017 17:08:32 -0700 Subject: Changes --- tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile | 2 +- tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile index 7109862911..06be7bec18 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x64/Dockerfile @@ -39,7 +39,7 @@ RUN yum update -y RUN yum remove -y git RUN yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc RUN cd /usr/src && \ - wget https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ + curl -O -L https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ tar xzf git-2.0.5.tar.gz RUN cd /usr/src/git-2.0.5 && \ make prefix=/usr/local/git all && \ diff --git a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile index 36286bca53..8693e30cb4 100644 --- a/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile +++ b/tools/dockerfile/grpc_artifact_python_manylinux_x86/Dockerfile @@ -39,7 +39,7 @@ RUN yum update -y RUN yum remove -y git RUN yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc RUN cd /usr/src && \ - wget https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ + curl -O -L https://kernel.org/pub/software/scm/git/git-2.0.5.tar.gz && \ tar xzf git-2.0.5.tar.gz RUN cd /usr/src/git-2.0.5 && \ make prefix=/usr/local/git all && \ -- cgit v1.2.3 From 071f74f6f13bc806169e0d3c5ca947e3b9b0605d Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Mar 2017 17:32:40 -0700 Subject: add copyright header to fix failing sanity tests --- src/ruby/end2end/README | 18 ------------------ src/ruby/end2end/README.md | 18 ++++++++++++++++++ src/ruby/end2end/channel_closing_driver.rb | 2 +- src/ruby/end2end/gen_protos.sh | 30 ++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 19 deletions(-) delete mode 100644 src/ruby/end2end/README create mode 100644 src/ruby/end2end/README.md diff --git a/src/ruby/end2end/README b/src/ruby/end2end/README deleted file mode 100644 index f0dc14fe9b..0000000000 --- a/src/ruby/end2end/README +++ /dev/null @@ -1,18 +0,0 @@ -This directory contains some grpc-ruby end to end tests. - -Each test here involves two files: a "driver" and a "client". For example, -the "channel_closing" test involves channel_closing_driver.rb -and channel_closing_client.rb. - -Typically, the "driver will start up a simple "echo" server, and then -spawn a client. It gives the client the address of the "echo" server as -well as an address to listen on for control rpcs. Depending on the test, the -client usually starts up a "ClientControl" grpc server for the driver to -interact with (the driver can tell the client process to do strange things at -different times, depending on the test). - -So far these tests are mostly useful for testing process-shutdown related -situations, since the client's run in separate processes. - -These tests are invoked through the "tools/run_tests/run_tests.py" script (the -Rakefile doesn't start these). diff --git a/src/ruby/end2end/README.md b/src/ruby/end2end/README.md new file mode 100644 index 0000000000..ea5ab6d4bc --- /dev/null +++ b/src/ruby/end2end/README.md @@ -0,0 +1,18 @@ +This directory contains some grpc-ruby end to end tests. + +Each test here involves two files: a "driver" and a "client". For example, +the "channel_closing" test involves channel_closing_driver.rb +and channel_closing_client.rb. + +Typically, the "driver" will start up a simple "echo" server, and then +spawn a client. It gives the client the address of the "echo" server as +well as an address to listen on for control rpcs. Depending on the test, the +client usually starts up a "ClientControl" grpc server for the driver to +interact with (the driver can tell the client process to do strange things at +different times, depending on the test). + +So far these tests are mostly useful for testing process-shutdown related +situations, since the client's run in separate processes. + +These tests are invoked through the "tools/run_tests/run_tests.py" script (the +Rakefile doesn't start these). diff --git a/src/ruby/end2end/channel_closing_driver.rb b/src/ruby/end2end/channel_closing_driver.rb index 924fbe3bee..98c8eaa1cd 100755 --- a/src/ruby/end2end/channel_closing_driver.rb +++ b/src/ruby/end2end/channel_closing_driver.rb @@ -29,7 +29,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# make sure that the client doesn't hang when process ended abruptly +# make sure that the client doesn't hang when channel is closed explictly while it's used require_relative './end2end_common' diff --git a/src/ruby/end2end/gen_protos.sh b/src/ruby/end2end/gen_protos.sh index c26b5572da..f78d9ad394 100644 --- a/src/ruby/end2end/gen_protos.sh +++ b/src/ruby/end2end/gen_protos.sh @@ -1,2 +1,32 @@ #!/bin/bash + +# Copyright 2016, 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. + grpc_tools_ruby_protoc -I protos --ruby_out=lib --grpc_out=lib protos/echo.proto protos/client_control.proto -- cgit v1.2.3 From 3f2413d15ed545f4d5902af067fbe285499e11c0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 8 Mar 2017 10:58:48 -0800 Subject: Use the right encoding overhead number in remote interop test with Cronet --- src/objective-c/tests/InteropTests.m | 6 ------ .../InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index 5584246ad9..766fa19d85 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -169,8 +169,6 @@ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -#ifndef GRPC_COMPILE_WITH_CRONET -// TODO (mxyan): Fix this test - (void)testResponsesOverMaxSizeFailWithActionableMessage { XCTAssertNotNil(self.class.host); __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"]; @@ -191,7 +189,6 @@ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -#endif - (void)testResponsesOver4MBAreAcceptedIfOptedIn { XCTAssertNotNil(self.class.host); @@ -327,8 +324,6 @@ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -#ifndef GRPC_COMPILE_WITH_CRONET -// TODO(makdharma@): Fix this test - (void)testEmptyStreamRPC { XCTAssertNotNil(self.class.host); __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"]; @@ -342,7 +337,6 @@ }]; [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } -#endif - (void)testCancelAfterBeginRPC { XCTAssertNotNil(self.class.host); diff --git a/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m index fab8ad8d25..7bc303ac10 100644 --- a/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m @@ -47,4 +47,8 @@ static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; return kRemoteSSLHost; } +- (int32_t)encodingOverhead { + return 12; // bytes +} + @end -- cgit v1.2.3 From f69a885f176c1bac9b15d7b270a9dc50fbf3a4f6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 8 Mar 2017 14:54:11 -0800 Subject: Add comment to encodingOverhead --- src/objective-c/tests/InteropTests.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index 766fa19d85..d964f53e8e 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -90,6 +90,9 @@ return nil; } +// This number indicates how many bytes of overhead does Protocol Buffers encoding add onto the +// message. The number varies as different message.proto is used on different servers. The actual +// number for each interop server is overridden in corresponding derived test classes. - (int32_t)encodingOverhead { return 0; } -- cgit v1.2.3 From 10112e50defa8b4ea10a153fd206ae8a1f1665a6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 10 Mar 2017 11:41:53 -0800 Subject: Use k-contant and add comment for encoding overhead --- src/objective-c/tests/InteropTestsLocalCleartext.m | 6 +++++- src/objective-c/tests/InteropTestsLocalSSL.m | 6 +++++- src/objective-c/tests/InteropTestsRemote.m | 6 +++++- .../InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/objective-c/tests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTestsLocalCleartext.m index b41210f50f..4987660808 100644 --- a/src/objective-c/tests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTestsLocalCleartext.m @@ -37,6 +37,10 @@ static NSString * const kLocalCleartextHost = @"localhost:5050"; +// The Protocol Buffers encoding overhead of local interop server. Acquired +// by experiment. Adjust this when server's proto file changes. +static int32_t kLocalInteropServerOverhead = 10; + /** Tests in InteropTests.m, sending the RPCs to a local cleartext server. */ @interface InteropTestsLocalCleartext : InteropTests @end @@ -48,7 +52,7 @@ static NSString * const kLocalCleartextHost = @"localhost:5050"; } - (int32_t)encodingOverhead { - return 10; // bytes + return kLocalInteropServerOverhead; // bytes } - (void)setUp { diff --git a/src/objective-c/tests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTestsLocalSSL.m index 1479c5896c..934d500abc 100644 --- a/src/objective-c/tests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTestsLocalSSL.m @@ -37,6 +37,10 @@ static NSString * const kLocalSSLHost = @"localhost:5051"; +// The Protocol Buffers encoding overhead of local interop server. Acquired +// by experiment. Adjust this when server's proto file changes. +static int32_t kLocalInteropServerOverhead = 10; + /** Tests in InteropTests.m, sending the RPCs to a local SSL server. */ @interface InteropTestsLocalSSL : InteropTests @end @@ -48,7 +52,7 @@ static NSString * const kLocalSSLHost = @"localhost:5051"; } - (int32_t)encodingOverhead { - return 10; // bytes + return kLocalInteropServerOverhead; // bytes } - (void)setUp { diff --git a/src/objective-c/tests/InteropTestsRemote.m b/src/objective-c/tests/InteropTestsRemote.m index 70f84753bb..9fb30aa43d 100644 --- a/src/objective-c/tests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTestsRemote.m @@ -37,6 +37,10 @@ static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; +// The Protocol Buffers encoding overhead of remote interop server. Acquired +// by experiment. Adjust this when server's proto file changes. +static int32_t kRemoteInteropServerOverhead = 12; + /** Tests in InteropTests.m, sending the RPCs to a remote SSL server. */ @interface InteropTestsRemote : InteropTests @end @@ -48,7 +52,7 @@ static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; } - (int32_t)encodingOverhead { - return 12; // bytes + return kRemoteInteropServerOverhead; // bytes } @end diff --git a/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m index 7bc303ac10..005bac0a0d 100644 --- a/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m @@ -37,6 +37,10 @@ static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; +// The Protocol Buffers encoding overhead of remote interop server. Acquired +// by experiment. Adjust this when server's proto file changes. +static int32_t kRemoteInteropServerOverhead = 12; + /** Tests in InteropTests.m, sending the RPCs to a remote SSL server. */ @interface InteropTestsRemoteWithCronet : InteropTests @end @@ -48,7 +52,7 @@ static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; } - (int32_t)encodingOverhead { - return 12; // bytes + return kRemoteInteropServerOverhead; // bytes } @end -- cgit v1.2.3 From 12ca7d319c2ef2ff2e15ea0ed02ccb5c84198aa7 Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Thu, 16 Mar 2017 11:01:06 -0700 Subject: Bump 1.2.x version to pre-2 --- CMakeLists.txt | 2 +- Makefile | 4 ++-- build.yaml | 2 +- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.json | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Auth/project.json | 4 ++-- src/csharp/Grpc.Core.Testing/project.json | 4 ++-- src/csharp/Grpc.Core/VersionInfo.cs | 2 +- src/csharp/Grpc.Core/project.json | 2 +- src/csharp/Grpc.HealthCheck/project.json | 4 ++-- src/csharp/Grpc.Reflection/project.json | 4 ++-- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/node/health_check/package.json | 4 ++-- src/node/tools/package.json | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 31 files changed, 39 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89a983ca4d..28bff0d231 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.2.0-pre1") +set(PACKAGE_VERSION "1.2.0-pre2") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index c35fe90a17..331523ed7d 100644 --- a/Makefile +++ b/Makefile @@ -412,8 +412,8 @@ Q = @ endif CORE_VERSION = 3.0.0-dev -CPP_VERSION = 1.2.0-pre1 -CSHARP_VERSION = 1.2.0-pre1 +CPP_VERSION = 1.2.0-pre2 +CSHARP_VERSION = 1.2.0-pre2 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index c71e98c522..ce88586b92 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 3.0.0-dev g_stands_for: green - version: 1.2.0-pre1 + version: 1.2.0-pre2 filegroups: - name: census public_headers: diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 8b67a5dcdd..6e65f681b8 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -37,7 +37,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.2.0-pre1' + version = '1.2.0-pre2' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 8fbdf7ad55..2b6908b8b9 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.2.0-pre1' + version = '1.2.0-pre2' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index e302e6482e..7293a189ed 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.2.0-pre1' + version = '1.2.0-pre2' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'http://www.grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 64a6f0aba4..149847e993 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -35,7 +35,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.2.0-pre1' + version = '1.2.0-pre2' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' diff --git a/package.json b/package.json index 588425d0e0..36f7d35a7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grpc", - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "author": "Google Inc.", "description": "gRPC Library for Node", "homepage": "http://www.grpc.io/", diff --git a/package.xml b/package.xml index 94305025b5..7b3e6b129f 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2017-03-01 - 1.2.0RC1 - 1.2.0RC1 + 1.2.0RC2 + 1.2.0RC2 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 30395fbac5..9b30223f47 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -37,5 +37,5 @@ #include namespace grpc { -grpc::string Version() { return "1.2.0-pre1"; } +grpc::string Version() { return "1.2.0-pre2"; } } diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index d4fbdc1d56..fc0a8ba0de 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "title": "gRPC C# Auth", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre1", + "Grpc.Core": "1.2.0-pre2", "Google.Apis.Auth": "1.21.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Core.Testing/project.json b/src/csharp/Grpc.Core.Testing/project.json index 9d1180d054..0070b74cc3 100644 --- a/src/csharp/Grpc.Core.Testing/project.json +++ b/src/csharp/Grpc.Core.Testing/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "title": "gRPC C# Core Testing", "authors": [ "Google Inc." ], "copyright": "Copyright 2017, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre1" + "Grpc.Core": "1.2.0-pre2" }, "frameworks": { "net45": { diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index b6e3bc5f8d..8773183aaf 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -53,6 +53,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.2.0-pre1"; + public const string CurrentVersion = "1.2.0-pre2"; } } diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index 51311010cd..0f9f1e819e 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "title": "gRPC C# Core", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 330002f3ad..ae3094b903 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "title": "gRPC C# Healthchecking", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre1", + "Grpc.Core": "1.2.0-pre2", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Reflection/project.json b/src/csharp/Grpc.Reflection/project.json index 1a77a854c2..8daa9e47dd 100644 --- a/src/csharp/Grpc.Reflection/project.json +++ b/src/csharp/Grpc.Reflection/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "title": "gRPC C# Reflection", "authors": [ "Google Inc." ], "copyright": "Copyright 2016, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre1", + "Grpc.Core": "1.2.0-pre2", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index fee896d883..9e1074833f 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -28,7 +28,7 @@ @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @rem Current package versions -set VERSION=1.2.0-pre1 +set VERSION=1.2.0-pre2 set PROTOBUF_VERSION=3.0.0 @rem Adjust the location of nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index bc7350f3af..a283dc76f1 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -66,7 +66,7 @@ dotnet pack --configuration Release Grpc.Auth/project.json --output ../../artifa dotnet pack --configuration Release Grpc.HealthCheck/project.json --output ../../artifacts dotnet pack --configuration Release Grpc.Reflection/project.json --output ../../artifacts -nuget pack Grpc.nuspec -Version "1.2.0-pre1" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.2.0-pre1" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.2.0-pre2" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.2.0-pre2" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json index 302f2606c6..d03d5a4d62 100644 --- a/src/node/health_check/package.json +++ b/src/node/health_check/package.json @@ -1,6 +1,6 @@ { "name": "grpc-health-check", - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "author": "Google Inc.", "description": "Health check service for use with gRPC", "repository": { @@ -15,7 +15,7 @@ } ], "dependencies": { - "grpc": "^1.2.0-pre1", + "grpc": "^1.2.0-pre2", "lodash": "^3.9.3", "google-protobuf": "^3.0.0" }, diff --git a/src/node/tools/package.json b/src/node/tools/package.json index 78071ad55a..e3b53bcdf5 100644 --- a/src/node/tools/package.json +++ b/src/node/tools/package.json @@ -1,6 +1,6 @@ { "name": "grpc-tools", - "version": "1.2.0-pre1", + "version": "1.2.0-pre2", "author": "Google Inc.", "description": "Tools for developing with gRPC on Node.js", "homepage": "http://www.grpc.io/", diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index ccad095f17..2a2f4de502 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.2.0-pre1' + v = '1.2.0-pre2' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 2d9ecc6c30..289a55d083 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -38,4 +38,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.2.0-pre1" +#define GRPC_OBJC_VERSION_STRING @"1.2.0-pre2" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 12c80fdbef..ff72fde583 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION='1.2.0rc1' +VERSION='1.2.0rc2' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 6d7907d377..6e098452a8 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION='1.2.0rc1' +VERSION='1.2.0rc2' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 0372478401..3fe4779e15 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION='1.2.0rc1' +VERSION='1.2.0rc2' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 5be5ecf254..ca78d14ad9 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION='1.2.0rc1' +VERSION='1.2.0rc2' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index c5169e6ae3..2cc0a950d0 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.2.0.pre1' + VERSION = '1.2.0.pre2' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 2970518f91..22a2a72e4c 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -29,6 +29,6 @@ module GRPC module Tools - VERSION = '1.2.0.pre1' + VERSION = '1.2.0.pre2' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 72c929889b..b784a80bf5 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION='1.2.0rc1' +VERSION='1.2.0rc2' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 1588755fde..7af9246bee 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.0-pre1 +PROJECT_NUMBER = 1.2.0-pre2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 62d801054d..5ca65127dc 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.0-pre1 +PROJECT_NUMBER = 1.2.0-pre2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 867e35a458c717f463e156a116897a38ffb0ef8f Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Thu, 16 Mar 2017 11:28:14 -0700 Subject: Initialize GIL at startup --- src/python/grpcio/grpc/_cython/cygrpc.pyx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index e1bd046a1a..274b5f1b8a 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -47,14 +47,14 @@ include "_cygrpc/server.pyx.pxi" # # initialize gRPC # - - cdef extern from "Python.h": - int Py_AtExit(void(*func)()) - + int PyEval_InitThreads() -def _initialize(): +cdef _initialize(): + # We have Python callbacks called by c-core threads, this ensures the GIL + # is initialized. + PyEval_InitThreads() grpc_set_ssl_roots_override_callback( ssl_roots_override_callback) -- cgit v1.2.3 From 411b63b92f0cdcf6bcd6b83fb1a9549bb68f4c36 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 16 Mar 2017 17:13:05 -0700 Subject: Advance dependency version --- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index ccad095f17..392a86106b 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -101,7 +101,7 @@ Pod::Spec.new do |s| s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.1.0' + s.dependency '!ProtoCompiler', '3.2.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.1' s.osx.deployment_target = '10.9' -- cgit v1.2.3 From 37d3fba39188d0efce113582a06d20e011b7c1ef Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 28 Feb 2017 16:14:40 -0800 Subject: Relieve ios deployment version to 7.0 --- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- templates/gRPC-Core.podspec.template | 2 +- templates/gRPC-ProtoRPC.podspec.template | 2 +- templates/gRPC-RxLibrary.podspec.template | 2 +- templates/gRPC.podspec.template | 2 +- templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 8b67a5dcdd..9cb5552bac 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -51,7 +51,7 @@ Pod::Spec.new do |s| :submodules => true, } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.requires_arc = false diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 8fbdf7ad55..e46440339e 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -48,7 +48,7 @@ Pod::Spec.new do |s| :tag => "v#{version}", } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' name = 'ProtoRPC' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index e302e6482e..5c8a4c8a76 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -48,7 +48,7 @@ Pod::Spec.new do |s| :tag => "v#{version}", } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' name = 'RxLibrary' diff --git a/gRPC.podspec b/gRPC.podspec index 64a6f0aba4..109e0e08c1 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -47,7 +47,7 @@ Pod::Spec.new do |s| :tag => "v#{version}", } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' name = 'GRPCClient' diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 392a86106b..5f9ea2e840 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -103,7 +103,7 @@ Pod::Spec.new do |s| # Restrict the protoc version to the one supported by this plugin. s.dependency '!ProtoCompiler', '3.2.0' # For the Protobuf dependency not to complain: - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' # Restrict the gRPC runtime version to the one supported by this plugin. s.dependency 'gRPC-ProtoRPC', v diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 9ed32e31cf..11146a490b 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -78,7 +78,7 @@ :submodules => true, } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.requires_arc = false diff --git a/templates/gRPC-ProtoRPC.podspec.template b/templates/gRPC-ProtoRPC.podspec.template index 5d7d90d231..47b22dd2a5 100644 --- a/templates/gRPC-ProtoRPC.podspec.template +++ b/templates/gRPC-ProtoRPC.podspec.template @@ -50,7 +50,7 @@ :tag => "v#{version}", } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' name = 'ProtoRPC' diff --git a/templates/gRPC-RxLibrary.podspec.template b/templates/gRPC-RxLibrary.podspec.template index 35a06c8a85..48f0df8f9e 100644 --- a/templates/gRPC-RxLibrary.podspec.template +++ b/templates/gRPC-RxLibrary.podspec.template @@ -50,7 +50,7 @@ :tag => "v#{version}", } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' name = 'RxLibrary' diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index d33ce277dc..ce473608dd 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -49,7 +49,7 @@ :tag => "v#{version}", } - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' name = 'GRPCClient' diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index 3a10cfab3c..b100fa7cfe 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -105,7 +105,7 @@ # Restrict the protoc version to the one supported by this plugin. s.dependency '!ProtoCompiler', '3.1.0' # For the Protobuf dependency not to complain: - s.ios.deployment_target = '7.1' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' # Restrict the gRPC runtime version to the one supported by this plugin. s.dependency 'gRPC-ProtoRPC', v -- cgit v1.2.3 From e38b01293ba231d00802c3016505d1eb73330a50 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 16 Mar 2017 20:53:41 -0700 Subject: Changes to podspecs --- gRPC-Core.podspec | 7 +++---- templates/gRPC-Core.podspec.template | 7 +++---- .../src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 9cb5552bac..77cf112590 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -887,8 +887,7 @@ Pod::Spec.new do |s| s.subspec 'Cronet-Interface' do |ss| ss.header_mappings_dir = 'include/grpc' - ss.source_files = 'include/grpc/grpc_cronet.h', - 'src/core/ext/transport/cronet/transport/cronet_transport.h' + ss.source_files = 'include/grpc/grpc_cronet.h' end s.subspec 'Cronet-Implementation' do |ss| @@ -899,7 +898,7 @@ Pod::Spec.new do |s| ss.dependency "#{s.name}/Cronet-Interface", version ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c', - 'src/core/ext/transport/cronet/transport/cronet_transport.c', + 'src/core/ext/transport/cronet/transport/cronet_transport.{c,h}', 'third_party/objective_c/Cronet/bidirectional_stream_c.h' end @@ -914,7 +913,7 @@ Pod::Spec.new do |s| 'test/core/end2end/end2end_test_utils.c', 'test/core/end2end/tests/*.{c,h}', 'test/core/end2end/data/*.{c,h}', - 'test/core/util/debugger_macros.c', + 'test/core/util/debugger_macros.{c,h}', 'test/core/util/test_config.{c,h}', 'test/core/util/port.h', 'test/core/util/port.c', diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 11146a490b..e7289111b2 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -161,8 +161,7 @@ s.subspec 'Cronet-Interface' do |ss| ss.header_mappings_dir = 'include/grpc' - ss.source_files = 'include/grpc/grpc_cronet.h', - 'src/core/ext/transport/cronet/transport/cronet_transport.h' + ss.source_files = 'include/grpc/grpc_cronet.h' end s.subspec 'Cronet-Implementation' do |ss| @@ -173,7 +172,7 @@ ss.dependency "#{s.name}/Cronet-Interface", version ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c', - 'src/core/ext/transport/cronet/transport/cronet_transport.c', + 'src/core/ext/transport/cronet/transport/cronet_transport.{c,h}', 'third_party/objective_c/Cronet/bidirectional_stream_c.h' end @@ -188,7 +187,7 @@ 'test/core/end2end/end2end_test_utils.c', 'test/core/end2end/tests/*.{c,h}', 'test/core/end2end/data/*.{c,h}', - 'test/core/util/debugger_macros.c', + 'test/core/util/debugger_macros.{c,h}', 'test/core/util/test_config.{c,h}', 'test/core/util/port.h', 'test/core/util/port.c', diff --git a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template index b100fa7cfe..d7d84f3c77 100644 --- a/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template +++ b/templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template @@ -103,7 +103,7 @@ s.preserve_paths = plugin # Restrict the protoc version to the one supported by this plugin. - s.dependency '!ProtoCompiler', '3.1.0' + s.dependency '!ProtoCompiler', '3.2.0' # For the Protobuf dependency not to complain: s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' -- cgit v1.2.3 From 39a5932097b5a2ed9481cd9660522658ee96fc65 Mon Sep 17 00:00:00 2001 From: Ken Payson Date: Tue, 7 Mar 2017 11:48:35 -0800 Subject: Add max_requests argument to server If the server is already serving max requests, return RESOURCE_EXHAUSTED --- src/python/grpcio/grpc/__init__.py | 11 +- src/python/grpcio/grpc/_server.py | 94 ++++--- src/python/grpcio_tests/tests/tests.json | 1 + .../tests/unit/_resource_exhausted_test.py | 270 +++++++++++++++++++++ 4 files changed, 337 insertions(+), 39 deletions(-) create mode 100644 src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index a4481b2ac3..4960df3be9 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1273,7 +1273,10 @@ def secure_channel(target, credentials, options=None): credentials._credentials) -def server(thread_pool, handlers=None, options=None): +def server(thread_pool, + handlers=None, + options=None, + maximum_concurrent_rpcs=None): """Creates a Server with which RPCs can be serviced. Args: @@ -1286,13 +1289,17 @@ def server(thread_pool, handlers=None, options=None): returned Server is started. options: A sequence of string-value pairs according to which to configure the created server. + maximum_concurrent_rpcs: The maximum number of concurrent RPCs this server + will service before returning status RESOURCE_EXHAUSTED, or None to + indicate no limit. Returns: A Server with which RPCs can be serviced. """ from grpc import _server # pylint: disable=cyclic-import return _server.Server(thread_pool, () if handlers is None else handlers, () - if options is None else options) + if options is None else options, + maximum_concurrent_rpcs) ################################### __all__ ################################# diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 84e096d4c0..47838c2c98 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -504,37 +504,37 @@ def _stream_response_in_pool(rpc_event, state, behavior, argument_thunk, def _handle_unary_unary(rpc_event, state, method_handler, thread_pool): unary_request = _unary_request(rpc_event, state, method_handler.request_deserializer) - thread_pool.submit(_unary_response_in_pool, rpc_event, state, - method_handler.unary_unary, unary_request, - method_handler.request_deserializer, - method_handler.response_serializer) + return thread_pool.submit(_unary_response_in_pool, rpc_event, state, + method_handler.unary_unary, unary_request, + method_handler.request_deserializer, + method_handler.response_serializer) def _handle_unary_stream(rpc_event, state, method_handler, thread_pool): unary_request = _unary_request(rpc_event, state, method_handler.request_deserializer) - thread_pool.submit(_stream_response_in_pool, rpc_event, state, - method_handler.unary_stream, unary_request, - method_handler.request_deserializer, - method_handler.response_serializer) + return thread_pool.submit(_stream_response_in_pool, rpc_event, state, + method_handler.unary_stream, unary_request, + method_handler.request_deserializer, + method_handler.response_serializer) def _handle_stream_unary(rpc_event, state, method_handler, thread_pool): request_iterator = _RequestIterator(state, rpc_event.operation_call, method_handler.request_deserializer) - thread_pool.submit(_unary_response_in_pool, rpc_event, state, - method_handler.stream_unary, lambda: request_iterator, - method_handler.request_deserializer, - method_handler.response_serializer) + return thread_pool.submit( + _unary_response_in_pool, rpc_event, state, method_handler.stream_unary, + lambda: request_iterator, method_handler.request_deserializer, + method_handler.response_serializer) def _handle_stream_stream(rpc_event, state, method_handler, thread_pool): request_iterator = _RequestIterator(state, rpc_event.operation_call, method_handler.request_deserializer) - thread_pool.submit(_stream_response_in_pool, rpc_event, state, - method_handler.stream_stream, lambda: request_iterator, - method_handler.request_deserializer, - method_handler.response_serializer) + return thread_pool.submit( + _stream_response_in_pool, rpc_event, state, + method_handler.stream_stream, lambda: request_iterator, + method_handler.request_deserializer, method_handler.response_serializer) def _find_method_handler(rpc_event, generic_handlers): @@ -549,13 +549,12 @@ def _find_method_handler(rpc_event, generic_handlers): return None -def _handle_unrecognized_method(rpc_event): +def _reject_rpc(rpc_event, status, details): operations = (cygrpc.operation_send_initial_metadata(_common.EMPTY_METADATA, _EMPTY_FLAGS), cygrpc.operation_receive_close_on_server(_EMPTY_FLAGS), cygrpc.operation_send_status_from_server( - _common.EMPTY_METADATA, cygrpc.StatusCode.unimplemented, - b'Method not found!', _EMPTY_FLAGS),) + _common.EMPTY_METADATA, status, details, _EMPTY_FLAGS),) rpc_state = _RPCState() rpc_event.operation_call.start_server_batch( operations, lambda ignored_event: (rpc_state, (),)) @@ -572,33 +571,37 @@ def _handle_with_method_handler(rpc_event, method_handler, thread_pool): state.due.add(_RECEIVE_CLOSE_ON_SERVER_TOKEN) if method_handler.request_streaming: if method_handler.response_streaming: - _handle_stream_stream(rpc_event, state, method_handler, - thread_pool) + return state, _handle_stream_stream(rpc_event, state, + method_handler, thread_pool) else: - _handle_stream_unary(rpc_event, state, method_handler, - thread_pool) + return state, _handle_stream_unary(rpc_event, state, + method_handler, thread_pool) else: if method_handler.response_streaming: - _handle_unary_stream(rpc_event, state, method_handler, - thread_pool) + return state, _handle_unary_stream(rpc_event, state, + method_handler, thread_pool) else: - _handle_unary_unary(rpc_event, state, method_handler, - thread_pool) - return state + return state, _handle_unary_unary(rpc_event, state, + method_handler, thread_pool) -def _handle_call(rpc_event, generic_handlers, thread_pool): +def _handle_call(rpc_event, generic_handlers, thread_pool, + concurrency_exceeded): if not rpc_event.success: - return None + return None, None if rpc_event.request_call_details.method is not None: method_handler = _find_method_handler(rpc_event, generic_handlers) if method_handler is None: - return _handle_unrecognized_method(rpc_event) + return _reject_rpc(rpc_event, cygrpc.StatusCode.unimplemented, + b'Method not found!'), None + elif concurrency_exceeded: + return _reject_rpc(rpc_event, cygrpc.StatusCode.resource_exhausted, + b'Concurrent RPC limit exceeded!'), None else: return _handle_with_method_handler(rpc_event, method_handler, thread_pool) else: - return None + return None, None @enum.unique @@ -610,7 +613,8 @@ class _ServerStage(enum.Enum): class _ServerState(object): - def __init__(self, completion_queue, server, generic_handlers, thread_pool): + def __init__(self, completion_queue, server, generic_handlers, thread_pool, + maximum_concurrent_rpcs): self.lock = threading.Lock() self.completion_queue = completion_queue self.server = server @@ -618,6 +622,8 @@ class _ServerState(object): self.thread_pool = thread_pool self.stage = _ServerStage.STOPPED self.shutdown_events = None + self.maximum_concurrent_rpcs = maximum_concurrent_rpcs + self.active_rpc_count = 0 # TODO(https://github.com/grpc/grpc/issues/6597): eliminate these fields. self.rpc_states = set() @@ -657,6 +663,11 @@ def _stop_serving(state): return False +def _on_call_completed(state): + with state.lock: + state.active_rpc_count -= 1 + + def _serve(state): while True: event = state.completion_queue.poll() @@ -668,10 +679,18 @@ def _serve(state): elif event.tag is _REQUEST_CALL_TAG: with state.lock: state.due.remove(_REQUEST_CALL_TAG) - rpc_state = _handle_call(event, state.generic_handlers, - state.thread_pool) + concurrency_exceeded = ( + state.maximum_concurrent_rpcs is not None and + state.active_rpc_count >= state.maximum_concurrent_rpcs) + rpc_state, rpc_future = _handle_call( + event, state.generic_handlers, state.thread_pool, + concurrency_exceeded) if rpc_state is not None: state.rpc_states.add(rpc_state) + if rpc_future is not None: + state.active_rpc_count += 1 + rpc_future.add_done_callback( + lambda unused_future: _on_call_completed(state)) if state.stage is _ServerStage.STARTED: _request_call(state) elif _stop_serving(state): @@ -749,12 +768,13 @@ def _start(state): class Server(grpc.Server): - def __init__(self, thread_pool, generic_handlers, options): + def __init__(self, thread_pool, generic_handlers, options, + maximum_concurrent_rpcs): completion_queue = cygrpc.CompletionQueue() server = cygrpc.Server(_common.channel_args(options)) server.register_completion_queue(completion_queue) self._state = _ServerState(completion_queue, server, generic_handlers, - thread_pool) + thread_pool, maximum_concurrent_rpcs) def add_generic_rpc_handlers(self, generic_rpc_handlers): _add_generic_handlers(self._state, generic_rpc_handlers) diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json index 70d965d3ca..f750b05102 100644 --- a/src/python/grpcio_tests/tests/tests.json +++ b/src/python/grpcio_tests/tests/tests.json @@ -31,6 +31,7 @@ "unit._invocation_defects_test.InvocationDefectsTest", "unit._metadata_code_details_test.MetadataCodeDetailsTest", "unit._metadata_test.MetadataTest", + "unit._resource_exhausted_test.ResourceExhaustedTest", "unit._rpc_test.RPCTest", "unit._sanity._sanity_test.Sanity", "unit._thread_cleanup_test.CleanupThreadTest", diff --git a/src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py b/src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py new file mode 100644 index 0000000000..88c82b5541 --- /dev/null +++ b/src/python/grpcio_tests/tests/unit/_resource_exhausted_test.py @@ -0,0 +1,270 @@ +# Copyright 2017, 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. +"""Tests server responding with RESOURCE_EXHAUSTED.""" + +import threading +import unittest + +import grpc +from grpc import _channel +from grpc.framework.foundation import logging_pool + +from tests.unit import test_common +from tests.unit.framework.common import test_constants + +_REQUEST = b'\x00\x00\x00' +_RESPONSE = b'\x00\x00\x00' + +_UNARY_UNARY = '/test/UnaryUnary' +_UNARY_STREAM = '/test/UnaryStream' +_STREAM_UNARY = '/test/StreamUnary' +_STREAM_STREAM = '/test/StreamStream' + + +class _TestTrigger(object): + + def __init__(self, total_call_count): + self._total_call_count = total_call_count + self._pending_calls = 0 + self._triggered = False + self._finish_condition = threading.Condition() + self._start_condition = threading.Condition() + + # Wait for all calls be be blocked in their handler + def await_calls(self): + with self._start_condition: + while self._pending_calls < self._total_call_count: + self._start_condition.wait() + + # Block in a response handler and wait for a trigger + def await_trigger(self): + with self._start_condition: + self._pending_calls += 1 + self._start_condition.notify() + + with self._finish_condition: + if not self._triggered: + self._finish_condition.wait() + + # Finish all response handlers + def trigger(self): + with self._finish_condition: + self._triggered = True + self._finish_condition.notify_all() + + +def handle_unary_unary(trigger, request, servicer_context): + trigger.await_trigger() + return _RESPONSE + + +def handle_unary_stream(trigger, request, servicer_context): + trigger.await_trigger() + for _ in range(test_constants.STREAM_LENGTH): + yield _RESPONSE + + +def handle_stream_unary(trigger, request_iterator, servicer_context): + trigger.await_trigger() + # TODO(issue:#6891) We should be able to remove this loop + for request in request_iterator: + pass + return _RESPONSE + + +def handle_stream_stream(trigger, request_iterator, servicer_context): + trigger.await_trigger() + # TODO(issue:#6891) We should be able to remove this loop, + # and replace with return; yield + for request in request_iterator: + yield _RESPONSE + + +class _MethodHandler(grpc.RpcMethodHandler): + + def __init__(self, trigger, request_streaming, response_streaming): + self.request_streaming = request_streaming + self.response_streaming = response_streaming + self.request_deserializer = None + self.response_serializer = None + self.unary_unary = None + self.unary_stream = None + self.stream_unary = None + self.stream_stream = None + if self.request_streaming and self.response_streaming: + self.stream_stream = ( + lambda x, y: handle_stream_stream(trigger, x, y)) + elif self.request_streaming: + self.stream_unary = lambda x, y: handle_stream_unary(trigger, x, y) + elif self.response_streaming: + self.unary_stream = lambda x, y: handle_unary_stream(trigger, x, y) + else: + self.unary_unary = lambda x, y: handle_unary_unary(trigger, x, y) + + +class _GenericHandler(grpc.GenericRpcHandler): + + def __init__(self, trigger): + self._trigger = trigger + + def service(self, handler_call_details): + if handler_call_details.method == _UNARY_UNARY: + return _MethodHandler(self._trigger, False, False) + elif handler_call_details.method == _UNARY_STREAM: + return _MethodHandler(self._trigger, False, True) + elif handler_call_details.method == _STREAM_UNARY: + return _MethodHandler(self._trigger, True, False) + elif handler_call_details.method == _STREAM_STREAM: + return _MethodHandler(self._trigger, True, True) + else: + return None + + +class ResourceExhaustedTest(unittest.TestCase): + + def setUp(self): + self._server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY) + self._trigger = _TestTrigger(test_constants.THREAD_CONCURRENCY) + self._server = grpc.server( + self._server_pool, + handlers=(_GenericHandler(self._trigger),), + maximum_concurrent_rpcs=test_constants.THREAD_CONCURRENCY) + port = self._server.add_insecure_port('[::]:0') + self._server.start() + self._channel = grpc.insecure_channel('localhost:%d' % port) + + def tearDown(self): + self._server.stop(0) + + def testUnaryUnary(self): + multi_callable = self._channel.unary_unary(_UNARY_UNARY) + futures = [] + for _ in range(test_constants.THREAD_CONCURRENCY): + futures.append(multi_callable.future(_REQUEST)) + + self._trigger.await_calls() + + with self.assertRaises(grpc.RpcError) as exception_context: + multi_callable(_REQUEST) + + self.assertEqual(grpc.StatusCode.RESOURCE_EXHAUSTED, + exception_context.exception.code()) + + future_exception = multi_callable.future(_REQUEST) + self.assertEqual(grpc.StatusCode.RESOURCE_EXHAUSTED, + future_exception.exception().code()) + + self._trigger.trigger() + for future in futures: + self.assertEqual(_RESPONSE, future.result()) + + # Ensure a new request can be handled + self.assertEqual(_RESPONSE, multi_callable(_REQUEST)) + + def testUnaryStream(self): + multi_callable = self._channel.unary_stream(_UNARY_STREAM) + calls = [] + for _ in range(test_constants.THREAD_CONCURRENCY): + calls.append(multi_callable(_REQUEST)) + + self._trigger.await_calls() + + with self.assertRaises(grpc.RpcError) as exception_context: + next(multi_callable(_REQUEST)) + + self.assertEqual(grpc.StatusCode.RESOURCE_EXHAUSTED, + exception_context.exception.code()) + + self._trigger.trigger() + + for call in calls: + for response in call: + self.assertEqual(_RESPONSE, response) + + # Ensure a new request can be handled + new_call = multi_callable(_REQUEST) + for response in new_call: + self.assertEqual(_RESPONSE, response) + + def testStreamUnary(self): + multi_callable = self._channel.stream_unary(_STREAM_UNARY) + futures = [] + request = iter([_REQUEST] * test_constants.STREAM_LENGTH) + for _ in range(test_constants.THREAD_CONCURRENCY): + futures.append(multi_callable.future(request)) + + self._trigger.await_calls() + + with self.assertRaises(grpc.RpcError) as exception_context: + multi_callable(request) + + self.assertEqual(grpc.StatusCode.RESOURCE_EXHAUSTED, + exception_context.exception.code()) + + future_exception = multi_callable.future(request) + self.assertEqual(grpc.StatusCode.RESOURCE_EXHAUSTED, + future_exception.exception().code()) + + self._trigger.trigger() + + for future in futures: + self.assertEqual(_RESPONSE, future.result()) + + # Ensure a new request can be handled + self.assertEqual(_RESPONSE, multi_callable(request)) + + def testStreamStream(self): + multi_callable = self._channel.stream_stream(_STREAM_STREAM) + calls = [] + request = iter([_REQUEST] * test_constants.STREAM_LENGTH) + for _ in range(test_constants.THREAD_CONCURRENCY): + calls.append(multi_callable(request)) + + self._trigger.await_calls() + + with self.assertRaises(grpc.RpcError) as exception_context: + next(multi_callable(request)) + + self.assertEqual(grpc.StatusCode.RESOURCE_EXHAUSTED, + exception_context.exception.code()) + + self._trigger.trigger() + + for call in calls: + for response in call: + self.assertEqual(_RESPONSE, response) + + # Ensure a new request can be handled + new_call = multi_callable(request) + for response in new_call: + self.assertEqual(_RESPONSE, response) + + +if __name__ == '__main__': + unittest.main(verbosity=2) -- cgit v1.2.3 From b862b6ae205628d7713ee2e4cbb752206cf0b1f6 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Sun, 19 Mar 2017 23:36:21 -0700 Subject: use RTEST with channel watch arg to capture larger set of truthy args --- src/ruby/ext/grpc/rb_channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 3b1111e5e2..1fe825efd6 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -234,7 +234,7 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, /* "01" == 0 mandatory args, 1 (try_to_connect) is optional */ rb_scan_args(argc, argv, "01", &try_to_connect_param); - grpc_try_to_connect = try_to_connect_param == Qtrue ? 1 : 0; + grpc_try_to_connect = RTEST(try_to_connect_param) ? 1 : 0; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); ch = wrapper->wrapped; -- cgit v1.2.3 From 4e606751db54e289fae86aed7e1b1c2f35478469 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Sun, 19 Mar 2017 23:32:54 -0700 Subject: add end2end tests to formatter and adjust to formatter --- Rakefile | 3 ++- src/ruby/.rubocop.yml | 1 + src/ruby/end2end/channel_closing_client.rb | 6 +++++- src/ruby/end2end/channel_closing_driver.rb | 16 +++++++++------- src/ruby/end2end/channel_state_client.rb | 7 ++++--- src/ruby/end2end/channel_state_driver.rb | 11 ++++++----- src/ruby/end2end/end2end_common.rb | 22 ++++++++++++++-------- src/ruby/end2end/sig_handling_client.rb | 25 ++++++++++++++++--------- src/ruby/end2end/sig_handling_driver.rb | 9 +++++---- 9 files changed, 62 insertions(+), 38 deletions(-) diff --git a/Rakefile b/Rakefile index 12ac12710f..cc02aa130a 100755 --- a/Rakefile +++ b/Rakefile @@ -12,7 +12,8 @@ load 'tools/distrib/docker_for_windows.rb' # Add rubocop style checking tasks RuboCop::RakeTask.new(:rubocop) do |task| task.options = ['-c', 'src/ruby/.rubocop.yml'] - task.patterns = ['src/ruby/{lib,spec}/**/*.rb'] + # add end2end tests to formatter but don't add generated proto _pb.rb's + task.patterns = ['src/ruby/{lib,spec}/**/*.rb', 'src/ruby/end2end/*.rb'] end spec = Gem::Specification.load('grpc.gemspec') diff --git a/src/ruby/.rubocop.yml b/src/ruby/.rubocop.yml index 0f61ccfa81..7174f3b15a 100644 --- a/src/ruby/.rubocop.yml +++ b/src/ruby/.rubocop.yml @@ -9,6 +9,7 @@ AllCops: - 'bin/math_services_pb.rb' - 'pb/grpc/health/v1/*' - 'pb/test/**/*' + - 'end2end/lib/*' Metrics/CyclomaticComplexity: Max: 9 diff --git a/src/ruby/end2end/channel_closing_client.rb b/src/ruby/end2end/channel_closing_client.rb index a9df078421..8449797360 100755 --- a/src/ruby/end2end/channel_closing_client.rb +++ b/src/ruby/end2end/channel_closing_client.rb @@ -31,10 +31,13 @@ require_relative './end2end_common' +# Calls '#close' on a Channel when "shutdown" called. This tries to +# trigger a hang or crash bug by closing a channel actively being watched class ChannelClosingClientController < ClientControl::ClientController::Service def initialize(ch) @ch = ch end + def shutdown(_, _) @ch.close ClientControl::Void.new @@ -53,7 +56,8 @@ def main end end.parse! - ch = GRPC::Core::Channel.new("localhost:#{server_port}", {}, :this_channel_is_insecure) + ch = GRPC::Core::Channel.new("localhost:#{server_port}", {}, + :this_channel_is_insecure) srv = GRPC::RpcServer.new thd = Thread.new do diff --git a/src/ruby/end2end/channel_closing_driver.rb b/src/ruby/end2end/channel_closing_driver.rb index 98c8eaa1cd..43e2fe8cbb 100755 --- a/src/ruby/end2end/channel_closing_driver.rb +++ b/src/ruby/end2end/channel_closing_driver.rb @@ -29,23 +29,24 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# make sure that the client doesn't hang when channel is closed explictly while it's used +# make sure that the client doesn't hang when channel is closed +# explictly while it's used require_relative './end2end_common' def main - STDERR.puts "start server" + STDERR.puts 'start server' server_runner = ServerRunner.new server_port = server_runner.run sleep 1 - STDERR.puts "start client" - control_stub, client_pid = start_client("channel_closing_client.rb", server_port) + STDERR.puts 'start client' + control_stub, client_pid = start_client('channel_closing_client.rb', + server_port) sleep 3 - begin Timeout.timeout(10) do control_stub.shutdown(ClientControl::Void.new) @@ -55,8 +56,9 @@ def main STDERR.puts "timeout wait for client pid #{client_pid}" Process.kill('SIGKILL', client_pid) Process.wait(client_pid) - STDERR.puts "killed client child" - raise 'Timed out waiting for client process. It likely hangs when a channel is closed while connectivity is watched' + STDERR.puts 'killed client child' + raise 'Timed out waiting for client process. It likely hangs when a ' \ + 'channel is closed while connectivity is watched' end server_runner.stop diff --git a/src/ruby/end2end/channel_state_client.rb b/src/ruby/end2end/channel_state_client.rb index 476329ff73..08c21bbb8e 100755 --- a/src/ruby/end2end/channel_state_client.rb +++ b/src/ruby/end2end/channel_state_client.rb @@ -34,15 +34,16 @@ require_relative './end2end_common' def main server_port = '' OptionParser.new do |opts| - opts.on('--client_control_port=P', String) do |p| - STDERR.puts "client_control_port ignored" + opts.on('--client_control_port=P', String) do + STDERR.puts 'client_control_port ignored' end opts.on('--server_port=P', String) do |p| server_port = p end end.parse! - ch = GRPC::Core::Channel.new("localhost:#{server_port}", {}, :this_channel_is_insecure) + ch = GRPC::Core::Channel.new("localhost:#{server_port}", {}, + :this_channel_is_insecure) loop do state = ch.connectivity_state diff --git a/src/ruby/end2end/channel_state_driver.rb b/src/ruby/end2end/channel_state_driver.rb index 8ef32acfff..c3184bf939 100755 --- a/src/ruby/end2end/channel_state_driver.rb +++ b/src/ruby/end2end/channel_state_driver.rb @@ -34,14 +34,14 @@ require_relative './end2end_common' def main - STDERR.puts "start server" + STDERR.puts 'start server' server_runner = ServerRunner.new server_port = server_runner.run sleep 1 - STDERR.puts "start client" - _, client_pid = start_client("channel_state_client.rb", server_port) + STDERR.puts 'start client' + _, client_pid = start_client('channel_state_client.rb', server_port) sleep 3 @@ -53,8 +53,9 @@ def main STDERR.puts "timeout wait for client pid #{client_pid}" Process.kill('SIGKILL', client_pid) Process.wait(client_pid) - STDERR.puts "killed client child" - raise 'Timed out waiting for client process. It likely hangs when ended abruptly' + STDERR.puts 'killed client child' + raise 'Timed out waiting for client process. ' \ + 'It likely hangs when ended abruptly' end server_runner.stop diff --git a/src/ruby/end2end/end2end_common.rb b/src/ruby/end2end/end2end_common.rb index d98e41f642..9534bb2078 100755 --- a/src/ruby/end2end/end2end_common.rb +++ b/src/ruby/end2end/end2end_common.rb @@ -43,6 +43,7 @@ require 'socket' require 'optparse' require 'thread' require 'timeout' +require 'English' # see https://github.com/bbatsov/rubocop/issues/1747 # GreeterServer is simple server that implements the Helloworld Greeter server. class EchoServerImpl < Echo::EchoServer::Service @@ -52,9 +53,11 @@ class EchoServerImpl < Echo::EchoServer::Service end end +# ServerRunner starts an "echo server" that test clients can make calls to class ServerRunner def initialize end + def run @srv = GRPC::RpcServer.new port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure) @@ -66,10 +69,11 @@ class ServerRunner @srv.wait_till_running port end + def stop @srv.stop @thd.join - raise "server not stopped" unless @srv.stopped? + fail 'server not stopped' unless @srv.stopped? end end @@ -81,22 +85,24 @@ def start_client(client_main, server_port) tmp_server.close client_path = File.join(this_dir, client_main) - client_pid = Process.spawn(RbConfig.ruby, client_path, - "--client_control_port=#{client_control_port}", - "--server_port=#{server_port}") + client_pid = Process.spawn(RbConfig.ruby, + client_path, + "--client_control_port=#{client_control_port}", + "--server_port=#{server_port}") sleep 1 - control_stub = ClientControl::ClientController::Stub.new("localhost:#{client_control_port}", :this_channel_is_insecure) - return control_stub, client_pid + control_stub = ClientControl::ClientController::Stub.new( + "localhost:#{client_control_port}", :this_channel_is_insecure) + [control_stub, client_pid] end def cleanup(control_stub, client_pid, server_runner) control_stub.shutdown(ClientControl::Void.new) Process.wait(client_pid) - client_exit_code = $?.exitstatus + client_exit_code = $CHILD_STATUS if client_exit_code != 0 - raise "term sig test failure: client exit code: #{client_exit_code}" + fail "term sig test failure: client exit code: #{client_exit_code}" end server_runner.stop diff --git a/src/ruby/end2end/sig_handling_client.rb b/src/ruby/end2end/sig_handling_client.rb index f0b2ba61ca..5b1e54718e 100755 --- a/src/ruby/end2end/sig_handling_client.rb +++ b/src/ruby/end2end/sig_handling_client.rb @@ -31,20 +31,25 @@ require_relative './end2end_common' +# Test client. Sends RPC's as normal but process also has signal handlers class SigHandlingClientController < ClientControl::ClientController::Service def initialize(srv, stub) @srv = srv @stub = stub end + def do_echo_rpc(req, _) response = @stub.echo(Echo::EchoRequest.new(request: req.request)) - raise "bad response" unless response.response == req.request + fail 'bad response' unless response.response == req.request ClientControl::Void.new end + def shutdown(_, _) Thread.new do - #TODO(apolcyn) There is a race between stopping the server and the "shutdown" rpc completing, - # See if stop method on server can end active RPC cleanly, to avoid this sleep. + # TODO(apolcyn) There is a race between stopping the + # server and the "shutdown" rpc completing, + # See if stop method on server can end active RPC cleanly, to + # avoid this sleep. sleep 3 @srv.stop end @@ -64,17 +69,19 @@ def main end end.parse! - Signal.trap("TERM") do - STDERR.puts "SIGTERM received" + Signal.trap('TERM') do + STDERR.puts 'SIGTERM received' end - Signal.trap("INT") do - STDERR.puts "SIGINT received" + Signal.trap('INT') do + STDERR.puts 'SIGINT received' end srv = GRPC::RpcServer.new - srv.add_http2_port("0.0.0.0:#{client_control_port}", :this_port_is_insecure) - stub = Echo::EchoServer::Stub.new("localhost:#{server_port}", :this_channel_is_insecure) + srv.add_http2_port("0.0.0.0:#{client_control_port}", + :this_port_is_insecure) + stub = Echo::EchoServer::Stub.new("localhost:#{server_port}", + :this_channel_is_insecure) srv.handle(SigHandlingClientController.new(srv, stub)) srv.run end diff --git a/src/ruby/end2end/sig_handling_driver.rb b/src/ruby/end2end/sig_handling_driver.rb index 4d205da9ae..c5d46e074c 100755 --- a/src/ruby/end2end/sig_handling_driver.rb +++ b/src/ruby/end2end/sig_handling_driver.rb @@ -35,20 +35,21 @@ require_relative './end2end_common' def main - STDERR.puts "start server" + STDERR.puts 'start server' server_runner = ServerRunner.new server_port = server_runner.run sleep 1 - STDERR.puts "start client" - control_stub, client_pid = start_client("sig_handling_client.rb", server_port) + STDERR.puts 'start client' + control_stub, client_pid = start_client('sig_handling_client.rb', server_port) sleep 1 count = 0 while count < 5 - control_stub.do_echo_rpc(ClientControl::DoEchoRpcRequest.new(request: 'hello')) + control_stub.do_echo_rpc( + ClientControl::DoEchoRpcRequest.new(request: 'hello')) Process.kill('SIGTERM', client_pid) Process.kill('SIGINT', client_pid) count += 1 -- cgit v1.2.3 From 69e5a286351fb87c54d29322fbc03859a829e636 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 20 Mar 2017 12:51:17 -0700 Subject: Going for 1.2.0 --- BUILD | 2 +- CMakeLists.txt | 2 +- Makefile | 4 ++-- build.yaml | 2 +- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.json | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Auth/project.json | 4 ++-- src/csharp/Grpc.Core.Testing/project.json | 4 ++-- src/csharp/Grpc.Core/VersionInfo.cs | 2 +- src/csharp/Grpc.Core/project.json | 2 +- src/csharp/Grpc.HealthCheck/project.json | 4 ++-- src/csharp/Grpc.Reflection/project.json | 4 ++-- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/node/health_check/package.json | 4 ++-- src/node/tools/package.json | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 32 files changed, 40 insertions(+), 40 deletions(-) diff --git a/BUILD b/BUILD index 585c26ad1c..db08f57fbf 100644 --- a/BUILD +++ b/BUILD @@ -41,7 +41,7 @@ g_stands_for = "green" core_version = "3.0.0-dev" -version = "1.2.0-pre1" +version = "1.2.0" grpc_cc_library( name = "gpr", diff --git a/CMakeLists.txt b/CMakeLists.txt index 28bff0d231..ce9c346ddd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.2.0-pre2") +set(PACKAGE_VERSION "1.2.0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 331523ed7d..1d2436cc94 100644 --- a/Makefile +++ b/Makefile @@ -412,8 +412,8 @@ Q = @ endif CORE_VERSION = 3.0.0-dev -CPP_VERSION = 1.2.0-pre2 -CSHARP_VERSION = 1.2.0-pre2 +CPP_VERSION = 1.2.0 +CSHARP_VERSION = 1.2.0 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index ce88586b92..91d65d84ef 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 3.0.0-dev g_stands_for: green - version: 1.2.0-pre2 + version: 1.2.0 filegroups: - name: census public_headers: diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6857f4bfb2..5530588abc 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -37,7 +37,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.2.0-pre2' + version = '1.2.0' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index e37a34b672..dd0f6e89f3 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.2.0-pre2' + version = '1.2.0' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 7cd110b740..23301e1adc 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.2.0-pre2' + version = '1.2.0' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'http://www.grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 073f3b7a0f..b91e815e41 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -35,7 +35,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.2.0-pre2' + version = '1.2.0' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' diff --git a/package.json b/package.json index 36f7d35a7e..db1e5dddbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grpc", - "version": "1.2.0-pre2", + "version": "1.2.0", "author": "Google Inc.", "description": "gRPC Library for Node", "homepage": "http://www.grpc.io/", diff --git a/package.xml b/package.xml index 7b3e6b129f..6fc30f1aa2 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2017-03-01 - 1.2.0RC2 - 1.2.0RC2 + 1.2.0 + 1.2.0 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index 9b30223f47..fd80b98f3c 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -37,5 +37,5 @@ #include namespace grpc { -grpc::string Version() { return "1.2.0-pre2"; } +grpc::string Version() { return "1.2.0"; } } diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index fc0a8ba0de..ad708e32c4 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre2", + "version": "1.2.0", "title": "gRPC C# Auth", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre2", + "Grpc.Core": "1.2.0", "Google.Apis.Auth": "1.21.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Core.Testing/project.json b/src/csharp/Grpc.Core.Testing/project.json index 0070b74cc3..737ae3b926 100644 --- a/src/csharp/Grpc.Core.Testing/project.json +++ b/src/csharp/Grpc.Core.Testing/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre2", + "version": "1.2.0", "title": "gRPC C# Core Testing", "authors": [ "Google Inc." ], "copyright": "Copyright 2017, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre2" + "Grpc.Core": "1.2.0" }, "frameworks": { "net45": { diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index 8773183aaf..e4e0b5b2ad 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -53,6 +53,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.2.0-pre2"; + public const string CurrentVersion = "1.2.0"; } } diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index 0f9f1e819e..5f2a5f944d 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre2", + "version": "1.2.0", "title": "gRPC C# Core", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index ae3094b903..d2acce5cf4 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre2", + "version": "1.2.0", "title": "gRPC C# Healthchecking", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre2", + "Grpc.Core": "1.2.0", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Reflection/project.json b/src/csharp/Grpc.Reflection/project.json index 8daa9e47dd..8b7a46aa4a 100644 --- a/src/csharp/Grpc.Reflection/project.json +++ b/src/csharp/Grpc.Reflection/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0-pre2", + "version": "1.2.0", "title": "gRPC C# Reflection", "authors": [ "Google Inc." ], "copyright": "Copyright 2016, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0-pre2", + "Grpc.Core": "1.2.0", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index 9e1074833f..8180098c01 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -28,7 +28,7 @@ @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @rem Current package versions -set VERSION=1.2.0-pre2 +set VERSION=1.2.0 set PROTOBUF_VERSION=3.0.0 @rem Adjust the location of nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index a283dc76f1..b758f3fc84 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -66,7 +66,7 @@ dotnet pack --configuration Release Grpc.Auth/project.json --output ../../artifa dotnet pack --configuration Release Grpc.HealthCheck/project.json --output ../../artifacts dotnet pack --configuration Release Grpc.Reflection/project.json --output ../../artifacts -nuget pack Grpc.nuspec -Version "1.2.0-pre2" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.2.0-pre2" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.2.0" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.2.0" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json index d03d5a4d62..31b4ed24ad 100644 --- a/src/node/health_check/package.json +++ b/src/node/health_check/package.json @@ -1,6 +1,6 @@ { "name": "grpc-health-check", - "version": "1.2.0-pre2", + "version": "1.2.0", "author": "Google Inc.", "description": "Health check service for use with gRPC", "repository": { @@ -15,7 +15,7 @@ } ], "dependencies": { - "grpc": "^1.2.0-pre2", + "grpc": "^1.2.0", "lodash": "^3.9.3", "google-protobuf": "^3.0.0" }, diff --git a/src/node/tools/package.json b/src/node/tools/package.json index e3b53bcdf5..8370fa65a4 100644 --- a/src/node/tools/package.json +++ b/src/node/tools/package.json @@ -1,6 +1,6 @@ { "name": "grpc-tools", - "version": "1.2.0-pre2", + "version": "1.2.0", "author": "Google Inc.", "description": "Tools for developing with gRPC on Node.js", "homepage": "http://www.grpc.io/", diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index c4867768f0..4b8faf7582 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.2.0-pre2' + v = '1.2.0' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 289a55d083..346763326e 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -38,4 +38,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.2.0-pre2" +#define GRPC_OBJC_VERSION_STRING @"1.2.0" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index ff72fde583..1da40ca19f 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION='1.2.0rc2' +VERSION='1.2.0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 6e098452a8..362f21f458 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION='1.2.0rc2' +VERSION='1.2.0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 3fe4779e15..79b7c1d665 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION='1.2.0rc2' +VERSION='1.2.0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index ca78d14ad9..722093ddd3 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION='1.2.0rc2' +VERSION='1.2.0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 2cc0a950d0..f35f74b852 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.2.0.pre2' + VERSION = '1.2.0' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 22a2a72e4c..af39467db1 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -29,6 +29,6 @@ module GRPC module Tools - VERSION = '1.2.0.pre2' + VERSION = '1.2.0' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index b784a80bf5..7829999e03 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION='1.2.0rc2' +VERSION='1.2.0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 7af9246bee..9d7bd84e92 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.0-pre2 +PROJECT_NUMBER = 1.2.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 5ca65127dc..d64190ad7f 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.0-pre2 +PROJECT_NUMBER = 1.2.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 3e30832ccad4df08e3ca1967ab9d3d3c48f27a6f Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 20 Mar 2017 17:00:45 -0700 Subject: bump v1.2.x branch to 1.2.1-pre1 --- CMakeLists.txt | 2 +- Makefile | 4 ++-- build.yaml | 2 +- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.json | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Auth/project.json | 4 ++-- src/csharp/Grpc.Core.Testing/project.json | 4 ++-- src/csharp/Grpc.Core/VersionInfo.cs | 4 ++-- src/csharp/Grpc.Core/project.json | 2 +- src/csharp/Grpc.HealthCheck/project.json | 4 ++-- src/csharp/Grpc.Reflection/project.json | 4 ++-- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/node/health_check/package.json | 4 ++-- src/node/tools/package.json | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/php/composer.json | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 32 files changed, 41 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce9c346ddd..3a0787e2f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.2.0") +set(PACKAGE_VERSION "1.2.1-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 1d2436cc94..4a32fed2c9 100644 --- a/Makefile +++ b/Makefile @@ -412,8 +412,8 @@ Q = @ endif CORE_VERSION = 3.0.0-dev -CPP_VERSION = 1.2.0 -CSHARP_VERSION = 1.2.0 +CPP_VERSION = 1.2.1-pre1 +CSHARP_VERSION = 1.2.1-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index 91d65d84ef..1ec134645c 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 3.0.0-dev g_stands_for: green - version: 1.2.0 + version: 1.2.1-pre1 filegroups: - name: census public_headers: diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 5530588abc..c502c4440e 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -37,7 +37,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.2.0' + version = '1.2.1-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index dd0f6e89f3..5fddf8fd82 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.2.0' + version = '1.2.1-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 23301e1adc..84478f56ea 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.2.0' + version = '1.2.1-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'http://www.grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index b91e815e41..dc1dd38a6e 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -35,7 +35,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.2.0' + version = '1.2.1-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' diff --git a/package.json b/package.json index db1e5dddbe..004f968ea2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grpc", - "version": "1.2.0", + "version": "1.2.1-pre1", "author": "Google Inc.", "description": "gRPC Library for Node", "homepage": "http://www.grpc.io/", diff --git a/package.xml b/package.xml index 6fc30f1aa2..fc3d092372 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2017-03-01 - 1.2.0 - 1.2.0 + 1.2.1RC1 + 1.2.1RC1 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index fd80b98f3c..a40f8f0a28 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -37,5 +37,5 @@ #include namespace grpc { -grpc::string Version() { return "1.2.0"; } +grpc::string Version() { return "1.2.1-pre1"; } } diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index ad708e32c4..16584f9b14 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.2.1-pre1", "title": "gRPC C# Auth", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0", + "Grpc.Core": "1.2.1-pre1", "Google.Apis.Auth": "1.21.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Core.Testing/project.json b/src/csharp/Grpc.Core.Testing/project.json index 737ae3b926..960774c0d9 100644 --- a/src/csharp/Grpc.Core.Testing/project.json +++ b/src/csharp/Grpc.Core.Testing/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.2.1-pre1", "title": "gRPC C# Core Testing", "authors": [ "Google Inc." ], "copyright": "Copyright 2017, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0" + "Grpc.Core": "1.2.1-pre1" }, "frameworks": { "net45": { diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index e4e0b5b2ad..25be59a61c 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -48,11 +48,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.2.0.0"; + public const string CurrentAssemblyFileVersion = "1.2.1.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.2.0"; + public const string CurrentVersion = "1.2.1-pre1"; } } diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index 5f2a5f944d..5338011dd2 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.2.1-pre1", "title": "gRPC C# Core", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index d2acce5cf4..2a7ec78852 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.2.1-pre1", "title": "gRPC C# Healthchecking", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0", + "Grpc.Core": "1.2.1-pre1", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Reflection/project.json b/src/csharp/Grpc.Reflection/project.json index 8b7a46aa4a..18bc2d8d69 100644 --- a/src/csharp/Grpc.Reflection/project.json +++ b/src/csharp/Grpc.Reflection/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.2.1-pre1", "title": "gRPC C# Reflection", "authors": [ "Google Inc." ], "copyright": "Copyright 2016, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.0", + "Grpc.Core": "1.2.1-pre1", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index 8180098c01..e4f75d3ba0 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -28,7 +28,7 @@ @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @rem Current package versions -set VERSION=1.2.0 +set VERSION=1.2.1-pre1 set PROTOBUF_VERSION=3.0.0 @rem Adjust the location of nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index b758f3fc84..a5a6b6108a 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -66,7 +66,7 @@ dotnet pack --configuration Release Grpc.Auth/project.json --output ../../artifa dotnet pack --configuration Release Grpc.HealthCheck/project.json --output ../../artifacts dotnet pack --configuration Release Grpc.Reflection/project.json --output ../../artifacts -nuget pack Grpc.nuspec -Version "1.2.0" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.2.0" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.2.1-pre1" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.2.1-pre1" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json index 31b4ed24ad..a3966a4abb 100644 --- a/src/node/health_check/package.json +++ b/src/node/health_check/package.json @@ -1,6 +1,6 @@ { "name": "grpc-health-check", - "version": "1.2.0", + "version": "1.2.1-pre1", "author": "Google Inc.", "description": "Health check service for use with gRPC", "repository": { @@ -15,7 +15,7 @@ } ], "dependencies": { - "grpc": "^1.2.0", + "grpc": "^1.2.1-pre1", "lodash": "^3.9.3", "google-protobuf": "^3.0.0" }, diff --git a/src/node/tools/package.json b/src/node/tools/package.json index 8370fa65a4..de64cca844 100644 --- a/src/node/tools/package.json +++ b/src/node/tools/package.json @@ -1,6 +1,6 @@ { "name": "grpc-tools", - "version": "1.2.0", + "version": "1.2.1-pre1", "author": "Google Inc.", "description": "Tools for developing with gRPC on Node.js", "homepage": "http://www.grpc.io/", diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 4b8faf7582..906fea86b7 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.2.0' + v = '1.2.1-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 346763326e..a623d2d772 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -38,4 +38,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.2.0" +#define GRPC_OBJC_VERSION_STRING @"1.2.1-pre1" diff --git a/src/php/composer.json b/src/php/composer.json index 491e34795a..ee7616b45d 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "BSD-3-Clause", - "version": "1.2.0", + "version": "1.2.1", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.1.0" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 1da40ca19f..5a0cf4df2e 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION='1.2.0' +VERSION='1.2.1rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 362f21f458..c401cdbbca 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION='1.2.0' +VERSION='1.2.1rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 79b7c1d665..83f5d950b1 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION='1.2.0' +VERSION='1.2.1rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 722093ddd3..3613aeee13 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION='1.2.0' +VERSION='1.2.1rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index f35f74b852..e9759ad206 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.2.0' + VERSION = '1.2.1.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index af39467db1..a11e53cb2b 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -29,6 +29,6 @@ module GRPC module Tools - VERSION = '1.2.0' + VERSION = '1.2.1.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 7829999e03..73f06ba875 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION='1.2.0' +VERSION='1.2.1rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 9d7bd84e92..8b69893696 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.0 +PROJECT_NUMBER = 1.2.1-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index d64190ad7f..823f9b0168 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.0 +PROJECT_NUMBER = 1.2.1-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From ea282e9c4cd422a1edcbdd30a81b8f58c8523063 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Mon, 20 Mar 2017 20:53:34 -0700 Subject: add passing test that kills a process while there are active watch chan state calls --- .../end2end/sig_int_during_channel_watch_client.rb | 70 ++++++++++++++++++++++ .../end2end/sig_int_during_channel_watch_driver.rb | 67 +++++++++++++++++++++ .../helper_scripts/run_ruby_end2end_tests.sh | 1 + 3 files changed, 138 insertions(+) create mode 100755 src/ruby/end2end/sig_int_during_channel_watch_client.rb create mode 100755 src/ruby/end2end/sig_int_during_channel_watch_driver.rb diff --git a/src/ruby/end2end/sig_int_during_channel_watch_client.rb b/src/ruby/end2end/sig_int_during_channel_watch_client.rb new file mode 100755 index 0000000000..389fc5ba33 --- /dev/null +++ b/src/ruby/end2end/sig_int_during_channel_watch_client.rb @@ -0,0 +1,70 @@ +#!/usr/bin/env ruby + +# Copyright 2015, 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. + +require_relative './end2end_common' + +# Start polling the channel state in both the main thread +# and a child thread. Try to get the driver to send process-ending +# interrupt while both a child thread and the main thread are in the +# middle of a blocking connectivity_state call. +def main + server_port = '' + OptionParser.new do |opts| + opts.on('--client_control_port=P', String) do + STDERR.puts 'client_control_port not used' + end + opts.on('--server_port=P', String) do |p| + server_port = p + end + end.parse! + + thd = Thread.new do + child_thread_channel = GRPC::Core::Channel.new("localhost:#{server_port}", + {}, + :this_channel_is_insecure) + loop do + state = child_thread_channel.connectivity_state(false) + child_thread_channel.watch_connectivity_state(state, Time.now + 360) + end + end + + main_channel = GRPC::Core::Channel.new("localhost:#{server_port}", + {}, + :this_channel_is_insecure) + loop do + state = main_channel.connectivity_state(false) + main_channel.watch_connectivity_state(state, Time.now + 360) + end + + thd.join +end + +main diff --git a/src/ruby/end2end/sig_int_during_channel_watch_driver.rb b/src/ruby/end2end/sig_int_during_channel_watch_driver.rb new file mode 100755 index 0000000000..8c9fecd549 --- /dev/null +++ b/src/ruby/end2end/sig_int_during_channel_watch_driver.rb @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby + +# Copyright 2016, 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. + +# abruptly end a process that has active calls to +# Channel.watch_connectivity_state + +require_relative './end2end_common' + +def main + STDERR.puts 'start server' + server_runner = ServerRunner.new + server_port = server_runner.run + + sleep 1 + + STDERR.puts 'start client' + _, client_pid = start_client('sig_int_during_channel_watch_client.rb', + server_port) + + # give time for the client to get into the middle + # of a channel state watch call + sleep 1 + Process.kill('SIGINT', client_pid) + + begin + Timeout.timeout(10) do + Process.wait(client_pid) + end + rescue Timeout::Error + STDERR.puts "timeout wait for client pid #{client_pid}" + Process.kill('SIGKILL', client_pid) + Process.wait(client_pid) + STDERR.puts 'killed client child' + raise 'Timed out waiting for client process. It likely hangs when a ' \ + 'SIGINT is sent while there is an active connectivity_state call' + end +end + +main diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh index eb75878caf..d7da6364d8 100755 --- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh +++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh @@ -37,4 +37,5 @@ EXIT_CODE=0 ruby src/ruby/end2end/sig_handling_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/channel_state_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/channel_closing_driver.rb || EXIT_CODE=1 +ruby src/ruby/end2end/sig_int_during_channel_watch_driver.rb || EXIT_CODE=1 exit $EXIT_CODE -- cgit v1.2.3 From 5b881460d24bc930339d1cfd37805a7eadeee5c0 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 21 Mar 2017 18:31:29 -0700 Subject: make fewer lock/unlock calls and loop on cv_wait in watch conn state --- src/ruby/ext/grpc/rb_channel.c | 40 +++++++++++++++----------------- src/ruby/spec/channel_connection_spec.rb | 2 +- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 1fe825efd6..c12ea921c9 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -78,6 +78,7 @@ typedef struct grpc_rb_channel { grpc_connectivity_state current_connectivity_state; int mu_init_done; + int abort_watch_connectivity_state; gpr_mu channel_mu; gpr_cv channel_cv; } grpc_rb_channel; @@ -193,6 +194,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { wrapper->mu_init_done = 1; gpr_mu_lock(&wrapper->channel_mu); + wrapper->abort_watch_connectivity_state = 0; wrapper->current_connectivity_state = grpc_channel_check_connectivity_state(wrapper->wrapped, 0); wrapper->safe_to_destroy = 0; wrapper->request_safe_destroy = 0; @@ -242,8 +244,7 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, rb_raise(rb_eRuntimeError, "closed!"); return Qnil; } - return LONG2NUM( - grpc_channel_check_connectivity_state(ch, grpc_try_to_connect)); + return LONG2NUM(grpc_channel_check_connectivity_state(wrapper->wrapped, grpc_try_to_connect)); } typedef struct watch_state_stack { @@ -254,39 +255,35 @@ typedef struct watch_state_stack { static void *watch_channel_state_without_gvl(void *arg) { watch_state_stack *stack = (watch_state_stack*)arg; - gpr_timespec deadline = stack->deadline; grpc_rb_channel *wrapper = stack->wrapper; int last_state = stack->last_state; + void *return_value = (void*)0; + gpr_timespec time_check_increment = gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); + gpr_mu_lock(&wrapper->channel_mu); - if (wrapper->current_connectivity_state != last_state) { - gpr_mu_unlock(&wrapper->channel_mu); - return (void*)0; - } - if (wrapper->request_safe_destroy) { - gpr_mu_unlock(&wrapper->channel_mu); - return (void*)0; + while(wrapper->current_connectivity_state == last_state && + !wrapper->request_safe_destroy && + !wrapper->safe_to_destroy && + !wrapper->abort_watch_connectivity_state && + gpr_time_cmp(deadline, gpr_now(GPR_CLOCK_REALTIME)) > 0) { + gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, time_check_increment); } - if (wrapper->safe_to_destroy) { - gpr_mu_unlock(&wrapper->channel_mu); - return (void*)0; - } - - gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, deadline); - if (wrapper->current_connectivity_state != last_state) { - gpr_mu_unlock(&wrapper->channel_mu); - return (void*)1; + return_value = (void*)1; } gpr_mu_unlock(&wrapper->channel_mu); - return (void*)0; + + return return_value; } static void watch_channel_state_unblocking_func(void *arg) { grpc_rb_channel *wrapper = (grpc_rb_channel*)arg; gpr_log(GPR_DEBUG, "GRPC_RUBY: watch channel state unblocking func called"); gpr_mu_lock(&wrapper->channel_mu); + wrapper->abort_watch_connectivity_state = 1; gpr_cv_broadcast(&wrapper->channel_cv); gpr_mu_unlock(&wrapper->channel_mu); } @@ -461,8 +458,9 @@ static void grpc_rb_channel_try_register_connection_polling( // Note requires wrapper->wrapped, wrapper->channel_mu/cv initialized static void grpc_rb_channel_safe_destroy(grpc_rb_channel *wrapper) { gpr_mu_lock(&wrapper->channel_mu); + wrapper->request_safe_destroy = 1; + while (!wrapper->safe_to_destroy) { - wrapper->request_safe_destroy = 1; gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } diff --git a/src/ruby/spec/channel_connection_spec.rb b/src/ruby/spec/channel_connection_spec.rb index b344052a21..940d68b9b0 100644 --- a/src/ruby/spec/channel_connection_spec.rb +++ b/src/ruby/spec/channel_connection_spec.rb @@ -92,7 +92,7 @@ describe 'channel connection behavior' do end it 'observably connects and reconnects to transient server' \ - 'when using the channel state API' do + ' when using the channel state API' do port = start_server ch = GRPC::Core::Channel.new("localhost:#{port}", {}, :this_channel_is_insecure) -- cgit v1.2.3 From 06d4edd28355877e71733a0d246a9b5b4c67452b Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 21 Mar 2017 19:24:07 -0700 Subject: fix setting of time_check_increment in watch conn state loop --- src/ruby/ext/grpc/rb_channel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index c12ea921c9..acf22dd46b 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -259,9 +259,7 @@ static void *watch_channel_state_without_gvl(void *arg) { grpc_rb_channel *wrapper = stack->wrapper; int last_state = stack->last_state; void *return_value = (void*)0; - gpr_timespec time_check_increment = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); - + gpr_timespec time_check_increment; gpr_mu_lock(&wrapper->channel_mu); while(wrapper->current_connectivity_state == last_state && @@ -269,6 +267,8 @@ static void *watch_channel_state_without_gvl(void *arg) { !wrapper->safe_to_destroy && !wrapper->abort_watch_connectivity_state && gpr_time_cmp(deadline, gpr_now(GPR_CLOCK_REALTIME)) > 0) { + time_check_increment = gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, time_check_increment); } if (wrapper->current_connectivity_state != last_state) { -- cgit v1.2.3 From 513070cf20c973727c7f5899ac9018f7fd349b1f Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 22 Mar 2017 10:27:31 -0700 Subject: get rid of time check increment in watch connectivity state loop --- src/ruby/ext/grpc/rb_channel.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index acf22dd46b..ba23052521 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -259,7 +259,6 @@ static void *watch_channel_state_without_gvl(void *arg) { grpc_rb_channel *wrapper = stack->wrapper; int last_state = stack->last_state; void *return_value = (void*)0; - gpr_timespec time_check_increment; gpr_mu_lock(&wrapper->channel_mu); while(wrapper->current_connectivity_state == last_state && @@ -267,9 +266,7 @@ static void *watch_channel_state_without_gvl(void *arg) { !wrapper->safe_to_destroy && !wrapper->abort_watch_connectivity_state && gpr_time_cmp(deadline, gpr_now(GPR_CLOCK_REALTIME)) > 0) { - time_check_increment = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); - gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, time_check_increment); + gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, deadline); } if (wrapper->current_connectivity_state != last_state) { return_value = (void*)1; -- cgit v1.2.3 From 02d131b5ef69e5427b078caa68c49da8eda91bac Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 22 Mar 2017 15:12:32 -0700 Subject: fix mac crash on abruptly ended server thread --- src/ruby/end2end/sig_int_during_channel_watch_driver.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ruby/end2end/sig_int_during_channel_watch_driver.rb b/src/ruby/end2end/sig_int_during_channel_watch_driver.rb index 8c9fecd549..84d039bf19 100755 --- a/src/ruby/end2end/sig_int_during_channel_watch_driver.rb +++ b/src/ruby/end2end/sig_int_during_channel_watch_driver.rb @@ -62,6 +62,8 @@ def main raise 'Timed out waiting for client process. It likely hangs when a ' \ 'SIGINT is sent while there is an active connectivity_state call' end + + server_runner.stop end main -- cgit v1.2.3 From 604abf4fa57fffa5448a85d606db290574c33493 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 23 Mar 2017 11:20:15 -0700 Subject: add generated imports header to be able to build on mingw --- src/ruby/ext/grpc/rb_channel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index ba23052521..1c20c8813f 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -34,6 +34,7 @@ #include #include +#include "rb_grpc_imports.generated.h" #include "rb_byte_buffer.h" #include "rb_channel.h" -- cgit v1.2.3