diff options
-rw-r--r-- | gRPC-Core.podspec | 1 | ||||
-rw-r--r-- | src/compiler/objective_c_generator.cc | 21 | ||||
-rw-r--r-- | src/compiler/objective_c_generator.h | 4 | ||||
-rw-r--r-- | src/compiler/objective_c_plugin.cc | 40 | ||||
-rw-r--r-- | src/core/lib/iomgr/ev_epollex_linux.cc | 3 | ||||
-rw-r--r-- | src/core/lib/support/log_posix.cc | 2 | ||||
-rw-r--r-- | src/objective-c/tests/RemoteTestClient/RemoteTest.podspec | 2 | ||||
-rwxr-xr-x | src/ruby/end2end/load_grpc_with_gc_stress_driver.rb | 32 | ||||
-rw-r--r-- | src/ruby/ext/grpc/rb_grpc.c | 2 | ||||
-rw-r--r-- | templates/gRPC-Core.podspec.template | 1 | ||||
-rw-r--r-- | test/cpp/end2end/async_end2end_test.cc | 9 | ||||
-rw-r--r-- | test/cpp/end2end/end2end_test.cc | 5 | ||||
-rw-r--r-- | test/cpp/interop/stress_test.cc | 7 | ||||
-rwxr-xr-x | tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh | 1 | ||||
-rwxr-xr-x | tools/run_tests/python_utils/jobset.py | 10 | ||||
-rw-r--r-- | tools/run_tests/python_utils/upload_test_results.py | 15 |
16 files changed, 123 insertions, 32 deletions
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 0afdb60d35..659ea07ba6 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -84,6 +84,7 @@ Pod::Spec.new do |s| # build. 'USE_HEADERMAP' => 'NO', 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"', } s.default_subspecs = 'Interface', 'Implementation' diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index c05d15375b..33b5fedd5c 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -17,6 +17,7 @@ */ #include <map> +#include <set> #include <sstream> #include "src/compiler/config.h" @@ -29,7 +30,9 @@ using ::google::protobuf::compiler::objectivec::ClassName; using ::grpc::protobuf::io::Printer; using ::grpc::protobuf::MethodDescriptor; using ::grpc::protobuf::ServiceDescriptor; +using ::grpc::protobuf::FileDescriptor; using ::std::map; +using ::std::set; namespace grpc_objective_c_generator { namespace { @@ -190,6 +193,24 @@ void PrintMethodImplementations(Printer *printer, } // namespace +::grpc::string GetAllMessageClasses(const FileDescriptor *file) { + ::grpc::string output; + set< ::grpc::string> classes; + for (int i = 0; i < file->service_count(); i++) { + const auto service = file->service(i); + for (int i = 0; i < service->method_count(); i++) { + const auto method = service->method(i); + classes.insert(ClassName(method->input_type())); + classes.insert(ClassName(method->output_type())); + } + } + for (auto one_class : classes) { + output += " @class " + one_class + ";\n"; + } + + return output; +} + ::grpc::string GetHeader(const ServiceDescriptor *service) { ::grpc::string output; { diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h index edbee7ff52..e912a52415 100644 --- a/src/compiler/objective_c_generator.h +++ b/src/compiler/objective_c_generator.h @@ -24,8 +24,12 @@ namespace grpc_objective_c_generator { using ::grpc::protobuf::ServiceDescriptor; +using ::grpc::protobuf::FileDescriptor; using ::grpc::string; +// Returns forward declaration of classes in the generated header file. +string GetAllMessageClasses(const FileDescriptor *file); + // Returns the content to be included in the "global_scope" insertion point of // the generated header file. string GetHeader(const ServiceDescriptor *service); diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 96a3375e96..e751d0562e 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -58,9 +58,10 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { "#import <RxLibrary/GRXWriteable.h>\n" "#import <RxLibrary/GRXWriter.h>\n"; - // TODO(jcanizales): Instead forward-declare the input and output types - // and import the files in the .pbrpc.m ::grpc::string proto_imports; + proto_imports += "#if GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO\n" + + grpc_objective_c_generator::GetAllMessageClasses(file) + + "#else\n"; for (int i = 0; i < file->dependency_count(); i++) { ::grpc::string header = grpc_objective_c_generator::MessageHeaderName(file->dependency(i)); @@ -70,19 +71,20 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { grpc_generator::StripPrefix(&base_name, "google/protobuf/"); // create the import code snippet proto_imports += - "#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS\n" - " #import <" + + " #if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS\n" + " #import <" + ::grpc::string(ProtobufLibraryFrameworkName) + "/" + base_name + ">\n" - "#else\n" - " #import \"" + + " #else\n" + " #import \"" + header + "\"\n" - "#endif\n"; + " #endif\n"; } else { - proto_imports += ::grpc::string("#import \"") + header + "\"\n"; + proto_imports += ::grpc::string(" #import \"") + header + "\"\n"; } } + proto_imports += "#endif\n"; ::grpc::string declarations; for (int i = 0; i < file->service_count(); i++) { @@ -106,6 +108,28 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ".pbrpc.h\"\n\n" "#import <ProtoRPC/ProtoRPC.h>\n" "#import <RxLibrary/GRXWriter+Immediate.h>\n"; + for (int i = 0; i < file->dependency_count(); i++) { + ::grpc::string header = + grpc_objective_c_generator::MessageHeaderName(file->dependency(i)); + const grpc::protobuf::FileDescriptor *dependency = file->dependency(i); + if (IsProtobufLibraryBundledProtoFile(dependency)) { + ::grpc::string base_name = header; + grpc_generator::StripPrefix(&base_name, "google/protobuf/"); + // create the import code snippet + imports += + "#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS\n" + " #import <" + + ::grpc::string(ProtobufLibraryFrameworkName) + "/" + base_name + + ">\n" + "#else\n" + " #import \"" + + header + + "\"\n" + "#endif\n"; + } else { + imports += ::grpc::string("#import \"") + header + "\"\n"; + } + } ::grpc::string definitions; for (int i = 0; i < file->service_count(); i++) { diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index e29b39ac5a..59dd8fd2fe 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -58,7 +58,8 @@ typedef enum { PO_POLLSET, PO_FD, /* ordering is important: we always want to lock pollsets before fds: - this guarantees that using an fd as a pollable is safe */ PO_EMPTY_POLLABLE, + this guarantees that using an fd as a pollable is safe */ + PO_EMPTY_POLLABLE, PO_COUNT } polling_obj_type; diff --git a/src/core/lib/support/log_posix.cc b/src/core/lib/support/log_posix.cc index 38a136e646..29530c858f 100644 --- a/src/core/lib/support/log_posix.cc +++ b/src/core/lib/support/log_posix.cc @@ -58,7 +58,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, } extern "C" void gpr_default_log(gpr_log_func_args *args) { - char *final_slash; + const char *final_slash; const char *display_file; char time_buffer[64]; time_t timer; diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index 1796c6d746..ad83481595 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -47,7 +47,7 @@ Pod::Spec.new do |s| s.pod_target_xcconfig = { # This is needed by all pods that depend on Protobuf: - 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=1', # This is needed by all pods that depend on gRPC-RxLibrary: 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', } diff --git a/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb b/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb new file mode 100755 index 0000000000..3668b95a05 --- /dev/null +++ b/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby +# +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +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) + +GC.stress = 0x04 + +require 'grpc' + +GRPC::Core::Channel.new('dummy_host', nil, :this_channel_is_insecure) +GRPC::Core::Server.new({}) +GRPC::Core::ChannelCredentials.new +GRPC::Core::CallCredentials.new(proc { |noop| noop }) +GRPC::Core::CompressionOptions.new diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index 933a3ac152..b53f09edec 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -315,8 +315,8 @@ void Init_grpc_c() { return; } - bg_thread_init_rb_mu = rb_mutex_new(); rb_global_variable(&bg_thread_init_rb_mu); + bg_thread_init_rb_mu = rb_mutex_new(); grpc_rb_mGRPC = rb_define_module("GRPC"); grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core"); diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index 77191aa6d0..f3ac30c08d 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -119,6 +119,7 @@ # build. 'USE_HEADERMAP' => 'NO', 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"', } s.default_subspecs = 'Interface', 'Implementation' diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index e2531ef95a..f938aea40e 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -252,11 +252,8 @@ class TestScenario { bool disable_blocking; bool inproc; bool health_check_service; - // Although the below grpc::string's are logically const, we can't declare - // them const because of a limitation in the way old compilers (e.g., gcc-4.4) - // manage vector insertion using a copy constructor - grpc::string credentials_type; - grpc::string message_content; + const grpc::string credentials_type; + const grpc::string message_content; }; static std::ostream& operator<<(std::ostream& out, @@ -1784,7 +1781,7 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking, GPR_ASSERT(!credentials_types.empty()); messages.push_back("Hello"); - for (int sz = 1; sz < test_big_limit; sz *= 2) { + for (int sz = 1; sz <= test_big_limit; sz *= 32) { grpc::string big_msg; for (int i = 0; i < sz * 1024; i++) { char c = 'a' + (i % 26); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 5dae5b014b..810ee303f2 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -198,10 +198,7 @@ class TestScenario { void Log() const; bool use_proxy; bool inproc; - // Although the below grpc::string is logically const, we can't declare - // them const because of a limitation in the way old compilers (e.g., gcc-4.4) - // manage vector insertion using a copy constructor - grpc::string credentials_type; + const grpc::string credentials_type; }; static std::ostream& operator<<(std::ostream& out, diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 9cc5a8168b..c6d3600be8 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -257,6 +257,7 @@ int main(int argc, char** argv) { gpr_log(GPR_INFO, "Starting test(s).."); std::vector<std::thread> test_threads; + std::vector<std::unique_ptr<StressTestInteropClient>> clients; // Create and start the test threads. // Note that: @@ -282,9 +283,9 @@ int main(int argc, char** argv) { // Create stub(s) for each channel for (int stub_idx = 0; stub_idx < FLAGS_num_stubs_per_channel; stub_idx++) { - StressTestInteropClient* client = new StressTestInteropClient( + clients.emplace_back(new StressTestInteropClient( ++thread_idx, *it, channel, test_selector, FLAGS_test_duration_secs, - FLAGS_sleep_duration_ms, FLAGS_do_not_abort_on_transient_failures); + FLAGS_sleep_duration_ms, FLAGS_do_not_abort_on_transient_failures)); bool is_already_created = false; // QpsGauge name @@ -293,7 +294,7 @@ int main(int argc, char** argv) { server_idx, channel_idx, stub_idx); test_threads.emplace_back(std::thread( - &StressTestInteropClient::MainLoop, client, + &StressTestInteropClient::MainLoop, clients.back().get(), metrics_service.CreateQpsGauge(buffer, &is_already_created))); // The QpsGauge should not have been already created 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 7914b0e29a..5cfab14fee 100755 --- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh +++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh @@ -27,4 +27,5 @@ ruby src/ruby/end2end/killed_client_thread_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/forking_client_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/grpc_class_init_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/multiple_killed_watching_threads_driver.rb || EXIT_CODE=1 +ruby src/ruby/end2end/load_grpc_with_gc_stress_driver.rb || EXIT_CODE=1 exit $EXIT_CODE diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py index 82a3bc1435..d523095e70 100755 --- a/tools/run_tests/python_utils/jobset.py +++ b/tools/run_tests/python_utils/jobset.py @@ -306,8 +306,8 @@ class Job(object): else: self._state = _FAILURE if not self._suppress_failure_message: - message('FAILED', '%s [ret=%d, pid=%d]' % ( - self._spec.shortname, self._process.returncode, self._process.pid), + message('FAILED', '%s [ret=%d, pid=%d, time=%.1fsec]' % ( + self._spec.shortname, self._process.returncode, self._process.pid, elapsed), stdout(), do_newline=True) self.result.state = 'FAILED' self.result.num_failures += 1 @@ -326,7 +326,7 @@ class Job(object): self.result.cpu_estimated = float('%.01f' % self._spec.cpu_cost) measurement = '; cpu_cost=%.01f; estimated=%.01f' % (self.result.cpu_measured, self.result.cpu_estimated) if not self._quiet_success: - message('PASSED', '%s [time=%.1fsec; retries=%d:%d%s]' % ( + message('PASSED', '%s [time=%.1fsec, retries=%d:%d%s]' % ( self._spec.shortname, elapsed, self._retries, self._timeout_retries, measurement), stdout() if self._spec.verbose_success else None, do_newline=self._newline_on_success or self._travis) @@ -334,6 +334,8 @@ class Job(object): elif (self._state == _RUNNING and self._spec.timeout_seconds is not None and time.time() - self._start > self._spec.timeout_seconds): + elapsed = time.time() - self._start + self.result.elapsed_time = elapsed if self._timeout_retries < self._spec.timeout_retries: message('TIMEOUT_FLAKE', '%s [pid=%d]' % (self._spec.shortname, self._process.pid), stdout(), do_newline=True) self._timeout_retries += 1 @@ -344,7 +346,7 @@ class Job(object): self._process.terminate() self.start() else: - message('TIMEOUT', '%s [pid=%d]' % (self._spec.shortname, self._process.pid), stdout(), do_newline=True) + message('TIMEOUT', '%s [pid=%d, time=%.1fsec]' % (self._spec.shortname, self._process.pid, elapsed), stdout(), do_newline=True) self.kill() self.result.state = 'TIMEOUT' self.result.num_failures += 1 diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py index 580e7f7d81..15e827769e 100644 --- a/tools/run_tests/python_utils/upload_test_results.py +++ b/tools/run_tests/python_utils/upload_test_results.py @@ -102,6 +102,15 @@ def upload_results_to_bq(resultset, bq_table, args, platform): test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S') row = big_query_utils.make_row(str(uuid.uuid4()), test_results) - if not big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, bq_table, [row]): - print('Error uploading result to bigquery.') - sys.exit(1) + + # TODO(jtattermusch): rows are inserted one by one, very inefficient + max_retries = 3 + for attempt in range(max_retries): + if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, bq_table, [row]): + break + else: + if attempt < max_retries - 1: + print('Error uploading result to bigquery, will retry.') + else: + print('Error uploading result to bigquery, all attempts failed.') + sys.exit(1) |