From 7d9b6358b507aef4188739c46db1ad3f39a5bf98 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 28 Dec 2017 15:04:48 -0800 Subject: [PATCH 01/67] Initial commit Picks up work from https://github.com/grpc/grpc/pull/10259. A merge was impossible due to the many sweeping changed that have occured since I last touched that PR (c++-ization, exec_ctx, reorganitation of filters, etc). --- CMakeLists.txt | 39 +++ Makefile | 45 +++ build.yaml | 17 + config.m4 | 2 + config.w32 | 2 + gRPC-Core.podspec | 8 + grpc.gemspec | 4 + grpc.gyp | 7 + include/grpc/impl/codegen/grpc_types.h | 3 + package.xml | 4 + .../ext/filters/client_channel/subchannel.cc | 17 + .../ext/filters/client_channel/subchannel.h | 4 + src/core/lib/channel/channel_tracer.cc | 326 ++++++++++++++++++ src/core/lib/channel/channel_tracer.h | 78 +++++ src/core/lib/json/json.cc | 36 ++ src/core/lib/json/json.h | 21 +- src/core/lib/support/object_registry.cc | 100 ++++++ src/core/lib/support/object_registry.h | 39 +++ src/core/lib/surface/channel.cc | 33 +- src/core/lib/surface/channel.h | 3 + src/core/lib/surface/init.cc | 3 + src/python/grpcio/grpc_core_dependencies.py | 2 + test/core/channel/channel_tracer_test.cc | 210 +++++++++++ test/core/util/channel_tracing_utils.cc | 60 ++++ test/core/util/channel_tracing_utils.h | 30 ++ tools/doxygen/Doxyfile.c++.internal | 2 + tools/doxygen/Doxyfile.core.internal | 4 + .../generated/sources_and_headers.json | 26 ++ tools/run_tests/generated/tests.json | 24 ++ 29 files changed, 1146 insertions(+), 3 deletions(-) create mode 100644 src/core/lib/channel/channel_tracer.cc create mode 100644 src/core/lib/channel/channel_tracer.h create mode 100644 src/core/lib/support/object_registry.cc create mode 100644 src/core/lib/support/object_registry.h create mode 100644 test/core/channel/channel_tracer_test.cc create mode 100644 test/core/util/channel_tracing_utils.cc create mode 100644 test/core/util/channel_tracing_utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eff902f6b0..c819a09e60d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,6 +274,7 @@ add_dependencies(buildtests_c grpc_byte_buffer_reader_test) add_dependencies(buildtests_c grpc_channel_args_test) add_dependencies(buildtests_c grpc_channel_stack_builder_test) add_dependencies(buildtests_c grpc_channel_stack_test) +add_dependencies(buildtests_c grpc_channel_tracer_test) add_dependencies(buildtests_c grpc_completion_queue_test) add_dependencies(buildtests_c grpc_completion_queue_threading_test) add_dependencies(buildtests_c grpc_credentials_test) @@ -639,6 +640,7 @@ add_library(gpr src/core/lib/support/log_windows.cc src/core/lib/support/mpscq.cc src/core/lib/support/murmur_hash.cc + src/core/lib/support/object_registry.cc src/core/lib/support/string.cc src/core/lib/support/string_posix.cc src/core/lib/support/string_util_windows.cc @@ -793,6 +795,7 @@ add_library(grpc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_tracer.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1136,6 +1139,7 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_tracer.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1445,6 +1449,7 @@ add_library(grpc_test_util test/core/end2end/fixtures/http_proxy_fixture.cc test/core/end2end/fixtures/proxy.cc test/core/iomgr/endpoint_tests.cc + test/core/util/channel_tracing_utils.cc test/core/util/debugger_macros.cc test/core/util/grpc_profiler.cc test/core/util/histogram.cc @@ -1462,6 +1467,7 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_tracer.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1715,6 +1721,7 @@ add_library(grpc_test_util_unsecure test/core/end2end/fixtures/http_proxy_fixture.cc test/core/end2end/fixtures/proxy.cc test/core/iomgr/endpoint_tests.cc + test/core/util/channel_tracing_utils.cc test/core/util/debugger_macros.cc test/core/util/grpc_profiler.cc test/core/util/histogram.cc @@ -1732,6 +1739,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_tracer.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1985,6 +1993,7 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_tracer.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2735,6 +2744,7 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc + src/core/lib/channel/channel_tracer.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -6348,6 +6358,35 @@ target_link_libraries(grpc_channel_stack_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(grpc_channel_tracer_test + test/core/channel/channel_tracer_test.cc +) + + +target_include_directories(grpc_channel_tracer_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${BENCHMARK_ROOT_DIR}/include + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib + PRIVATE ${CARES_INCLUDE_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include +) + +target_link_libraries(grpc_channel_tracer_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr_test_util + gpr +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(grpc_completion_queue_test test/core/surface/completion_queue_test.cc ) diff --git a/Makefile b/Makefile index e51882c3640..d12e3ade3e0 100644 --- a/Makefile +++ b/Makefile @@ -1001,6 +1001,7 @@ grpc_byte_buffer_reader_test: $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test grpc_channel_args_test: $(BINDIR)/$(CONFIG)/grpc_channel_args_test grpc_channel_stack_builder_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test grpc_channel_stack_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_test +grpc_channel_tracer_test: $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test grpc_completion_queue_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_test grpc_completion_queue_threading_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt @@ -1400,6 +1401,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/grpc_channel_args_test \ $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test \ $(BINDIR)/$(CONFIG)/grpc_channel_stack_test \ + $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \ $(BINDIR)/$(CONFIG)/grpc_credentials_test \ @@ -1865,6 +1867,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test || ( echo test grpc_channel_stack_builder_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_channel_stack_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_stack_test || ( echo test grpc_channel_stack_test failed ; exit 1 ) + $(E) "[RUN] Testing grpc_channel_tracer_test" + $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test || ( echo test grpc_channel_tracer_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_completion_queue_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_test || ( echo test grpc_completion_queue_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_completion_queue_threading_test" @@ -2843,6 +2847,7 @@ LIBGPR_SRC = \ src/core/lib/support/log_windows.cc \ src/core/lib/support/mpscq.cc \ src/core/lib/support/murmur_hash.cc \ + src/core/lib/support/object_registry.cc \ src/core/lib/support/string.cc \ src/core/lib/support/string_posix.cc \ src/core/lib/support/string_util_windows.cc \ @@ -2974,6 +2979,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_tracer.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3317,6 +3323,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_tracer.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3625,6 +3632,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/end2end/fixtures/http_proxy_fixture.cc \ test/core/end2end/fixtures/proxy.cc \ test/core/iomgr/endpoint_tests.cc \ + test/core/util/channel_tracing_utils.cc \ test/core/util/debugger_macros.cc \ test/core/util/grpc_profiler.cc \ test/core/util/histogram.cc \ @@ -3642,6 +3650,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_tracer.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3886,6 +3895,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/end2end/fixtures/http_proxy_fixture.cc \ test/core/end2end/fixtures/proxy.cc \ test/core/iomgr/endpoint_tests.cc \ + test/core/util/channel_tracing_utils.cc \ test/core/util/debugger_macros.cc \ test/core/util/grpc_profiler.cc \ test/core/util/histogram.cc \ @@ -3903,6 +3913,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_tracer.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4134,6 +4145,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_tracer.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4867,6 +4879,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_tracer.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -10516,6 +10529,38 @@ endif endif +GRPC_CHANNEL_TRACER_TEST_SRC = \ + test/core/channel/channel_tracer_test.cc \ + +GRPC_CHANNEL_TRACER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CHANNEL_TRACER_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/grpc_channel_tracer_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/grpc_channel_tracer_test: $(GRPC_CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_tracer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_grpc_channel_tracer_test: $(GRPC_CHANNEL_TRACER_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GRPC_CHANNEL_TRACER_TEST_OBJS:.o=.dep) +endif +endif + + GRPC_COMPLETION_QUEUE_TEST_SRC = \ test/core/surface/completion_queue_test.cc \ diff --git a/build.yaml b/build.yaml index 42d72459811..67513d84453 100644 --- a/build.yaml +++ b/build.yaml @@ -49,6 +49,7 @@ filegroups: - src/core/lib/support/log_windows.cc - src/core/lib/support/mpscq.cc - src/core/lib/support/murmur_hash.cc + - src/core/lib/support/object_registry.cc - src/core/lib/support/string.cc - src/core/lib/support/string_posix.cc - src/core/lib/support/string_util_windows.cc @@ -113,6 +114,7 @@ filegroups: - src/core/lib/support/memory.h - src/core/lib/support/mpscq.h - src/core/lib/support/murmur_hash.h + - src/core/lib/support/object_registry.h - src/core/lib/support/spinlock.h - src/core/lib/support/string.h - src/core/lib/support/string_windows.h @@ -154,6 +156,7 @@ filegroups: - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc + - src/core/lib/channel/channel_tracer.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc @@ -309,6 +312,7 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h + - src/core/lib/channel/channel_tracer.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h @@ -710,6 +714,7 @@ filegroups: - test/core/end2end/fixtures/http_proxy_fixture.h - test/core/end2end/fixtures/proxy.h - test/core/iomgr/endpoint_tests.h + - test/core/util/channel_tracing_utils.h - test/core/util/debugger_macros.h - test/core/util/grpc_profiler.h - test/core/util/histogram.h @@ -728,6 +733,7 @@ filegroups: - test/core/end2end/fixtures/http_proxy_fixture.cc - test/core/end2end/fixtures/proxy.cc - test/core/iomgr/endpoint_tests.cc + - test/core/util/channel_tracing_utils.cc - test/core/util/debugger_macros.cc - test/core/util/grpc_profiler.cc - test/core/util/histogram.cc @@ -2333,6 +2339,17 @@ targets: - gpr_test_util - gpr uses_polling: false +- name: grpc_channel_tracer_test + build: test + language: c + src: + - test/core/channel/channel_tracer_test.cc + deps: + - grpc_test_util + - grpc + - gpr_test_util + - gpr + uses_polling: false - name: grpc_completion_queue_test build: test language: c diff --git a/config.m4 b/config.m4 index c026b83f359..e0de29807d2 100644 --- a/config.m4 +++ b/config.m4 @@ -62,6 +62,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/support/log_windows.cc \ src/core/lib/support/mpscq.cc \ src/core/lib/support/murmur_hash.cc \ + src/core/lib/support/object_registry.cc \ src/core/lib/support/string.cc \ src/core/lib/support/string_posix.cc \ src/core/lib/support/string_util_windows.cc \ @@ -88,6 +89,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ + src/core/lib/channel/channel_tracer.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ diff --git a/config.w32 b/config.w32 index cd3a16a4653..8815331c6ad 100644 --- a/config.w32 +++ b/config.w32 @@ -39,6 +39,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\support\\log_windows.cc " + "src\\core\\lib\\support\\mpscq.cc " + "src\\core\\lib\\support\\murmur_hash.cc " + + "src\\core\\lib\\support\\object_registry.cc " + "src\\core\\lib\\support\\string.cc " + "src\\core\\lib\\support\\string_posix.cc " + "src\\core\\lib\\support\\string_util_windows.cc " + @@ -65,6 +66,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + + "src\\core\\lib\\channel\\channel_tracer.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 708c3436abd..1cae08d0882 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -205,6 +205,7 @@ Pod::Spec.new do |s| 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', 'src/core/lib/support/murmur_hash.h', + 'src/core/lib/support/object_registry.h', 'src/core/lib/support/spinlock.h', 'src/core/lib/support/string.h', 'src/core/lib/support/string_windows.h', @@ -234,6 +235,7 @@ Pod::Spec.new do |s| 'src/core/lib/support/log_windows.cc', 'src/core/lib/support/mpscq.cc', 'src/core/lib/support/murmur_hash.cc', + 'src/core/lib/support/object_registry.cc', 'src/core/lib/support/string.cc', 'src/core/lib/support/string_posix.cc', 'src/core/lib/support/string_util_windows.cc', @@ -333,6 +335,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_tracer.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -473,6 +476,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_tracer.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -729,6 +733,7 @@ Pod::Spec.new do |s| 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', 'src/core/lib/support/murmur_hash.h', + 'src/core/lib/support/object_registry.h', 'src/core/lib/support/spinlock.h', 'src/core/lib/support/string.h', 'src/core/lib/support/string_windows.h', @@ -813,6 +818,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_tracer.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -985,6 +991,7 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', + 'test/core/util/channel_tracing_utils.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -1004,6 +1011,7 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.h', 'test/core/end2end/fixtures/proxy.h', 'test/core/iomgr/endpoint_tests.h', + 'test/core/util/channel_tracing_utils.h', 'test/core/util/debugger_macros.h', 'test/core/util/grpc_profiler.h', 'test/core/util/histogram.h', diff --git a/grpc.gemspec b/grpc.gemspec index d1859952619..ea11b6a94c8 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -95,6 +95,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/memory.h ) s.files += %w( src/core/lib/support/mpscq.h ) s.files += %w( src/core/lib/support/murmur_hash.h ) + s.files += %w( src/core/lib/support/object_registry.h ) s.files += %w( src/core/lib/support/spinlock.h ) s.files += %w( src/core/lib/support/string.h ) s.files += %w( src/core/lib/support/string_windows.h ) @@ -124,6 +125,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/log_windows.cc ) s.files += %w( src/core/lib/support/mpscq.cc ) s.files += %w( src/core/lib/support/murmur_hash.cc ) + s.files += %w( src/core/lib/support/object_registry.cc ) s.files += %w( src/core/lib/support/string.cc ) s.files += %w( src/core/lib/support/string_posix.cc ) s.files += %w( src/core/lib/support/string_util_windows.cc ) @@ -259,6 +261,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) + s.files += %w( src/core/lib/channel/channel_tracer.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) @@ -403,6 +406,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) + s.files += %w( src/core/lib/channel/channel_tracer.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) diff --git a/grpc.gyp b/grpc.gyp index c34206b1a5d..8f7ba225512 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -181,6 +181,7 @@ 'src/core/lib/support/log_windows.cc', 'src/core/lib/support/mpscq.cc', 'src/core/lib/support/murmur_hash.cc', + 'src/core/lib/support/object_registry.cc', 'src/core/lib/support/string.cc', 'src/core/lib/support/string_posix.cc', 'src/core/lib/support/string_util_windows.cc', @@ -226,6 +227,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_tracer.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -503,6 +505,7 @@ 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', + 'test/core/util/channel_tracing_utils.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -520,6 +523,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_tracer.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -715,6 +719,7 @@ 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', + 'test/core/util/channel_tracing_utils.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -732,6 +737,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_tracer.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -926,6 +932,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_tracer.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index fcbc8ac5a1e..b4cbff8649b 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -274,6 +274,9 @@ typedef struct { #define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" /** The grpc_socket_factory instance to create and bind sockets. A pointer. */ #define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" +/** The maximum number of trace nodes to keep in the tracer for each channel or + * subchannel. The default is 10. If set to 0, channel tracing is disabled. */ +#define GRPC_ARG_CHANNEL_TRACING_MAX_NODES "grpc.channel_tracing_max_nodes" /** If non-zero, Cronet transport will coalesce packets to fewer frames * when possible. */ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ diff --git a/package.xml b/package.xml index b4d8c886930..5f70dbc3fab 100644 --- a/package.xml +++ b/package.xml @@ -107,6 +107,7 @@ + @@ -136,6 +137,7 @@ + @@ -271,6 +273,7 @@ + @@ -415,6 +418,7 @@ + diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index f07394d29b2..8b8e468f16f 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -35,6 +35,7 @@ #include "src/core/ext/filters/client_channel/uri_parser.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channel_tracer.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/sockaddr_utils.h" @@ -42,6 +43,7 @@ #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/manual_constructor.h" +#include "src/core/lib/support/object_registry.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel_init.h" #include "src/core/lib/transport/connectivity_state.h" @@ -75,6 +77,7 @@ typedef struct external_state_watcher { } external_state_watcher; struct grpc_subchannel { + intptr_t uuid; grpc_connector* connector; /** refcount @@ -131,6 +134,8 @@ struct grpc_subchannel { bool backoff_begun; /** our alarm */ grpc_timer alarm; + + grpc_channel_tracer* tracer; }; struct grpc_subchannel_call { @@ -183,6 +188,7 @@ void grpc_connected_subchannel_unref( static void subchannel_destroy(void* arg, grpc_error* error) { grpc_subchannel* c = (grpc_subchannel*)arg; + grpc_object_registry_unregister_object(c->uuid); gpr_free((void*)c->filters); grpc_channel_args_destroy(c->args); grpc_connectivity_state_destroy(&c->state_tracker); @@ -337,6 +343,8 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(); c = (grpc_subchannel*)gpr_zalloc(sizeof(*c)); + c->uuid = + grpc_object_registry_register_object(c, GPRC_OBJECT_REGISTRY_SUBCHANNEL); c->key = key; gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS); c->connector = connector; @@ -385,6 +393,15 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, return grpc_subchannel_index_register(key, c); } +char* grpc_subchannel_get_trace(grpc_subchannel* subchannel, bool recursive) { + return subchannel->tracer != NULL + ? grpc_channel_tracer_render_trace(subchannel->tracer, recursive) + : NULL; +} +intptr_t grpc_subchannel_get_uuid(grpc_subchannel* subchannel) { + return subchannel->uuid; +} + static void continue_connect_locked(grpc_subchannel* c) { grpc_connect_in_args args; args.interested_parties = c->pollset_set; diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 9d34fff07a8..3584d3928a1 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -165,6 +165,10 @@ struct grpc_subchannel_args { grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, const grpc_subchannel_args* args); +/// retrieves the trace for this subchannel in JSON form. +char* grpc_subchannel_get_trace(grpc_subchannel* subchannel, bool recursive); +intptr_t grpc_subchannel_get_uuid(grpc_subchannel* subchannel); + /// Sets \a addr from \a args. void grpc_get_subchannel_address_arg(const grpc_channel_args* args, grpc_resolved_address* addr); diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc new file mode 100644 index 00000000000..0d77f33c7f2 --- /dev/null +++ b/src/core/lib/channel/channel_tracer.cc @@ -0,0 +1,326 @@ +/* + * + * Copyright 2017 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. + * + */ + +#include "src/core/lib/channel/channel_tracer.h" +#include +#include +#include +#include +#include +#include +#include + +#include "src/core/ext/filters/client_channel/subchannel.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/object_registry.h" +#include "src/core/lib/support/string.h" +#include "src/core/lib/surface/channel.h" +#include "src/core/lib/transport/connectivity_state.h" + +// One node of tracing data +typedef struct grpc_trace_node { + grpc_slice data; + grpc_error* error; + gpr_timespec time_created; + grpc_connectivity_state connectivity_state; + struct grpc_trace_node* next; + + // the tracer object for the (sub)channel that this trace node refers to. + grpc_channel_tracer* referenced_tracer; +} grpc_trace_node; + +/* the channel tracing object */ +struct grpc_channel_tracer { + gpr_refcount refs; + gpr_mu tracer_mu; + intptr_t channel_uuid; + uint64_t num_nodes_logged; + size_t list_size; + size_t max_list_size; + grpc_trace_node* head_trace; + grpc_trace_node* tail_trace; + gpr_timespec time_created; +}; + +#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, + const char* file, int line, + const char* func) { +#else +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, + intptr_t uuid) { +#endif + grpc_channel_tracer* tracer = static_cast( + gpr_zalloc(sizeof(grpc_channel_tracer))); + gpr_mu_init(&tracer->tracer_mu); + gpr_ref_init(&tracer->refs, 1); +#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG + gpr_log(GPR_DEBUG, "%p create [%s:%d %s]", tracer, file, line, func); +#endif + tracer->channel_uuid = uuid; + tracer->max_list_size = max_nodes; + tracer->time_created = gpr_now(GPR_CLOCK_REALTIME); + return tracer; +} + +#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, + const char* file, int line, + const char* func) { + if (!tracer) return tracer; + gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, + gpr_atm_no_barrier_load(&tracer->refs.count), + gpr_atm_no_barrier_load(&tracer->refs.count) + 1, file, line, func); + gpr_ref(&tracer->refs); + return tracer; +} +#else +grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer) { + if (!tracer) return tracer; + gpr_ref(&tracer->refs); + return tracer; +} +#endif + +static void free_node(grpc_trace_node* node) { + GRPC_ERROR_UNREF(node->error); + GRPC_CHANNEL_TRACER_UNREF(node->referenced_tracer); + grpc_slice_unref_internal(node->data); + gpr_free(node); +} + +static void grpc_channel_tracer_destroy(grpc_channel_tracer* tracer) { + grpc_trace_node* it = tracer->head_trace; + while (it != NULL) { + grpc_trace_node* to_free = it; + it = it->next; + free_node(to_free); + } + gpr_mu_destroy(&tracer->tracer_mu); + gpr_free(tracer); +} + +#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +void grpc_channel_tracer_unref(grpc_channel_tracer* tracer, const char* file, + int line, const char* func) { + if (!tracer) return; + gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, + gpr_atm_no_barrier_load(&tracer->refs.count), + gpr_atm_no_barrier_load(&tracer->refs.count) - 1, file, line, func); + if (gpr_unref(&tracer->refs)) { + grpc_channel_tracer_destroy(tracer); + } +} +#else +void grpc_channel_tracer_unref(grpc_channel_tracer* tracer) { + if (!tracer) return; + if (gpr_unref(&tracer->refs)) { + grpc_channel_tracer_destroy(tracer); + } +} +#endif + +void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, + grpc_error* error, + grpc_connectivity_state connectivity_state, + grpc_channel_tracer* referenced_tracer) { + if (!tracer) return; + ++tracer->num_nodes_logged; + // create and fill up the new node + grpc_trace_node* new_trace_node = + static_cast(gpr_malloc(sizeof(grpc_trace_node))); + new_trace_node->data = data; + new_trace_node->error = error; + new_trace_node->time_created = gpr_now(GPR_CLOCK_REALTIME); + new_trace_node->connectivity_state = connectivity_state; + new_trace_node->next = NULL; + new_trace_node->referenced_tracer = + GRPC_CHANNEL_TRACER_REF(referenced_tracer); + // first node case + if (tracer->head_trace == NULL) { + tracer->head_trace = tracer->tail_trace = new_trace_node; + } + // regular node add case + else { + tracer->tail_trace->next = new_trace_node; + tracer->tail_trace = tracer->tail_trace->next; + } + ++tracer->list_size; + // maybe garbage collect the end + if (tracer->list_size > tracer->max_list_size) { + grpc_trace_node* to_free = tracer->head_trace; + tracer->head_trace = tracer->head_trace->next; + free_node(to_free); + --tracer->list_size; + } +} + +// returns an allocated string that represents tm according to RFC-3339. +static char* fmt_time(gpr_timespec tm) { + char buffer[35]; + struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); + strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", tm_info); + char* full_time_str; + gpr_asprintf(&full_time_str, "%s.%09dZ", buffer, tm.tv_nsec); + return full_time_str; +} + +typedef struct seen_tracers { + grpc_channel_tracer** tracers; + size_t size; + size_t cap; +} seen_tracers; + +static void seen_tracers_add(seen_tracers* tracker, + grpc_channel_tracer* tracer) { + if (tracker->size >= tracker->cap) { + tracker->cap = GPR_MAX(5 * sizeof(tracer), 3 * tracker->cap / 2); + tracker->tracers = + (grpc_channel_tracer**)gpr_realloc(tracker->tracers, tracker->cap); + } + tracker->tracers[tracker->size++] = tracer; +} + +static bool seen_tracers_check(seen_tracers* tracker, + grpc_channel_tracer* tracer) { + for (size_t i = 0; i < tracker->size; ++i) { + if (tracker->tracers[i] == tracer) return true; + } + return false; +} + +static void recursively_populate_json(grpc_channel_tracer* tracer, + seen_tracers* tracker, grpc_json* json, + bool recursive); + +static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, + grpc_json* json, grpc_json* children) { + grpc_json* child = NULL; + child = grpc_json_create_child(child, json, "data", + grpc_slice_to_c_string(node->data), + GRPC_JSON_STRING, true); + if (node->error != GRPC_ERROR_NONE) { + child = grpc_json_create_child(child, json, "error", + gpr_strdup(grpc_error_string(node->error)), + GRPC_JSON_STRING, true); + } + child = + grpc_json_create_child(child, json, "time", fmt_time(node->time_created), + GRPC_JSON_STRING, true); + child = grpc_json_create_child( + child, json, "state", + grpc_connectivity_state_name(node->connectivity_state), GRPC_JSON_STRING, + false); + if (node->referenced_tracer != NULL) { + char* uuid_str; + gpr_asprintf(&uuid_str, "%ld", node->referenced_tracer->channel_uuid); + child = grpc_json_create_child(child, json, "uuid", uuid_str, + GRPC_JSON_NUMBER, true); + if (children && !seen_tracers_check(tracker, node->referenced_tracer)) { + grpc_json* referenced_tracer = grpc_json_create_child( + NULL, children, NULL, NULL, GRPC_JSON_OBJECT, false); + recursively_populate_json(node->referenced_tracer, tracker, + referenced_tracer, true); + } + } +} + +static void populate_node_list_data(grpc_channel_tracer* tracer, + seen_tracers* tracker, grpc_json* nodes, + grpc_json* children) { + grpc_json* child = NULL; + grpc_trace_node* it = tracer->head_trace; + while (it != NULL) { + child = grpc_json_create_child(child, nodes, NULL, NULL, GRPC_JSON_OBJECT, + false); + populate_node_data(it, tracker, child, children); + it = it->next; + } +} + +static void populate_tracer_data(grpc_channel_tracer* tracer, + seen_tracers* tracker, grpc_json* channel_data, + grpc_json* children) { + grpc_json* child = NULL; + + char* uuid_str; + gpr_asprintf(&uuid_str, "%ld", tracer->channel_uuid); + child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, + GRPC_JSON_NUMBER, true); + char* num_nodes_logged_str; + gpr_asprintf(&num_nodes_logged_str, "%" PRId64, tracer->num_nodes_logged); + child = grpc_json_create_child(child, channel_data, "numNodesLogged", + num_nodes_logged_str, GRPC_JSON_NUMBER, true); + child = grpc_json_create_child(child, channel_data, "startTime", + fmt_time(tracer->time_created), + GRPC_JSON_STRING, true); + child = grpc_json_create_child(child, channel_data, "nodes", NULL, + GRPC_JSON_ARRAY, false); + populate_node_list_data(tracer, tracker, child, children); +} + +static void recursively_populate_json(grpc_channel_tracer* tracer, + seen_tracers* tracker, grpc_json* json, + bool recursive) { + grpc_json* channel_data = grpc_json_create_child( + NULL, json, "channelData", NULL, GRPC_JSON_OBJECT, false); + grpc_json* children = NULL; + if (recursive) { + children = grpc_json_create_child(channel_data, json, "children", NULL, + GRPC_JSON_ARRAY, false); + } + seen_tracers_add(tracker, tracer); + populate_tracer_data(tracer, tracker, channel_data, children); +} + +char* grpc_channel_tracer_render_trace(grpc_channel_tracer* tracer, + bool recursive) { + grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); + + seen_tracers tracker; + memset(&tracker, 0, sizeof(tracker)); + + recursively_populate_json(tracer, &tracker, json, recursive); + + gpr_free(tracker.tracers); + + char* json_str = grpc_json_dump_to_string(json, 1); + grpc_json_destroy(json); + return json_str; +} + +char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive) { + void* object; + grpc_object_registry_type type = + grpc_object_registry_get_object(uuid, &object); + GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL || + type == GPRC_OBJECT_REGISTRY_SUBCHANNEL); + switch (type) { + case GRPC_OBJECT_REGISTRY_CHANNEL: + return grpc_channel_get_trace(static_cast(object), + recursive); + break; + case GPRC_OBJECT_REGISTRY_SUBCHANNEL: + return grpc_subchannel_get_trace(static_cast(object), + recursive); + break; + default: + abort(); + } +} diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h new file mode 100644 index 00000000000..1f151ba8991 --- /dev/null +++ b/src/core/lib/channel/channel_tracer.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2017 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. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H + +#include +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/json/json.h" + +/* Forward declaration */ +typedef struct grpc_channel_tracer grpc_channel_tracer; + +// #define GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG + +/* Creates a new tracer. The caller owns a reference to the returned tracer. */ +#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, + const char* file, int line, + const char* func); +#define GRPC_CHANNEL_TRACER_CREATE(max_nodes, id) \ + grpc_channel_tracer_create(max_nodes, id, __FILE__, __LINE__, __func__) +#else +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, + intptr_t uuid); +#define GRPC_CHANNEL_TRACER_CREATE(max_nodes, id) \ + grpc_channel_tracer_create(max_nodes, id) +#endif + +#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, + const char* file, int line, + const char* func); +void grpc_channel_tracer_unref(grpc_channel_tracer* tracer, const char* file, + int line, const char* func); +#define GRPC_CHANNEL_TRACER_REF(tracer) \ + grpc_channel_tracer_ref(tracer, __FILE__, __LINE__, __func__) +#define GRPC_CHANNEL_TRACER_UNREF(tracer) \ + grpc_channel_tracer_unref(tracer, __FILE__, __LINE__, __func__) +#else +grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer); +void grpc_channel_tracer_unref(grpc_channel_tracer* tracer); +#define GRPC_CHANNEL_TRACER_REF(tracer) grpc_channel_tracer_ref(tracer) +#define GRPC_CHANNEL_TRACER_UNREF(tracer) grpc_channel_tracer_unref(tracer) +#endif + +/* Adds a new trace node to the tracing object */ +void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, + grpc_error* error, + grpc_connectivity_state connectivity_state, + grpc_channel_tracer* subchannel); + +/* Returns the tracing data rendered as a grpc json string. + The string is owned by the caller and must be freed. If recursive + is true, then the string will include the recursive trace for all + subtracing objects. */ +char* grpc_channel_tracer_render_trace(grpc_channel_tracer* tracer, + bool recursive); +/* util functions that perform the uuid -> tracer step for you, and then + returns the trace for the uuid given. */ +char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive); + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H */ diff --git a/src/core/lib/json/json.cc b/src/core/lib/json/json.cc index 4ad51f662a7..2171e694555 100644 --- a/src/core/lib/json/json.cc +++ b/src/core/lib/json/json.cc @@ -19,6 +19,7 @@ #include #include +#include #include "src/core/lib/json/json.h" @@ -44,5 +45,40 @@ void grpc_json_destroy(grpc_json* json) { json->parent->child = json->next; } + if (json->owns_value) { + gpr_free((void*)json->value); + } + gpr_free(json); } + +grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, + grpc_json* sibling) { + // first child case. + if (parent->child == NULL) { + GPR_ASSERT(sibling == NULL); + parent->child = child; + return child; + } + if (sibling == NULL) { + sibling = parent->child; + } + // always find the right most sibling. + while (sibling->next != NULL) { + sibling = sibling->next; + } + sibling->next = child; + return child; +} + +grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent, + const char* key, const char* value, + grpc_json_type type, bool owns_value) { + grpc_json* child = grpc_json_create(type); + grpc_json_link_child(parent, child, sibling); + child->owns_value = owns_value; + child->parent = parent; + child->value = value; + child->key = key; + return child; +} diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index bbd43025eb8..d88a79271fd 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -19,6 +19,7 @@ #ifndef GRPC_CORE_LIB_JSON_JSON_H #define GRPC_CORE_LIB_JSON_JSON_H +#include #include #include "src/core/lib/json/json_common.h" @@ -35,6 +36,9 @@ typedef struct grpc_json { grpc_json_type type; const char* key; const char* value; + + /* if set, destructor will free value */ + bool owns_value; } grpc_json; /* The next two functions are going to parse the input string, and @@ -65,9 +69,24 @@ char* grpc_json_dump_to_string(grpc_json* json, int indent); /* Use these to create or delete a grpc_json object. * Deletion is recursive. We will not attempt to free any of the strings - * in any of the objects of that tree. + * in any of the objects of that tree, unless the boolean, owns_value, + * is true. */ grpc_json* grpc_json_create(grpc_json_type type); void grpc_json_destroy(grpc_json* json); +/* Links the child json object into the parent's json tree. If the parent + * already has children, then passing in the most recently added child as the + * sibling parameter is an optimization. For if sibling is NULL, this function + * will manually traverse the tree in order to find the right most sibling. + */ +grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, + grpc_json* sibling); + +/* Creates a child json object into the parent's json tree then links it in + * as described above. */ +grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent, + const char* key, const char* value, + grpc_json_type type, bool owns_value); + #endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/src/core/lib/support/object_registry.cc b/src/core/lib/support/object_registry.cc new file mode 100644 index 00000000000..596711804fa --- /dev/null +++ b/src/core/lib/support/object_registry.cc @@ -0,0 +1,100 @@ +/* + * + * Copyright 2017 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. + * + */ + +#include "src/core/lib/support/object_registry.h" + +#include +#include +#include + +// file global lock and avl. +static gpr_mu g_mu; +static gpr_avl g_avl; +static intptr_t g_uuid = 0; + +typedef struct { + void* object; + grpc_object_registry_type type; +} object_tracker; + +// avl vtable for uuid (intptr_t) -> object_tracker +// this table is only looking, it does not own anything. +static void destroy_intptr(void* not_used, void* user_data) {} +static void* copy_intptr(void* key, void* user_data) { return key; } +static long compare_intptr(void* key1, void* key2, void* user_data) { + return key1 > key2; +} + +static void destroy_tracker(void* tracker, void* user_data) { + gpr_free((object_tracker*)tracker); +} + +static void* copy_tracker(void* value, void* user_data) { + object_tracker* old = static_cast(value); + object_tracker* new_obj = + static_cast(gpr_malloc(sizeof(object_tracker))); + new_obj->object = old->object; + new_obj->type = old->type; + return new_obj; +} +static const gpr_avl_vtable avl_vtable = { + destroy_intptr, copy_intptr, compare_intptr, destroy_tracker, copy_tracker}; + +void grpc_object_registry_init() { + gpr_mu_init(&g_mu); + g_avl = gpr_avl_create(&avl_vtable); +} + +void grpc_object_registry_shutdown() { + gpr_avl_unref(g_avl, nullptr); + gpr_mu_destroy(&g_mu); +} + +intptr_t grpc_object_registry_register_object(void* object, + grpc_object_registry_type type) { + object_tracker* tracker = + static_cast(gpr_malloc(sizeof(object_tracker))); + tracker->object = object; + tracker->type = type; + intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); + gpr_mu_lock(&g_mu); + g_avl = gpr_avl_add(g_avl, (void*)prior, tracker, NULL); + gpr_mu_unlock(&g_mu); + return prior; +} + +void grpc_object_registry_unregister_object(intptr_t uuid) { + gpr_mu_lock(&g_mu); + g_avl = gpr_avl_remove(g_avl, (void*)uuid, nullptr); + gpr_mu_unlock(&g_mu); +} + +grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, + void** object) { + GPR_ASSERT(object); + gpr_mu_lock(&g_mu); + object_tracker* tracker = + static_cast(gpr_avl_get(g_avl, (void*)uuid, nullptr)); + gpr_mu_unlock(&g_mu); + if (tracker == NULL) { + *object = NULL; + return GRPC_OBJECT_REGISTRY_UNKNOWN; + } + *object = tracker->object; + return tracker->type; +} diff --git a/src/core/lib/support/object_registry.h b/src/core/lib/support/object_registry.h new file mode 100644 index 00000000000..3a0d056e2ad --- /dev/null +++ b/src/core/lib/support/object_registry.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2017 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. + * + */ + +#ifndef GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H +#define GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H + +#include + +typedef enum { + GRPC_OBJECT_REGISTRY_CHANNEL, + GPRC_OBJECT_REGISTRY_SUBCHANNEL, + GRPC_OBJECT_REGISTRY_UNKNOWN, +} grpc_object_registry_type; + +void grpc_object_registry_init(); +void grpc_object_registry_shutdown(); + +intptr_t grpc_object_registry_register_object(void* object, + grpc_object_registry_type type); +void grpc_object_registry_unregister_object(intptr_t uuid); +grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, + void** object); + +#endif /* GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index cf5e8c2150d..e94413e3bcb 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -28,9 +28,11 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channel_tracer.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/call.h" @@ -51,6 +53,7 @@ typedef struct registered_call { } registered_call; struct grpc_channel { + intptr_t uuid; int is_client; grpc_compression_options compression_options; grpc_mdelem default_authority; @@ -60,6 +63,8 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; + grpc_channel_tracer* tracer; + char* target; }; @@ -91,12 +96,16 @@ grpc_channel* grpc_channel_create_with_builder( grpc_error_string(error)); GRPC_ERROR_UNREF(error); gpr_free(target); - goto done; + grpc_channel_args_destroy(args); + return channel; } memset(channel, 0, sizeof(*channel)); + channel->uuid = grpc_object_registry_register_object( + channel, GRPC_OBJECT_REGISTRY_CHANNEL); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); + channel->tracer = NULL; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -186,14 +195,34 @@ grpc_channel* grpc_channel_create_with_builder( .enabled_stream_compression_algorithms_bitset = (uint32_t)args->args[i].value.integer | 0x1; /* always support no compression */ + } else if (0 == + strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { + GPR_ASSERT(channel->tracer == NULL); + // max_nodes defaults to 10, clamped between 0 and 100. + const grpc_integer_options options = {10, 0, 100}; + size_t max_nodes = + (size_t)grpc_channel_arg_get_integer(&args->args[i], options); + if (max_nodes > 0) { + channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, channel->uuid); + } } } -done: grpc_channel_args_destroy(args); + grpc_channel_tracer_add_trace( + channel->tracer, grpc_slice_from_static_string("Channel created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, NULL); return channel; } +char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { + return channel->tracer + ? grpc_channel_tracer_render_trace(channel->tracer, recursive) + : NULL; +} + +intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 26d8fceb2f8..507013f4529 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -58,6 +58,9 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); +char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); +intptr_t grpc_channel_get_uuid(grpc_channel* channel); + #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); void grpc_channel_internal_unref(grpc_channel* channel, const char* reason); diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 0f40965f16c..a33b6de8b7e 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -41,6 +41,7 @@ #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/fork.h" +#include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/thd_internal.h" #include "src/core/lib/surface/alarm_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -129,6 +130,7 @@ void grpc_init(void) { grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); + grpc_object_registry_init(); grpc_security_pre_init(); grpc_core::ExecCtx::GlobalInit(); grpc_iomgr_init(); @@ -177,6 +179,7 @@ void grpc_shutdown(void) { grpc_mdctx_global_shutdown(); grpc_handshaker_factory_registry_shutdown(); grpc_slice_intern_shutdown(); + grpc_object_registry_shutdown(); grpc_stats_shutdown(); } grpc_core::ExecCtx::GlobalShutdown(); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index aea0786890b..1e964cebce7 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -38,6 +38,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/log_windows.cc', 'src/core/lib/support/mpscq.cc', 'src/core/lib/support/murmur_hash.cc', + 'src/core/lib/support/object_registry.cc', 'src/core/lib/support/string.cc', 'src/core/lib/support/string_posix.cc', 'src/core/lib/support/string_util_windows.cc', @@ -64,6 +65,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', + 'src/core/lib/channel/channel_tracer.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc new file mode 100644 index 00000000000..a5264774fb5 --- /dev/null +++ b/test/core/channel/channel_tracer_test.cc @@ -0,0 +1,210 @@ +/* + * + * Copyright 2017 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. + * + */ + +#include +#include + +#include +#include +#include + +#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/iomgr/exec_ctx.h" + +#include "test/core/util/channel_tracing_utils.h" +#include "test/core/util/test_config.h" + +static void add_simple_trace(grpc_channel_tracer* tracer) { + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_CHANNEL_READY, NULL); +} + +// checks for the existence of all the required members of the tracer. +static void validate_tracer(grpc_channel_tracer* tracer, + size_t expected_num_nodes_logged, + size_t max_nodes) { + char* json_str = grpc_channel_tracer_render_trace(tracer, true); + grpc_json* json = grpc_json_parse_string(json_str); + validate_channel_data(json, expected_num_nodes_logged, + GPR_MIN(expected_num_nodes_logged, max_nodes)); + grpc_json_destroy(json); + gpr_free(json_str); +} + +// ensures the tracer has the correct number of children tracers. +static void validate_children(grpc_channel_tracer* tracer, + size_t expected_num_children) { + char* json_str = grpc_channel_tracer_render_trace(tracer, true); + grpc_json* json = grpc_json_parse_string(json_str); + validate_json_array_size(json, "children", expected_num_children); + grpc_json_destroy(json); + gpr_free(json_str); +} + +static intptr_t uuid = 0; + +static void test_basic_channel_tracing(size_t max_nodes) { + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_core::ExecCtx exec_ctx; + add_simple_trace(tracer); + add_simple_trace(tracer); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("trace three"), + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_ERROR_INT_HTTP2_ERROR, 2), + GRPC_CHANNEL_IDLE, NULL); + grpc_channel_tracer_add_trace(tracer, + grpc_slice_from_static_string("trace four"), + GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN, NULL); + validate_tracer(tracer, 4, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer(tracer, 6, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer(tracer, 10, max_nodes); + GRPC_CHANNEL_TRACER_UNREF(tracer); +} + +static void test_basic_channel_sizing() { + test_basic_channel_tracing(0); + test_basic_channel_tracing(1); + test_basic_channel_tracing(2); + test_basic_channel_tracing(6); + test_basic_channel_tracing(10); + test_basic_channel_tracing(15); +} + +static void test_complex_channel_tracing(size_t max_nodes) { + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_core::ExecCtx exec_ctx; + add_simple_trace(tracer); + add_simple_trace(tracer); + grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + validate_tracer(tracer, 3, max_nodes); + add_simple_trace(sc1); + add_simple_trace(sc1); + add_simple_trace(sc1); + validate_tracer(sc1, 3, max_nodes); + add_simple_trace(sc1); + add_simple_trace(sc1); + add_simple_trace(sc1); + validate_tracer(sc1, 6, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer(tracer, 5, max_nodes); + grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + validate_tracer(tracer, 7, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + GRPC_CHANNEL_TRACER_UNREF(sc1); + GRPC_CHANNEL_TRACER_UNREF(sc2); + GRPC_CHANNEL_TRACER_UNREF(tracer); +} + +static void test_complex_channel_sizing() { + test_complex_channel_tracing(0); + test_complex_channel_tracing(1); + test_complex_channel_tracing(2); + test_complex_channel_tracing(6); + test_complex_channel_tracing(10); + test_complex_channel_tracing(15); +} + +static void test_delete_parent_first() { + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(3, uuid++); + grpc_core::ExecCtx exec_ctx; + add_simple_trace(tracer); + add_simple_trace(tracer); + grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(3, uuid++); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + // this will cause the tracer destructor to run. + GRPC_CHANNEL_TRACER_UNREF(tracer); + GRPC_CHANNEL_TRACER_UNREF(sc1); +} + +static void test_nesting() { + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(10, uuid++); + grpc_core::ExecCtx exec_ctx; + add_simple_trace(tracer); + add_simple_trace(tracer); + grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(5, uuid++); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + // channel has only one subchannel right here. + validate_children(tracer, 1); + add_simple_trace(sc1); + grpc_channel_tracer* conn1 = GRPC_CHANNEL_TRACER_CREATE(5, uuid++); + // nesting one level deeper. + grpc_channel_tracer_add_trace( + sc1, grpc_slice_from_static_string("connection one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); + validate_children(sc1, 1); + add_simple_trace(conn1); + add_simple_trace(tracer); + add_simple_trace(tracer); + grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(5, uuid++); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + validate_children(tracer, 2); + // this trace should not get added to the parents children since it is already + // present in the tracer. + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + validate_children(tracer, 2); + add_simple_trace(tracer); + + GRPC_CHANNEL_TRACER_UNREF(conn1); + GRPC_CHANNEL_TRACER_UNREF(sc1); + GRPC_CHANNEL_TRACER_UNREF(sc2); + GRPC_CHANNEL_TRACER_UNREF(tracer); +} + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + grpc_init(); + test_basic_channel_tracing(5); + test_basic_channel_sizing(); + test_complex_channel_tracing(5); + test_complex_channel_sizing(); + test_delete_parent_first(); + test_nesting(); + grpc_shutdown(); + return 0; +} diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc new file mode 100644 index 00000000000..805726ff166 --- /dev/null +++ b/test/core/util/channel_tracing_utils.cc @@ -0,0 +1,60 @@ +/* + * + * Copyright 2017 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. + * + */ + +#include +#include + +#include +#include +#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/json/json.h" + +static grpc_json* get_json_child(grpc_json* parent, const char* key) { + GPR_ASSERT(parent != NULL); + for (grpc_json* child = parent->child; child != NULL; child = child->next) { + if (child->key != NULL && strcmp(child->key, key) == 0) return child; + } + return NULL; +} + +void validate_json_array_size(grpc_json* json, const char* key, + size_t expected_size) { + grpc_json* arr = get_json_child(json, key); + GPR_ASSERT(arr); + GPR_ASSERT(arr->type == GRPC_JSON_ARRAY); + size_t count = 0; + for (grpc_json* child = arr->child; child != NULL; child = child->next) { + ++count; + } + GPR_ASSERT(count == expected_size); +} + +void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, + size_t actual_num_nodes_expected) { + GPR_ASSERT(json); + grpc_json* channel_data = get_json_child(json, "channelData"); + grpc_json* num_nodes_logged_json = + get_json_child(channel_data, "numNodesLogged"); + GPR_ASSERT(num_nodes_logged_json); + grpc_json* start_time = get_json_child(channel_data, "startTime"); + GPR_ASSERT(start_time); + size_t num_nodes_logged = + (size_t)strtol(num_nodes_logged_json->value, NULL, 0); + GPR_ASSERT(num_nodes_logged == num_nodes_logged_expected); + validate_json_array_size(channel_data, "nodes", actual_num_nodes_expected); +} diff --git a/test/core/util/channel_tracing_utils.h b/test/core/util/channel_tracing_utils.h new file mode 100644 index 00000000000..6a3eac98a91 --- /dev/null +++ b/test/core/util/channel_tracing_utils.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2017 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. + * + */ + +#ifndef GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H +#define GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H + +#include "src/core/lib/channel/channel_tracer.h" + +void validate_json_array_size(grpc_json* json, const char* key, + size_t expected_size); + +void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, + size_t actual_num_nodes_expected); + +#endif /* GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H */ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index d09b325c97a..65bc771cf01 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -938,6 +938,7 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ +src/core/lib/channel/channel_tracer.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ @@ -1039,6 +1040,7 @@ src/core/lib/support/manual_constructor.h \ src/core/lib/support/memory.h \ src/core/lib/support/mpscq.h \ src/core/lib/support/murmur_hash.h \ +src/core/lib/support/object_registry.h \ src/core/lib/support/ref_counted.h \ src/core/lib/support/ref_counted_ptr.h \ src/core/lib/support/spinlock.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 1aff0075a6a..4caa299a175 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1040,6 +1040,8 @@ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ +src/core/lib/channel/channel_tracer.cc \ +src/core/lib/channel/channel_tracer.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ @@ -1305,6 +1307,8 @@ src/core/lib/support/mpscq.cc \ src/core/lib/support/mpscq.h \ src/core/lib/support/murmur_hash.cc \ src/core/lib/support/murmur_hash.h \ +src/core/lib/support/object_registry.cc \ +src/core/lib/support/object_registry.h \ src/core/lib/support/ref_counted.h \ src/core/lib/support/ref_counted_ptr.h \ src/core/lib/support/spinlock.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 0fc5a25afd3..067bf438341 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -914,6 +914,23 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "grpc_channel_tracer_test", + "src": [ + "test/core/channel/channel_tracer_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -7791,6 +7808,7 @@ "src/core/lib/support/log_windows.cc", "src/core/lib/support/mpscq.cc", "src/core/lib/support/murmur_hash.cc", + "src/core/lib/support/object_registry.cc", "src/core/lib/support/string.cc", "src/core/lib/support/string_posix.cc", "src/core/lib/support/string_util_windows.cc", @@ -7859,6 +7877,7 @@ "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", "src/core/lib/support/murmur_hash.h", + "src/core/lib/support/object_registry.h", "src/core/lib/support/spinlock.h", "src/core/lib/support/string.h", "src/core/lib/support/string_windows.h", @@ -7908,6 +7927,7 @@ "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", "src/core/lib/support/murmur_hash.h", + "src/core/lib/support/object_registry.h", "src/core/lib/support/spinlock.h", "src/core/lib/support/string.h", "src/core/lib/support/string_windows.h", @@ -8002,6 +8022,7 @@ "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", + "src/core/lib/channel/channel_tracer.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -8158,6 +8179,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/channel_tracer.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -8297,6 +8319,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/channel_tracer.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -8940,6 +8963,7 @@ "test/core/end2end/fixtures/http_proxy_fixture.h", "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.h", + "test/core/util/channel_tracing_utils.h", "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.h", "test/core/util/histogram.h", @@ -8967,6 +8991,8 @@ "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.cc", "test/core/iomgr/endpoint_tests.h", + "test/core/util/channel_tracing_utils.cc", + "test/core/util/channel_tracing_utils.h", "test/core/util/debugger_macros.cc", "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.cc", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 5cf371190c9..82157d095bc 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1223,6 +1223,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "grpc_channel_tracer_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, From d6631b0d6199bbda5ac726ad3d24611a3e831f4e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 2 Jan 2018 11:41:29 -0800 Subject: [PATCH 02/67] Update bazel files --- BUILD | 4 ++++ test/core/channel/BUILD | 12 ++++++++++++ test/core/util/BUILD | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/BUILD b/BUILD index dba6592f172..99cd76520f4 100644 --- a/BUILD +++ b/BUILD @@ -459,6 +459,7 @@ grpc_cc_library( "src/core/lib/support/log_windows.cc", "src/core/lib/support/mpscq.cc", "src/core/lib/support/murmur_hash.cc", + "src/core/lib/support/object_registry.cc", "src/core/lib/support/string.cc", "src/core/lib/support/string_posix.cc", "src/core/lib/support/string_util_windows.cc", @@ -494,6 +495,7 @@ grpc_cc_library( "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", "src/core/lib/support/murmur_hash.h", + "src/core/lib/support/object_registry.h", "src/core/lib/support/spinlock.h", "src/core/lib/support/string.h", "src/core/lib/support/string_windows.h", @@ -571,6 +573,7 @@ grpc_cc_library( "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", + "src/core/lib/channel/channel_tracer.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -705,6 +708,7 @@ grpc_cc_library( "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", + "src/core/lib/channel/channel_tracer.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 92f5907aac1..2950c3609ce 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -53,3 +53,15 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +cc_test( + name = "channel_tracer_test", + srcs = ["channel_tracer_test.cc"], + copts = ["-std=c99"], + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + ], +) diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 2237cfc1730..974940b3985 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -51,6 +51,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_test_util_base", srcs = [ + "channel_tracing_utils.cc", "grpc_profiler.cc", "histogram.cc", "mock_endpoint.cc", @@ -66,6 +67,7 @@ grpc_cc_library( "trickle_endpoint.cc", ], hdrs = [ + "channel_tracing_utils.h", "grpc_profiler.h", "histogram.h", "mock_endpoint.h", @@ -98,6 +100,8 @@ grpc_cc_library( ], ) + + grpc_cc_library( name = "grpc_test_util_unsecure", srcs = [], From fb505cc7c76cf5ec73cae16d146374e74aec5e30 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 10:21:21 -0800 Subject: [PATCH 03/67] No more custom define --- src/core/lib/channel/channel_tracer.cc | 31 +++++++++++++++++--------- src/core/lib/channel/channel_tracer.h | 6 ++--- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 0d77f33c7f2..31c1d842a0f 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -33,6 +33,9 @@ #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/connectivity_state.h" +grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount( + false, "channel_tracer_refcount"); + // One node of tracing data typedef struct grpc_trace_node { grpc_slice data; @@ -58,7 +61,7 @@ struct grpc_channel_tracer { gpr_timespec time_created; }; -#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +#ifndef NDEBUG grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, const char* file, int line, const char* func) { @@ -70,8 +73,10 @@ grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, gpr_zalloc(sizeof(grpc_channel_tracer))); gpr_mu_init(&tracer->tracer_mu); gpr_ref_init(&tracer->refs, 1); -#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG - gpr_log(GPR_DEBUG, "%p create [%s:%d %s]", tracer, file, line, func); +#ifndef NDEBUG + if (grpc_trace_channel_tracer_refcount.enabled()) { + gpr_log(GPR_DEBUG, "%p create [%s:%d %s]", tracer, file, line, func); + } #endif tracer->channel_uuid = uuid; tracer->max_list_size = max_nodes; @@ -79,14 +84,16 @@ grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, return tracer; } -#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +#ifndef NDEBUG grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, const char* file, int line, const char* func) { if (!tracer) return tracer; - gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, - gpr_atm_no_barrier_load(&tracer->refs.count), - gpr_atm_no_barrier_load(&tracer->refs.count) + 1, file, line, func); + if (grpc_trace_channel_tracer_refcount.enabled()) { + gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, + gpr_atm_no_barrier_load(&tracer->refs.count), + gpr_atm_no_barrier_load(&tracer->refs.count) + 1, file, line, func); + } gpr_ref(&tracer->refs); return tracer; } @@ -116,13 +123,15 @@ static void grpc_channel_tracer_destroy(grpc_channel_tracer* tracer) { gpr_free(tracer); } -#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +#ifndef NDEBUG void grpc_channel_tracer_unref(grpc_channel_tracer* tracer, const char* file, int line, const char* func) { if (!tracer) return; - gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, - gpr_atm_no_barrier_load(&tracer->refs.count), - gpr_atm_no_barrier_load(&tracer->refs.count) - 1, file, line, func); + if (grpc_trace_channel_tracer_refcount.enabled()) { + gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, + gpr_atm_no_barrier_load(&tracer->refs.count), + gpr_atm_no_barrier_load(&tracer->refs.count) - 1, file, line, func); + } if (gpr_unref(&tracer->refs)) { grpc_channel_tracer_destroy(tracer); } diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 1f151ba8991..34bb242ca00 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -26,10 +26,10 @@ /* Forward declaration */ typedef struct grpc_channel_tracer grpc_channel_tracer; -// #define GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +extern grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount; /* Creates a new tracer. The caller owns a reference to the returned tracer. */ -#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +#ifndef NDEBUG grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, const char* file, int line, const char* func); @@ -42,7 +42,7 @@ grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, grpc_channel_tracer_create(max_nodes, id) #endif -#ifdef GRPC_CHANNEL_TRACER_REFCOUNT_DEBUG +#ifndef NDEBUG grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, const char* file, int line, const char* func); From 1d2f23b338fee1a88db63bc5728bbe23065fbba7 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 17:42:52 -0800 Subject: [PATCH 04/67] Register tracers, not (sub)channels --- .../ext/filters/client_channel/subchannel.cc | 13 +------- .../ext/filters/client_channel/subchannel.h | 4 --- src/core/lib/channel/channel_tracer.cc | 30 +++++++------------ src/core/lib/channel/channel_tracer.h | 16 +++++----- src/core/lib/support/object_registry.h | 3 +- src/core/lib/surface/channel.cc | 6 ++-- 6 files changed, 25 insertions(+), 47 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 8b8e468f16f..02bcba0e73d 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -188,7 +188,6 @@ void grpc_connected_subchannel_unref( static void subchannel_destroy(void* arg, grpc_error* error) { grpc_subchannel* c = (grpc_subchannel*)arg; - grpc_object_registry_unregister_object(c->uuid); gpr_free((void*)c->filters); grpc_channel_args_destroy(c->args); grpc_connectivity_state_destroy(&c->state_tracker); @@ -343,8 +342,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(); c = (grpc_subchannel*)gpr_zalloc(sizeof(*c)); - c->uuid = - grpc_object_registry_register_object(c, GPRC_OBJECT_REGISTRY_SUBCHANNEL); + c->uuid = -1; c->key = key; gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS); c->connector = connector; @@ -393,15 +391,6 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, return grpc_subchannel_index_register(key, c); } -char* grpc_subchannel_get_trace(grpc_subchannel* subchannel, bool recursive) { - return subchannel->tracer != NULL - ? grpc_channel_tracer_render_trace(subchannel->tracer, recursive) - : NULL; -} -intptr_t grpc_subchannel_get_uuid(grpc_subchannel* subchannel) { - return subchannel->uuid; -} - static void continue_connect_locked(grpc_subchannel* c) { grpc_connect_in_args args; args.interested_parties = c->pollset_set; diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 3584d3928a1..9d34fff07a8 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -165,10 +165,6 @@ struct grpc_subchannel_args { grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, const grpc_subchannel_args* args); -/// retrieves the trace for this subchannel in JSON form. -char* grpc_subchannel_get_trace(grpc_subchannel* subchannel, bool recursive); -intptr_t grpc_subchannel_get_uuid(grpc_subchannel* subchannel); - /// Sets \a addr from \a args. void grpc_get_subchannel_address_arg(const grpc_channel_args* args, grpc_resolved_address* addr); diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 31c1d842a0f..931f4b32b58 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -25,7 +25,6 @@ #include #include -#include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/object_registry.h" @@ -62,12 +61,11 @@ struct grpc_channel_tracer { }; #ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, const char* file, int line, const char* func) { #else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - intptr_t uuid) { +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes) { #endif grpc_channel_tracer* tracer = static_cast( gpr_zalloc(sizeof(grpc_channel_tracer))); @@ -78,7 +76,8 @@ grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, gpr_log(GPR_DEBUG, "%p create [%s:%d %s]", tracer, file, line, func); } #endif - tracer->channel_uuid = uuid; + tracer->channel_uuid = grpc_object_registry_register_object( + tracer, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); tracer->max_list_size = max_nodes; tracer->time_created = gpr_now(GPR_CLOCK_REALTIME); return tracer; @@ -145,6 +144,10 @@ void grpc_channel_tracer_unref(grpc_channel_tracer* tracer) { } #endif +intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer) { + return tracer->channel_uuid; +} + void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, @@ -318,18 +321,7 @@ char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive) { void* object; grpc_object_registry_type type = grpc_object_registry_get_object(uuid, &object); - GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL || - type == GPRC_OBJECT_REGISTRY_SUBCHANNEL); - switch (type) { - case GRPC_OBJECT_REGISTRY_CHANNEL: - return grpc_channel_get_trace(static_cast(object), - recursive); - break; - case GPRC_OBJECT_REGISTRY_SUBCHANNEL: - return grpc_subchannel_get_trace(static_cast(object), - recursive); - break; - default: - abort(); - } + GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + return grpc_channel_tracer_render_trace( + static_cast(object), recursive); } diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 34bb242ca00..5c34f1bc441 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -30,16 +30,15 @@ extern grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount; /* Creates a new tracer. The caller owns a reference to the returned tracer. */ #ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, intptr_t uuid, +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, const char* file, int line, const char* func); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes, id) \ - grpc_channel_tracer_create(max_nodes, id, __FILE__, __LINE__, __func__) +#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ + grpc_channel_tracer_create(max_nodes, __FILE__, __LINE__, __func__) #else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - intptr_t uuid); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes, id) \ - grpc_channel_tracer_create(max_nodes, id) +grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes); +#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ + grpc_channel_tracer_create(max_nodes) #endif #ifndef NDEBUG @@ -59,6 +58,9 @@ void grpc_channel_tracer_unref(grpc_channel_tracer* tracer); #define GRPC_CHANNEL_TRACER_UNREF(tracer) grpc_channel_tracer_unref(tracer) #endif +/* returns the tracers uuid */ +intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer); + /* Adds a new trace node to the tracing object */ void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, grpc_error* error, diff --git a/src/core/lib/support/object_registry.h b/src/core/lib/support/object_registry.h index 3a0d056e2ad..1b8e13d054a 100644 --- a/src/core/lib/support/object_registry.h +++ b/src/core/lib/support/object_registry.h @@ -22,8 +22,7 @@ #include typedef enum { - GRPC_OBJECT_REGISTRY_CHANNEL, - GPRC_OBJECT_REGISTRY_SUBCHANNEL, + GRPC_OBJECT_REGISTRY_CHANNEL_TRACER, GRPC_OBJECT_REGISTRY_UNKNOWN, } grpc_object_registry_type; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e94413e3bcb..e182da27188 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -101,10 +101,9 @@ grpc_channel* grpc_channel_create_with_builder( } memset(channel, 0, sizeof(*channel)); - channel->uuid = grpc_object_registry_register_object( - channel, GRPC_OBJECT_REGISTRY_CHANNEL); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); + channel->uuid = -1; channel->tracer = NULL; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -203,7 +202,8 @@ grpc_channel* grpc_channel_create_with_builder( size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); if (max_nodes > 0) { - channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, channel->uuid); + channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); + channel->uuid = grpc_channel_tracer_get_uuid(channel->tracer); } } } From 09c033a8dd068d07216fbcc6dcd08ab021b2eb35 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 21:07:02 -0800 Subject: [PATCH 05/67] Fix test compile --- test/core/channel/channel_tracer_test.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index a5264774fb5..47bb4302ded 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -57,10 +57,8 @@ static void validate_children(grpc_channel_tracer* tracer, gpr_free(json_str); } -static intptr_t uuid = 0; - static void test_basic_channel_tracing(size_t max_nodes) { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_core::ExecCtx exec_ctx; add_simple_trace(tracer); add_simple_trace(tracer); @@ -94,11 +92,11 @@ static void test_basic_channel_sizing() { } static void test_complex_channel_tracing(size_t max_nodes) { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_core::ExecCtx exec_ctx; add_simple_trace(tracer); add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_channel_tracer_add_trace( tracer, grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); @@ -114,7 +112,7 @@ static void test_complex_channel_tracing(size_t max_nodes) { add_simple_trace(tracer); add_simple_trace(tracer); validate_tracer(tracer, 5, max_nodes); - grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(max_nodes, uuid++); + grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_channel_tracer_add_trace( tracer, grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); @@ -143,11 +141,11 @@ static void test_complex_channel_sizing() { } static void test_delete_parent_first() { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(3, uuid++); + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(3); grpc_core::ExecCtx exec_ctx; add_simple_trace(tracer); add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(3, uuid++); + grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(3); grpc_channel_tracer_add_trace( tracer, grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); @@ -157,18 +155,18 @@ static void test_delete_parent_first() { } static void test_nesting() { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(10, uuid++); + grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(10); grpc_core::ExecCtx exec_ctx; add_simple_trace(tracer); add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(5, uuid++); + grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(5); grpc_channel_tracer_add_trace( tracer, grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); // channel has only one subchannel right here. validate_children(tracer, 1); add_simple_trace(sc1); - grpc_channel_tracer* conn1 = GRPC_CHANNEL_TRACER_CREATE(5, uuid++); + grpc_channel_tracer* conn1 = GRPC_CHANNEL_TRACER_CREATE(5); // nesting one level deeper. grpc_channel_tracer_add_trace( sc1, grpc_slice_from_static_string("connection one created"), @@ -177,7 +175,7 @@ static void test_nesting() { add_simple_trace(conn1); add_simple_trace(tracer); add_simple_trace(tracer); - grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(5, uuid++); + grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(5); grpc_channel_tracer_add_trace( tracer, grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); From 9be168be0c36f588ce2bde923999d66375c0a030 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 21:26:23 -0800 Subject: [PATCH 06/67] Missing s/NULL/nullptr --- src/core/lib/iomgr/exec_ctx.h | 2 +- src/core/lib/iomgr/gethostname_sysconf.cc | 2 +- src/core/lib/iomgr/wakeup_fd_nospecial.cc | 2 +- src/core/lib/support/env_posix.cc | 4 ++-- src/core/lib/support/fork.cc | 2 +- src/core/lib/support/log_posix.cc | 8 ++++---- src/core/lib/support/time_posix.cc | 2 +- src/core/lib/transport/error_utils.cc | 2 +- test/core/iomgr/fd_conservation_posix_test.cc | 2 +- test/core/iomgr/resource_quota_test.cc | 14 +++++++------- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 8f8d518def7..5c6007c3c70 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -111,7 +111,7 @@ class ExecCtx { /** Checks if there is work to be done */ bool HasWork() { - return combiner_data_.active_combiner != NULL || + return combiner_data_.active_combiner != nullptr || !grpc_closure_list_empty(closure_list_); } diff --git a/src/core/lib/iomgr/gethostname_sysconf.cc b/src/core/lib/iomgr/gethostname_sysconf.cc index e099fbd3888..3d74e033388 100644 --- a/src/core/lib/iomgr/gethostname_sysconf.cc +++ b/src/core/lib/iomgr/gethostname_sysconf.cc @@ -30,7 +30,7 @@ char* grpc_gethostname() { char* hostname = (char*)gpr_malloc(host_name_max); if (gethostname(hostname, host_name_max) != 0) { gpr_free(hostname); - return NULL; + return nullptr; } return hostname; } diff --git a/src/core/lib/iomgr/wakeup_fd_nospecial.cc b/src/core/lib/iomgr/wakeup_fd_nospecial.cc index 4c20b8c1b71..c2b525a2544 100644 --- a/src/core/lib/iomgr/wakeup_fd_nospecial.cc +++ b/src/core/lib/iomgr/wakeup_fd_nospecial.cc @@ -31,6 +31,6 @@ static int check_availability_invalid(void) { return 0; } const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable = { - NULL, NULL, NULL, NULL, check_availability_invalid}; + nullptr, nullptr, nullptr, nullptr, check_availability_invalid}; #endif /* GRPC_POSIX_NO_SPECIAL_WAKEUP_FD */ diff --git a/src/core/lib/support/env_posix.cc b/src/core/lib/support/env_posix.cc index 7bea31ca550..8146330555c 100644 --- a/src/core/lib/support/env_posix.cc +++ b/src/core/lib/support/env_posix.cc @@ -31,12 +31,12 @@ const char* gpr_getenv_silent(const char* name, char** dst) { *dst = gpr_getenv(name); - return NULL; + return nullptr; } char* gpr_getenv(const char* name) { char* result = getenv(name); - return result == NULL ? result : gpr_strdup(result); + return result == nullptr ? result : gpr_strdup(result); } void gpr_setenv(const char* name, const char* value) { diff --git a/src/core/lib/support/fork.cc b/src/core/lib/support/fork.cc index d59ca5584cb..dc291c40804 100644 --- a/src/core/lib/support/fork.cc +++ b/src/core/lib/support/fork.cc @@ -39,7 +39,7 @@ void grpc_fork_support_init() { #else fork_support_enabled = 0; char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT"); - if (env != NULL) { + if (env != nullptr) { static const char* truthy[] = {"yes", "Yes", "YES", "true", "True", "TRUE", "1"}; for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) { diff --git a/src/core/lib/support/log_posix.cc b/src/core/lib/support/log_posix.cc index 9fab480a8d4..6f93cdefcdf 100644 --- a/src/core/lib/support/log_posix.cc +++ b/src/core/lib/support/log_posix.cc @@ -35,15 +35,15 @@ static intptr_t gettid(void) { return (intptr_t)pthread_self(); } void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { char buf[64]; - char* allocated = NULL; - char* message = NULL; + char* allocated = nullptr; + char* message = nullptr; int ret; va_list args; va_start(args, format); ret = vsnprintf(buf, sizeof(buf), format, args); va_end(args); if (ret < 0) { - message = NULL; + message = nullptr; } else if ((size_t)ret <= sizeof(buf) - 1) { message = buf; } else { @@ -66,7 +66,7 @@ void gpr_default_log(gpr_log_func_args* args) { timer = (time_t)now.tv_sec; final_slash = strrchr(args->file, '/'); - if (final_slash == NULL) + if (final_slash == nullptr) display_file = args->file; else display_file = final_slash + 1; diff --git a/src/core/lib/support/time_posix.cc b/src/core/lib/support/time_posix.cc index 47a849480f5..b2087c93cfe 100644 --- a/src/core/lib/support/time_posix.cc +++ b/src/core/lib/support/time_posix.cc @@ -107,7 +107,7 @@ static gpr_timespec now_impl(gpr_clock_type clock) { now.clock_type = clock; switch (clock) { case GPR_CLOCK_REALTIME: - gettimeofday(&now_tv, NULL); + gettimeofday(&now_tv, nullptr); now.tv_sec = now_tv.tv_sec; now.tv_nsec = now_tv.tv_usec * 1000; break; diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc index ffaf327081f..891576f4baf 100644 --- a/src/core/lib/transport/error_utils.cc +++ b/src/core/lib/transport/error_utils.cc @@ -70,7 +70,7 @@ void grpc_error_get_status(grpc_error* error, grpc_millis deadline, } if (code != nullptr) *code = status; - if (error_string != NULL && status != GRPC_STATUS_OK) { + if (error_string != nullptr && status != GRPC_STATUS_OK) { *error_string = gpr_strdup(grpc_error_string(error)); } diff --git a/test/core/iomgr/fd_conservation_posix_test.cc b/test/core/iomgr/fd_conservation_posix_test.cc index aaa14010f8d..4866e350d53 100644 --- a/test/core/iomgr/fd_conservation_posix_test.cc +++ b/test/core/iomgr/fd_conservation_posix_test.cc @@ -43,7 +43,7 @@ int main(int argc, char** argv) { grpc_resource_quota_create("fd_conservation_posix_test"); for (i = 0; i < 100; i++) { - p = grpc_iomgr_create_endpoint_pair("test", NULL); + p = grpc_iomgr_create_endpoint_pair("test", nullptr); grpc_endpoint_destroy(p.client); grpc_endpoint_destroy(p.server); grpc_core::ExecCtx::Get()->Flush(); diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc index ae26f72701b..07682d26308 100644 --- a/test/core/iomgr/resource_quota_test.cc +++ b/test/core/iomgr/resource_quota_test.cc @@ -118,7 +118,7 @@ static void test_instant_alloc_then_free(void) { grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_core::ExecCtx exec_ctx; - grpc_resource_user_alloc(usr, 1024, NULL); + grpc_resource_user_alloc(usr, 1024, nullptr); } { grpc_core::ExecCtx exec_ctx; @@ -136,7 +136,7 @@ static void test_instant_alloc_free_pair(void) { grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_core::ExecCtx exec_ctx; - grpc_resource_user_alloc(usr, 1024, NULL); + grpc_resource_user_alloc(usr, 1024, nullptr); grpc_resource_user_free(usr, 1024); } grpc_resource_quota_unref(q); @@ -565,7 +565,7 @@ static void test_resource_user_stays_allocated_until_memory_released(void) { grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_core::ExecCtx exec_ctx; - grpc_resource_user_alloc(usr, 1024, NULL); + grpc_resource_user_alloc(usr, 1024, nullptr); } { grpc_core::ExecCtx exec_ctx; @@ -608,8 +608,8 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released( grpc_core::ExecCtx exec_ctx; grpc_resource_user_alloc(usr, 1024, set_event(&allocated)); grpc_core::ExecCtx::Get()->Flush(); - GPR_ASSERT(gpr_event_wait(&allocated, - grpc_timeout_seconds_to_deadline(5)) != NULL); + GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline( + 5)) != nullptr); GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled, grpc_timeout_milliseconds_to_deadline(100)) == nullptr); @@ -667,8 +667,8 @@ static void test_reclaimers_can_be_posted_repeatedly(void) { grpc_core::ExecCtx exec_ctx; grpc_resource_user_alloc(usr, 1024, set_event(&allocated)); grpc_core::ExecCtx::Get()->Flush(); - GPR_ASSERT(gpr_event_wait(&allocated, - grpc_timeout_seconds_to_deadline(5)) != NULL); + GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline( + 5)) != nullptr); GPR_ASSERT(gpr_event_wait(&reclaimer_done, grpc_timeout_seconds_to_deadline(5)) != nullptr); From e78bd519ca433cd4945da3a6c77284a11cca8bb6 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 21:40:45 -0800 Subject: [PATCH 07/67] Clangify my stale code --- src/core/lib/channel/channel_tracer.cc | 30 ++++++++++++------------ src/core/lib/json/json.cc | 8 +++---- src/core/lib/support/object_registry.cc | 6 ++--- src/core/lib/surface/channel.cc | 8 +++---- test/core/channel/channel_tracer_test.cc | 15 ++++++------ test/core/util/channel_tracing_utils.cc | 13 +++++----- 6 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 931f4b32b58..92be5987a1f 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -113,7 +113,7 @@ static void free_node(grpc_trace_node* node) { static void grpc_channel_tracer_destroy(grpc_channel_tracer* tracer) { grpc_trace_node* it = tracer->head_trace; - while (it != NULL) { + while (it != nullptr) { grpc_trace_node* to_free = it; it = it->next; free_node(to_free); @@ -161,11 +161,11 @@ void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, new_trace_node->error = error; new_trace_node->time_created = gpr_now(GPR_CLOCK_REALTIME); new_trace_node->connectivity_state = connectivity_state; - new_trace_node->next = NULL; + new_trace_node->next = nullptr; new_trace_node->referenced_tracer = GRPC_CHANNEL_TRACER_REF(referenced_tracer); // first node case - if (tracer->head_trace == NULL) { + if (tracer->head_trace == nullptr) { tracer->head_trace = tracer->tail_trace = new_trace_node; } // regular node add case @@ -223,7 +223,7 @@ static void recursively_populate_json(grpc_channel_tracer* tracer, static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, grpc_json* json, grpc_json* children) { - grpc_json* child = NULL; + grpc_json* child = nullptr; child = grpc_json_create_child(child, json, "data", grpc_slice_to_c_string(node->data), GRPC_JSON_STRING, true); @@ -239,14 +239,14 @@ static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, child, json, "state", grpc_connectivity_state_name(node->connectivity_state), GRPC_JSON_STRING, false); - if (node->referenced_tracer != NULL) { + if (node->referenced_tracer != nullptr) { char* uuid_str; gpr_asprintf(&uuid_str, "%ld", node->referenced_tracer->channel_uuid); child = grpc_json_create_child(child, json, "uuid", uuid_str, GRPC_JSON_NUMBER, true); if (children && !seen_tracers_check(tracker, node->referenced_tracer)) { grpc_json* referenced_tracer = grpc_json_create_child( - NULL, children, NULL, NULL, GRPC_JSON_OBJECT, false); + nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); recursively_populate_json(node->referenced_tracer, tracker, referenced_tracer, true); } @@ -256,11 +256,11 @@ static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, static void populate_node_list_data(grpc_channel_tracer* tracer, seen_tracers* tracker, grpc_json* nodes, grpc_json* children) { - grpc_json* child = NULL; + grpc_json* child = nullptr; grpc_trace_node* it = tracer->head_trace; - while (it != NULL) { - child = grpc_json_create_child(child, nodes, NULL, NULL, GRPC_JSON_OBJECT, - false); + while (it != nullptr) { + child = grpc_json_create_child(child, nodes, nullptr, nullptr, + GRPC_JSON_OBJECT, false); populate_node_data(it, tracker, child, children); it = it->next; } @@ -269,7 +269,7 @@ static void populate_node_list_data(grpc_channel_tracer* tracer, static void populate_tracer_data(grpc_channel_tracer* tracer, seen_tracers* tracker, grpc_json* channel_data, grpc_json* children) { - grpc_json* child = NULL; + grpc_json* child = nullptr; char* uuid_str; gpr_asprintf(&uuid_str, "%ld", tracer->channel_uuid); @@ -282,7 +282,7 @@ static void populate_tracer_data(grpc_channel_tracer* tracer, child = grpc_json_create_child(child, channel_data, "startTime", fmt_time(tracer->time_created), GRPC_JSON_STRING, true); - child = grpc_json_create_child(child, channel_data, "nodes", NULL, + child = grpc_json_create_child(child, channel_data, "nodes", nullptr, GRPC_JSON_ARRAY, false); populate_node_list_data(tracer, tracker, child, children); } @@ -291,10 +291,10 @@ static void recursively_populate_json(grpc_channel_tracer* tracer, seen_tracers* tracker, grpc_json* json, bool recursive) { grpc_json* channel_data = grpc_json_create_child( - NULL, json, "channelData", NULL, GRPC_JSON_OBJECT, false); - grpc_json* children = NULL; + nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); + grpc_json* children = nullptr; if (recursive) { - children = grpc_json_create_child(channel_data, json, "children", NULL, + children = grpc_json_create_child(channel_data, json, "children", nullptr, GRPC_JSON_ARRAY, false); } seen_tracers_add(tracker, tracer); diff --git a/src/core/lib/json/json.cc b/src/core/lib/json/json.cc index 2171e694555..0b84a38199a 100644 --- a/src/core/lib/json/json.cc +++ b/src/core/lib/json/json.cc @@ -55,16 +55,16 @@ void grpc_json_destroy(grpc_json* json) { grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, grpc_json* sibling) { // first child case. - if (parent->child == NULL) { - GPR_ASSERT(sibling == NULL); + if (parent->child == nullptr) { + GPR_ASSERT(sibling == nullptr); parent->child = child; return child; } - if (sibling == NULL) { + if (sibling == nullptr) { sibling = parent->child; } // always find the right most sibling. - while (sibling->next != NULL) { + while (sibling->next != nullptr) { sibling = sibling->next; } sibling->next = child; diff --git a/src/core/lib/support/object_registry.cc b/src/core/lib/support/object_registry.cc index 596711804fa..bd19bb13a6e 100644 --- a/src/core/lib/support/object_registry.cc +++ b/src/core/lib/support/object_registry.cc @@ -73,7 +73,7 @@ intptr_t grpc_object_registry_register_object(void* object, tracker->type = type; intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); gpr_mu_lock(&g_mu); - g_avl = gpr_avl_add(g_avl, (void*)prior, tracker, NULL); + g_avl = gpr_avl_add(g_avl, (void*)prior, tracker, nullptr); gpr_mu_unlock(&g_mu); return prior; } @@ -91,8 +91,8 @@ grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, object_tracker* tracker = static_cast(gpr_avl_get(g_avl, (void*)uuid, nullptr)); gpr_mu_unlock(&g_mu); - if (tracker == NULL) { - *object = NULL; + if (tracker == nullptr) { + *object = nullptr; return GRPC_OBJECT_REGISTRY_UNKNOWN; } *object = tracker->object; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e182da27188..35e94f5dc1d 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -104,7 +104,7 @@ grpc_channel* grpc_channel_create_with_builder( channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); channel->uuid = -1; - channel->tracer = NULL; + channel->tracer = nullptr; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -196,7 +196,7 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(channel->tracer == NULL); + GPR_ASSERT(channel->tracer == nullptr); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; size_t max_nodes = @@ -211,14 +211,14 @@ grpc_channel* grpc_channel_create_with_builder( grpc_channel_args_destroy(args); grpc_channel_tracer_add_trace( channel->tracer, grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, NULL); + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); return channel; } char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { return channel->tracer ? grpc_channel_tracer_render_trace(channel->tracer, recursive) - : NULL; + : nullptr; } intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 47bb4302ded..4f1ce160a1a 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -30,9 +30,10 @@ #include "test/core/util/test_config.h" static void add_simple_trace(grpc_channel_tracer* tracer) { - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_CHANNEL_READY, NULL); + grpc_channel_tracer_add_trace(tracer, + grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_CHANNEL_READY, nullptr); } // checks for the existence of all the required members of the tracer. @@ -66,10 +67,10 @@ static void test_basic_channel_tracing(size_t max_nodes) { tracer, grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, 2), - GRPC_CHANNEL_IDLE, NULL); - grpc_channel_tracer_add_trace(tracer, - grpc_slice_from_static_string("trace four"), - GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN, NULL); + GRPC_CHANNEL_IDLE, nullptr); + grpc_channel_tracer_add_trace( + tracer, grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, + GRPC_CHANNEL_SHUTDOWN, nullptr); validate_tracer(tracer, 4, max_nodes); add_simple_trace(tracer); add_simple_trace(tracer); diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index 805726ff166..5644d1811d5 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -25,11 +25,12 @@ #include "src/core/lib/json/json.h" static grpc_json* get_json_child(grpc_json* parent, const char* key) { - GPR_ASSERT(parent != NULL); - for (grpc_json* child = parent->child; child != NULL; child = child->next) { - if (child->key != NULL && strcmp(child->key, key) == 0) return child; + GPR_ASSERT(parent != nullptr); + for (grpc_json* child = parent->child; child != nullptr; + child = child->next) { + if (child->key != nullptr && strcmp(child->key, key) == 0) return child; } - return NULL; + return nullptr; } void validate_json_array_size(grpc_json* json, const char* key, @@ -38,7 +39,7 @@ void validate_json_array_size(grpc_json* json, const char* key, GPR_ASSERT(arr); GPR_ASSERT(arr->type == GRPC_JSON_ARRAY); size_t count = 0; - for (grpc_json* child = arr->child; child != NULL; child = child->next) { + for (grpc_json* child = arr->child; child != nullptr; child = child->next) { ++count; } GPR_ASSERT(count == expected_size); @@ -54,7 +55,7 @@ void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, grpc_json* start_time = get_json_child(channel_data, "startTime"); GPR_ASSERT(start_time); size_t num_nodes_logged = - (size_t)strtol(num_nodes_logged_json->value, NULL, 0); + (size_t)strtol(num_nodes_logged_json->value, nullptr, 0); GPR_ASSERT(num_nodes_logged == num_nodes_logged_expected); validate_json_array_size(channel_data, "nodes", actual_num_nodes_expected); } From 5268185846477813592185075f13f1d8b2ab2190 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 3 Jan 2018 22:26:04 -0800 Subject: [PATCH 08/67] Fix bazel code --- test/core/channel/BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 2950c3609ce..f3b9231d83b 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -54,10 +54,10 @@ grpc_cc_test( ], ) -cc_test( +grpc_cc_test( name = "channel_tracer_test", srcs = ["channel_tracer_test.cc"], - copts = ["-std=c99"], + language = "C++", deps = [ "//:gpr", "//:grpc", From b928fd496efbe2265169077bcfdf684f7ad6aea3 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 4 Jan 2018 10:13:42 -0800 Subject: [PATCH 09/67] Fix portability build --- src/core/lib/channel/channel_tracer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 92be5987a1f..e2d3b7ae088 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -241,7 +241,7 @@ static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, false); if (node->referenced_tracer != nullptr) { char* uuid_str; - gpr_asprintf(&uuid_str, "%ld", node->referenced_tracer->channel_uuid); + gpr_asprintf(&uuid_str, "%" PRIdPTR, node->referenced_tracer->channel_uuid); child = grpc_json_create_child(child, json, "uuid", uuid_str, GRPC_JSON_NUMBER, true); if (children && !seen_tracers_check(tracker, node->referenced_tracer)) { @@ -272,7 +272,7 @@ static void populate_tracer_data(grpc_channel_tracer* tracer, grpc_json* child = nullptr; char* uuid_str; - gpr_asprintf(&uuid_str, "%ld", tracer->channel_uuid); + gpr_asprintf(&uuid_str, "%" PRIdPTR, tracer->channel_uuid); child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, GRPC_JSON_NUMBER, true); char* num_nodes_logged_str; From 6572ce2c4a11c65cbacd6434070f21254d81e917 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 18 Jan 2018 17:50:00 -0800 Subject: [PATCH 10/67] Classify the tracer object --- .../ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_tracer.cc | 370 ++++++++---------- src/core/lib/channel/channel_tracer.h | 84 ++-- src/core/lib/support/object_registry.cc | 2 +- src/core/lib/surface/channel.cc | 17 +- test/core/channel/channel_tracer_test.cc | 214 +++++----- 6 files changed, 316 insertions(+), 373 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index f4b6c2a161d..0310f152cce 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -137,7 +137,7 @@ struct grpc_subchannel { /** our alarm */ grpc_timer alarm; - grpc_channel_tracer* tracer; + grpc_core::ChannelTracer* tracer; }; struct grpc_subchannel_call { diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index e2d3b7ae088..e93fbc29d85 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -32,6 +32,8 @@ #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/connectivity_state.h" +namespace grpc_core { + grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount( false, "channel_tracer_refcount"); @@ -44,116 +46,55 @@ typedef struct grpc_trace_node { struct grpc_trace_node* next; // the tracer object for the (sub)channel that this trace node refers to. - grpc_channel_tracer* referenced_tracer; + ChannelTracer* referenced_tracer; } grpc_trace_node; -/* the channel tracing object */ -struct grpc_channel_tracer { - gpr_refcount refs; - gpr_mu tracer_mu; - intptr_t channel_uuid; - uint64_t num_nodes_logged; - size_t list_size; - size_t max_list_size; - grpc_trace_node* head_trace; - grpc_trace_node* tail_trace; - gpr_timespec time_created; -}; - -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - const char* file, int line, - const char* func) { -#else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes) { -#endif - grpc_channel_tracer* tracer = static_cast( - gpr_zalloc(sizeof(grpc_channel_tracer))); - gpr_mu_init(&tracer->tracer_mu); - gpr_ref_init(&tracer->refs, 1); -#ifndef NDEBUG - if (grpc_trace_channel_tracer_refcount.enabled()) { - gpr_log(GPR_DEBUG, "%p create [%s:%d %s]", tracer, file, line, func); - } -#endif - tracer->channel_uuid = grpc_object_registry_register_object( - tracer, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - tracer->max_list_size = max_nodes; - tracer->time_created = gpr_now(GPR_CLOCK_REALTIME); - return tracer; +ChannelTracer::ChannelTracer(size_t max_nodes) + : num_nodes_logged(0), + list_size(0), + max_list_size(max_nodes), + head_trace(0), + tail_trace(0) { + gpr_mu_init(&tracer_mu); + gpr_ref_init(&refs, 1); + channel_uuid = grpc_object_registry_register_object( + this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + max_list_size = max_nodes; + time_created = gpr_now(GPR_CLOCK_REALTIME); } -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, - const char* file, int line, - const char* func) { - if (!tracer) return tracer; - if (grpc_trace_channel_tracer_refcount.enabled()) { - gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, - gpr_atm_no_barrier_load(&tracer->refs.count), - gpr_atm_no_barrier_load(&tracer->refs.count) + 1, file, line, func); - } - gpr_ref(&tracer->refs); - return tracer; +ChannelTracer* ChannelTracer::Ref() { + gpr_ref(&refs); + return this; } -#else -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer) { - if (!tracer) return tracer; - gpr_ref(&tracer->refs); - return tracer; -} -#endif static void free_node(grpc_trace_node* node) { GRPC_ERROR_UNREF(node->error); - GRPC_CHANNEL_TRACER_UNREF(node->referenced_tracer); + if (node->referenced_tracer) { + node->referenced_tracer->Unref(); + } grpc_slice_unref_internal(node->data); gpr_free(node); } -static void grpc_channel_tracer_destroy(grpc_channel_tracer* tracer) { - grpc_trace_node* it = tracer->head_trace; - while (it != nullptr) { - grpc_trace_node* to_free = it; - it = it->next; - free_node(to_free); - } - gpr_mu_destroy(&tracer->tracer_mu); - gpr_free(tracer); -} - -#ifndef NDEBUG -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer, const char* file, - int line, const char* func) { - if (!tracer) return; - if (grpc_trace_channel_tracer_refcount.enabled()) { - gpr_log(GPR_DEBUG, "%p: %" PRIdPTR " -> %" PRIdPTR " [%s:%d %s]", tracer, - gpr_atm_no_barrier_load(&tracer->refs.count), - gpr_atm_no_barrier_load(&tracer->refs.count) - 1, file, line, func); - } - if (gpr_unref(&tracer->refs)) { - grpc_channel_tracer_destroy(tracer); - } -} -#else -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer) { - if (!tracer) return; - if (gpr_unref(&tracer->refs)) { - grpc_channel_tracer_destroy(tracer); +void ChannelTracer::Unref() { + if (gpr_unref(&refs)) { + grpc_trace_node* it = head_trace; + while (it != nullptr) { + grpc_trace_node* to_free = it; + it = it->next; + free_node(to_free); + } + gpr_mu_destroy(&tracer_mu); } } -#endif -intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer) { - return tracer->channel_uuid; -} +intptr_t ChannelTracer::GetUuid() { return channel_uuid; } -void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, - grpc_error* error, - grpc_connectivity_state connectivity_state, - grpc_channel_tracer* referenced_tracer) { - if (!tracer) return; - ++tracer->num_nodes_logged; +void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + ChannelTracer* referenced_tracer) { + ++num_nodes_logged; // create and fill up the new node grpc_trace_node* new_trace_node = static_cast(gpr_malloc(sizeof(grpc_trace_node))); @@ -163,23 +104,23 @@ void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, new_trace_node->connectivity_state = connectivity_state; new_trace_node->next = nullptr; new_trace_node->referenced_tracer = - GRPC_CHANNEL_TRACER_REF(referenced_tracer); + (referenced_tracer) ? referenced_tracer->Ref() : nullptr; // first node case - if (tracer->head_trace == nullptr) { - tracer->head_trace = tracer->tail_trace = new_trace_node; + if (head_trace == nullptr) { + head_trace = tail_trace = new_trace_node; } // regular node add case else { - tracer->tail_trace->next = new_trace_node; - tracer->tail_trace = tracer->tail_trace->next; + tail_trace->next = new_trace_node; + tail_trace = tail_trace->next; } - ++tracer->list_size; + ++list_size; // maybe garbage collect the end - if (tracer->list_size > tracer->max_list_size) { - grpc_trace_node* to_free = tracer->head_trace; - tracer->head_trace = tracer->head_trace->next; + if (list_size > max_list_size) { + grpc_trace_node* to_free = head_trace; + head_trace = head_trace->next; free_node(to_free); - --tracer->list_size; + --list_size; } } @@ -193,135 +134,138 @@ static char* fmt_time(gpr_timespec tm) { return full_time_str; } -typedef struct seen_tracers { - grpc_channel_tracer** tracers; - size_t size; - size_t cap; -} seen_tracers; +class ChannelTracerRenderer { + public: + ChannelTracerRenderer(ChannelTracer* tracer, bool recursive) + : current_tracer_(tracer), + recursive_(recursive), + seen_tracers_(nullptr), + size_(0), + cap_(0) {} -static void seen_tracers_add(seen_tracers* tracker, - grpc_channel_tracer* tracer) { - if (tracker->size >= tracker->cap) { - tracker->cap = GPR_MAX(5 * sizeof(tracer), 3 * tracker->cap / 2); - tracker->tracers = - (grpc_channel_tracer**)gpr_realloc(tracker->tracers, tracker->cap); + char* Run() { + grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); + AddSeenTracer(current_tracer_); + RecursivelyPopulateJson(json); + gpr_free(seen_tracers_); + char* json_str = grpc_json_dump_to_string(json, 1); + grpc_json_destroy(json); + return json_str; } - tracker->tracers[tracker->size++] = tracer; -} -static bool seen_tracers_check(seen_tracers* tracker, - grpc_channel_tracer* tracer) { - for (size_t i = 0; i < tracker->size; ++i) { - if (tracker->tracers[i] == tracer) return true; + private: + void AddSeenTracer(ChannelTracer* newly_seen) { + if (size_ >= cap_) { + cap_ = GPR_MAX(5 * sizeof(newly_seen), 3 * cap_ / 2); + seen_tracers_ = (ChannelTracer**)gpr_realloc(seen_tracers_, cap_); + } + seen_tracers_[size_++] = newly_seen; } - return false; -} -static void recursively_populate_json(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* json, - bool recursive); - -static void populate_node_data(grpc_trace_node* node, seen_tracers* tracker, - grpc_json* json, grpc_json* children) { - grpc_json* child = nullptr; - child = grpc_json_create_child(child, json, "data", - grpc_slice_to_c_string(node->data), - GRPC_JSON_STRING, true); - if (node->error != GRPC_ERROR_NONE) { - child = grpc_json_create_child(child, json, "error", - gpr_strdup(grpc_error_string(node->error)), - GRPC_JSON_STRING, true); - } - child = - grpc_json_create_child(child, json, "time", fmt_time(node->time_created), - GRPC_JSON_STRING, true); - child = grpc_json_create_child( - child, json, "state", - grpc_connectivity_state_name(node->connectivity_state), GRPC_JSON_STRING, - false); - if (node->referenced_tracer != nullptr) { - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, node->referenced_tracer->channel_uuid); - child = grpc_json_create_child(child, json, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - if (children && !seen_tracers_check(tracker, node->referenced_tracer)) { - grpc_json* referenced_tracer = grpc_json_create_child( - nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); - recursively_populate_json(node->referenced_tracer, tracker, - referenced_tracer, true); + bool TracerAlreadySeen(ChannelTracer* tracer) { + for (size_t i = 0; i < size_; ++i) { + if (seen_tracers_[i] == tracer) return true; } + return false; } -} -static void populate_node_list_data(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* nodes, - grpc_json* children) { - grpc_json* child = nullptr; - grpc_trace_node* it = tracer->head_trace; - while (it != nullptr) { - child = grpc_json_create_child(child, nodes, nullptr, nullptr, - GRPC_JSON_OBJECT, false); - populate_node_data(it, tracker, child, children); - it = it->next; + void RecursivelyPopulateJson(grpc_json* json) { + grpc_json* channel_data = grpc_json_create_child( + nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); + grpc_json* children = nullptr; + if (recursive_) { + children = grpc_json_create_child(channel_data, json, "children", nullptr, + GRPC_JSON_ARRAY, false); + } + PopulateTracer(channel_data, children); } -} -static void populate_tracer_data(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* channel_data, - grpc_json* children) { - grpc_json* child = nullptr; + void PopulateTracer(grpc_json* channel_data, grpc_json* children) { + grpc_json* child = nullptr; - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, tracer->channel_uuid); - child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - char* num_nodes_logged_str; - gpr_asprintf(&num_nodes_logged_str, "%" PRId64, tracer->num_nodes_logged); - child = grpc_json_create_child(child, channel_data, "numNodesLogged", - num_nodes_logged_str, GRPC_JSON_NUMBER, true); - child = grpc_json_create_child(child, channel_data, "startTime", - fmt_time(tracer->time_created), - GRPC_JSON_STRING, true); - child = grpc_json_create_child(child, channel_data, "nodes", nullptr, - GRPC_JSON_ARRAY, false); - populate_node_list_data(tracer, tracker, child, children); -} - -static void recursively_populate_json(grpc_channel_tracer* tracer, - seen_tracers* tracker, grpc_json* json, - bool recursive) { - grpc_json* channel_data = grpc_json_create_child( - nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); - grpc_json* children = nullptr; - if (recursive) { - children = grpc_json_create_child(channel_data, json, "children", nullptr, - GRPC_JSON_ARRAY, false); + char* uuid_str; + gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid); + child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, + GRPC_JSON_NUMBER, true); + char* num_nodes_logged_str; + gpr_asprintf(&num_nodes_logged_str, "%" PRId64, + current_tracer_->num_nodes_logged); + child = + grpc_json_create_child(child, channel_data, "numNodesLogged", + num_nodes_logged_str, GRPC_JSON_NUMBER, true); + child = grpc_json_create_child(child, channel_data, "startTime", + fmt_time(current_tracer_->time_created), + GRPC_JSON_STRING, true); + child = grpc_json_create_child(child, channel_data, "nodes", nullptr, + GRPC_JSON_ARRAY, false); + PopulateNodeList(child, children); } - seen_tracers_add(tracker, tracer); - populate_tracer_data(tracer, tracker, channel_data, children); -} - -char* grpc_channel_tracer_render_trace(grpc_channel_tracer* tracer, - bool recursive) { - grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); - seen_tracers tracker; - memset(&tracker, 0, sizeof(tracker)); + void PopulateNodeList(grpc_json* nodes, grpc_json* children) { + grpc_json* child = nullptr; + grpc_trace_node* it = current_tracer_->head_trace; + while (it != nullptr) { + child = grpc_json_create_child(child, nodes, nullptr, nullptr, + GRPC_JSON_OBJECT, false); + PopulateNode(it, child, children); + it = it->next; + } + } - recursively_populate_json(tracer, &tracker, json, recursive); + void PopulateNode(grpc_trace_node* node, grpc_json* json, + grpc_json* children) { + grpc_json* child = nullptr; + child = grpc_json_create_child(child, json, "data", + grpc_slice_to_c_string(node->data), + GRPC_JSON_STRING, true); + if (node->error != GRPC_ERROR_NONE) { + child = grpc_json_create_child(child, json, "error", + gpr_strdup(grpc_error_string(node->error)), + GRPC_JSON_STRING, true); + } + child = grpc_json_create_child(child, json, "time", + fmt_time(node->time_created), + GRPC_JSON_STRING, true); + child = grpc_json_create_child( + child, json, "state", + grpc_connectivity_state_name(node->connectivity_state), + GRPC_JSON_STRING, false); + if (node->referenced_tracer != nullptr) { + char* uuid_str; + gpr_asprintf(&uuid_str, "%" PRIdPTR, + node->referenced_tracer->channel_uuid); + child = grpc_json_create_child(child, json, "uuid", uuid_str, + GRPC_JSON_NUMBER, true); + if (children && !TracerAlreadySeen(node->referenced_tracer)) { + grpc_json* referenced_tracer = grpc_json_create_child( + nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); + AddSeenTracer(node->referenced_tracer); + ChannelTracer* saved = current_tracer_; + current_tracer_ = node->referenced_tracer; + RecursivelyPopulateJson(referenced_tracer); + current_tracer_ = saved; + } + } + } - gpr_free(tracker.tracers); + ChannelTracer* current_tracer_; + bool recursive_; + ChannelTracer** seen_tracers_; + size_t size_; + size_t cap_; +}; - char* json_str = grpc_json_dump_to_string(json, 1); - grpc_json_destroy(json); - return json_str; +char* ChannelTracer::RenderTrace(bool recursive) { + ChannelTracerRenderer renderer(this, recursive); + return renderer.Run(); } -char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive) { +char* ChannelTracer::GetChannelTraceFromUuid(intptr_t uuid, bool recursive) { void* object; grpc_object_registry_type type = grpc_object_registry_get_object(uuid, &object); GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - return grpc_channel_tracer_render_trace( - static_cast(object), recursive); + return static_cast(object)->RenderTrace(recursive); } + +} // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 5c34f1bc441..6b7d719028c 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -23,58 +23,52 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/json/json.h" -/* Forward declaration */ -typedef struct grpc_channel_tracer grpc_channel_tracer; +namespace grpc_core { extern grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount; -/* Creates a new tracer. The caller owns a reference to the returned tracer. */ -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes, - const char* file, int line, - const char* func); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ - grpc_channel_tracer_create(max_nodes, __FILE__, __LINE__, __func__) -#else -grpc_channel_tracer* grpc_channel_tracer_create(size_t max_nodes); -#define GRPC_CHANNEL_TRACER_CREATE(max_nodes) \ - grpc_channel_tracer_create(max_nodes) -#endif +typedef struct grpc_trace_node grpc_trace_node; -#ifndef NDEBUG -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer, - const char* file, int line, - const char* func); -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer, const char* file, - int line, const char* func); -#define GRPC_CHANNEL_TRACER_REF(tracer) \ - grpc_channel_tracer_ref(tracer, __FILE__, __LINE__, __func__) -#define GRPC_CHANNEL_TRACER_UNREF(tracer) \ - grpc_channel_tracer_unref(tracer, __FILE__, __LINE__, __func__) -#else -grpc_channel_tracer* grpc_channel_tracer_ref(grpc_channel_tracer* tracer); -void grpc_channel_tracer_unref(grpc_channel_tracer* tracer); -#define GRPC_CHANNEL_TRACER_REF(tracer) grpc_channel_tracer_ref(tracer) -#define GRPC_CHANNEL_TRACER_UNREF(tracer) grpc_channel_tracer_unref(tracer) -#endif +class ChannelTracer { + public: + ChannelTracer(size_t max_nodes); + ~ChannelTracer() {} -/* returns the tracers uuid */ -intptr_t grpc_channel_tracer_get_uuid(grpc_channel_tracer* tracer); + // TODO(ncteisen): incorporate RefCounted class + ChannelTracer* Ref(); + void Unref(); -/* Adds a new trace node to the tracing object */ -void grpc_channel_tracer_add_trace(grpc_channel_tracer* tracer, grpc_slice data, - grpc_error* error, - grpc_connectivity_state connectivity_state, - grpc_channel_tracer* subchannel); + /* returns the tracers uuid */ + intptr_t GetUuid(); -/* Returns the tracing data rendered as a grpc json string. - The string is owned by the caller and must be freed. If recursive - is true, then the string will include the recursive trace for all - subtracing objects. */ -char* grpc_channel_tracer_render_trace(grpc_channel_tracer* tracer, - bool recursive); -/* util functions that perform the uuid -> tracer step for you, and then + /* Adds a new trace node to the tracing object */ + void AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + ChannelTracer* subchannel); + + /* Returns the tracing data rendered as a grpc json string. + The string is owned by the caller and must be freed. If recursive + is true, then the string will include the recursive trace for all + subtracing objects. */ + char* RenderTrace(bool recursive); + + /* util functions that perform the uuid -> tracer step for you, and then returns the trace for the uuid given. */ -char* grpc_channel_tracer_get_trace(intptr_t uuid, bool recursive); + static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); + + private: + friend class ChannelTracerRenderer; + gpr_refcount refs; + gpr_mu tracer_mu; + intptr_t channel_uuid; + uint64_t num_nodes_logged; + size_t list_size; + size_t max_list_size; + grpc_trace_node* head_trace; + grpc_trace_node* tail_trace; + gpr_timespec time_created; +}; + +} // namespace grpc_core #endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H */ diff --git a/src/core/lib/support/object_registry.cc b/src/core/lib/support/object_registry.cc index bd19bb13a6e..72403a4f767 100644 --- a/src/core/lib/support/object_registry.cc +++ b/src/core/lib/support/object_registry.cc @@ -37,7 +37,7 @@ typedef struct { static void destroy_intptr(void* not_used, void* user_data) {} static void* copy_intptr(void* key, void* user_data) { return key; } static long compare_intptr(void* key1, void* key2, void* user_data) { - return key1 > key2; + return (intptr_t)key1 - (intptr_t)key2; } static void destroy_tracker(void* tracker, void* user_data) { diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 35e94f5dc1d..e80c36465e4 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,6 +32,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/memory.h" #include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/api_trace.h" @@ -63,7 +64,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_channel_tracer* tracer; + grpc_core::ChannelTracer* tracer; char* target; }; @@ -202,23 +203,21 @@ grpc_channel* grpc_channel_create_with_builder( size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); if (max_nodes > 0) { - channel->tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); - channel->uuid = grpc_channel_tracer_get_uuid(channel->tracer); + channel->tracer = grpc_core::New( + max_nodes); // TODO(ncteisen): leaky yo + channel->uuid = channel->tracer->GetUuid(); } } } grpc_channel_args_destroy(args); - grpc_channel_tracer_add_trace( - channel->tracer, grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); + channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); return channel; } char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { - return channel->tracer - ? grpc_channel_tracer_render_trace(channel->tracer, recursive) - : nullptr; + return channel->tracer ? channel->tracer->RenderTrace(recursive) : nullptr; } intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 4f1ce160a1a..131ea567fc9 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -29,18 +29,19 @@ #include "test/core/util/channel_tracing_utils.h" #include "test/core/util/test_config.h" -static void add_simple_trace(grpc_channel_tracer* tracer) { - grpc_channel_tracer_add_trace(tracer, - grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY, nullptr); +using grpc_core::ChannelTracer; + +static void add_simple_trace(ChannelTracer* tracer) { + tracer->AddTrace(grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_CHANNEL_READY, nullptr); } // checks for the existence of all the required members of the tracer. -static void validate_tracer(grpc_channel_tracer* tracer, +static void validate_tracer(ChannelTracer* tracer, size_t expected_num_nodes_logged, size_t max_nodes) { - char* json_str = grpc_channel_tracer_render_trace(tracer, true); + char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); validate_channel_data(json, expected_num_nodes_logged, GPR_MIN(expected_num_nodes_logged, max_nodes)); @@ -48,10 +49,20 @@ static void validate_tracer(grpc_channel_tracer* tracer, gpr_free(json_str); } +static void validate_tracer_data_matches_uuid_lookup(ChannelTracer* tracer) { + intptr_t uuid = tracer->GetUuid(); + char* tracer_json_str = tracer->RenderTrace(true); + char* uuid_lookup_json_str = + ChannelTracer::GetChannelTraceFromUuid(uuid, true); + strcmp(tracer_json_str, uuid_lookup_json_str); + gpr_free(tracer_json_str); + gpr_free(uuid_lookup_json_str); +} + // ensures the tracer has the correct number of children tracers. -static void validate_children(grpc_channel_tracer* tracer, +static void validate_children(ChannelTracer* tracer, size_t expected_num_children) { - char* json_str = grpc_channel_tracer_render_trace(tracer, true); + char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); validate_json_array_size(json, "children", expected_num_children); grpc_json_destroy(json); @@ -59,28 +70,29 @@ static void validate_children(grpc_channel_tracer* tracer, } static void test_basic_channel_tracing(size_t max_nodes) { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("trace three"), + ChannelTracer tracer(max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer_data_matches_uuid_lookup(&tracer); + tracer.AddTrace( + grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, 2), GRPC_CHANNEL_IDLE, nullptr); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, - GRPC_CHANNEL_SHUTDOWN, nullptr); - validate_tracer(tracer, 4, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - validate_tracer(tracer, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - validate_tracer(tracer, 10, max_nodes); - GRPC_CHANNEL_TRACER_UNREF(tracer); + tracer.AddTrace(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, + GRPC_CHANNEL_SHUTDOWN, nullptr); + validate_tracer(&tracer, 4, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer(&tracer, 6, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer(&tracer, 10, max_nodes); + validate_tracer_data_matches_uuid_lookup(&tracer); + tracer.Unref(); } static void test_basic_channel_sizing() { @@ -93,43 +105,42 @@ static void test_basic_channel_sizing() { } static void test_complex_channel_tracing(size_t max_nodes) { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(max_nodes); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(max_nodes); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); - validate_tracer(sc1, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); - validate_tracer(sc1, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - validate_tracer(tracer, 5, max_nodes); - grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(max_nodes); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 7, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - GRPC_CHANNEL_TRACER_UNREF(sc1); - GRPC_CHANNEL_TRACER_UNREF(sc2); - GRPC_CHANNEL_TRACER_UNREF(tracer); + ChannelTracer tracer(max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc1(max_nodes); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); + validate_tracer(&tracer, 3, max_nodes); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + validate_tracer(&sc1, 3, max_nodes); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + add_simple_trace(&sc1); + validate_tracer(&sc1, 6, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + validate_tracer(&tracer, 5, max_nodes); + validate_tracer_data_matches_uuid_lookup(&tracer); + ChannelTracer sc2(max_nodes); + tracer.AddTrace(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc2); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); + validate_tracer(&tracer, 7, max_nodes); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + // validate_tracer_data_matches_uuid_lookup(&tracer); + sc1.Unref(); + sc2.Unref(); + tracer.Unref(); } static void test_complex_channel_sizing() { @@ -142,57 +153,52 @@ static void test_complex_channel_sizing() { } static void test_delete_parent_first() { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(3); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(3); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + ChannelTracer tracer(3); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc1(3); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); // this will cause the tracer destructor to run. - GRPC_CHANNEL_TRACER_UNREF(tracer); - GRPC_CHANNEL_TRACER_UNREF(sc1); + tracer.Unref(); + sc1.Unref(); } static void test_nesting() { - grpc_channel_tracer* tracer = GRPC_CHANNEL_TRACER_CREATE(10); grpc_core::ExecCtx exec_ctx; - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc1 = GRPC_CHANNEL_TRACER_CREATE(5); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + ChannelTracer tracer(10); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc1(5); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); // channel has only one subchannel right here. - validate_children(tracer, 1); - add_simple_trace(sc1); - grpc_channel_tracer* conn1 = GRPC_CHANNEL_TRACER_CREATE(5); + validate_children(&tracer, 1); + add_simple_trace(&sc1); + ChannelTracer conn1(5); // nesting one level deeper. - grpc_channel_tracer_add_trace( - sc1, grpc_slice_from_static_string("connection one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); - validate_children(sc1, 1); - add_simple_trace(conn1); - add_simple_trace(tracer); - add_simple_trace(tracer); - grpc_channel_tracer* sc2 = GRPC_CHANNEL_TRACER_CREATE(5); - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - validate_children(tracer, 2); + sc1.AddTrace(grpc_slice_from_static_string("connection one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &conn1); + validate_children(&sc1, 1); + add_simple_trace(&conn1); + add_simple_trace(&tracer); + add_simple_trace(&tracer); + ChannelTracer sc2(5); + tracer.AddTrace(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc2); + validate_children(&tracer, 2); // this trace should not get added to the parents children since it is already // present in the tracer. - grpc_channel_tracer_add_trace( - tracer, grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_children(tracer, 2); - add_simple_trace(tracer); - - GRPC_CHANNEL_TRACER_UNREF(conn1); - GRPC_CHANNEL_TRACER_UNREF(sc1); - GRPC_CHANNEL_TRACER_UNREF(sc2); - GRPC_CHANNEL_TRACER_UNREF(tracer); + tracer.AddTrace(grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); + validate_children(&tracer, 2); + add_simple_trace(&tracer); + + conn1.Unref(); + sc1.Unref(); + sc2.Unref(); + tracer.Unref(); } int main(int argc, char** argv) { From ef043a853fdd63367ee12353f92dba2c9e3bf0f6 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 18 Jan 2018 19:38:11 -0800 Subject: [PATCH 11/67] Classify TraceNode --- src/core/lib/channel/channel_tracer.cc | 103 +++++++++++++------------ src/core/lib/channel/channel_tracer.h | 8 +- 2 files changed, 60 insertions(+), 51 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index e93fbc29d85..7f7ca7dd247 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -27,6 +27,7 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/memory.h" #include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/channel.h" @@ -37,17 +38,31 @@ namespace grpc_core { grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount( false, "channel_tracer_refcount"); -// One node of tracing data -typedef struct grpc_trace_node { - grpc_slice data; - grpc_error* error; - gpr_timespec time_created; - grpc_connectivity_state connectivity_state; - struct grpc_trace_node* next; +class TraceNode { + public: + TraceNode(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + ChannelTracer* referenced_tracer) + : data_(data), + error_(error), + connectivity_state_(connectivity_state), + next_(nullptr) { + referenced_tracer_ = referenced_tracer ? referenced_tracer->Ref() : nullptr; + time_created_ = gpr_now(GPR_CLOCK_REALTIME); + } + + private: + friend class ChannelTracer; + friend class ChannelTracerRenderer; + grpc_slice data_; + grpc_error* error_; + gpr_timespec time_created_; + grpc_connectivity_state connectivity_state_; + TraceNode* next_; // the tracer object for the (sub)channel that this trace node refers to. - ChannelTracer* referenced_tracer; -} grpc_trace_node; + ChannelTracer* referenced_tracer_; +}; ChannelTracer::ChannelTracer(size_t max_nodes) : num_nodes_logged(0), @@ -68,22 +83,22 @@ ChannelTracer* ChannelTracer::Ref() { return this; } -static void free_node(grpc_trace_node* node) { - GRPC_ERROR_UNREF(node->error); - if (node->referenced_tracer) { - node->referenced_tracer->Unref(); +void ChannelTracer::FreeNode(TraceNode* node) { + GRPC_ERROR_UNREF(node->error_); + if (node->referenced_tracer_) { + node->referenced_tracer_->Unref(); } - grpc_slice_unref_internal(node->data); + grpc_slice_unref_internal(node->data_); gpr_free(node); } void ChannelTracer::Unref() { if (gpr_unref(&refs)) { - grpc_trace_node* it = head_trace; + TraceNode* it = head_trace; while (it != nullptr) { - grpc_trace_node* to_free = it; - it = it->next; - free_node(to_free); + TraceNode* to_free = it; + it = it->next_; + FreeNode(to_free); } gpr_mu_destroy(&tracer_mu); } @@ -96,30 +111,23 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, ChannelTracer* referenced_tracer) { ++num_nodes_logged; // create and fill up the new node - grpc_trace_node* new_trace_node = - static_cast(gpr_malloc(sizeof(grpc_trace_node))); - new_trace_node->data = data; - new_trace_node->error = error; - new_trace_node->time_created = gpr_now(GPR_CLOCK_REALTIME); - new_trace_node->connectivity_state = connectivity_state; - new_trace_node->next = nullptr; - new_trace_node->referenced_tracer = - (referenced_tracer) ? referenced_tracer->Ref() : nullptr; + TraceNode* new_trace_node = + New(data, error, connectivity_state, referenced_tracer); // first node case if (head_trace == nullptr) { head_trace = tail_trace = new_trace_node; } // regular node add case else { - tail_trace->next = new_trace_node; - tail_trace = tail_trace->next; + tail_trace->next_ = new_trace_node; + tail_trace = tail_trace->next_; } ++list_size; // maybe garbage collect the end if (list_size > max_list_size) { - grpc_trace_node* to_free = head_trace; - head_trace = head_trace->next; - free_node(to_free); + TraceNode* to_free = head_trace; + head_trace = head_trace->next_; + FreeNode(to_free); --list_size; } } @@ -203,45 +211,44 @@ class ChannelTracerRenderer { void PopulateNodeList(grpc_json* nodes, grpc_json* children) { grpc_json* child = nullptr; - grpc_trace_node* it = current_tracer_->head_trace; + TraceNode* it = current_tracer_->head_trace; while (it != nullptr) { child = grpc_json_create_child(child, nodes, nullptr, nullptr, GRPC_JSON_OBJECT, false); PopulateNode(it, child, children); - it = it->next; + it = it->next_; } } - void PopulateNode(grpc_trace_node* node, grpc_json* json, - grpc_json* children) { + void PopulateNode(TraceNode* node, grpc_json* json, grpc_json* children) { grpc_json* child = nullptr; child = grpc_json_create_child(child, json, "data", - grpc_slice_to_c_string(node->data), + grpc_slice_to_c_string(node->data_), GRPC_JSON_STRING, true); - if (node->error != GRPC_ERROR_NONE) { - child = grpc_json_create_child(child, json, "error", - gpr_strdup(grpc_error_string(node->error)), - GRPC_JSON_STRING, true); + if (node->error_ != GRPC_ERROR_NONE) { + child = grpc_json_create_child( + child, json, "error", gpr_strdup(grpc_error_string(node->error_)), + GRPC_JSON_STRING, true); } child = grpc_json_create_child(child, json, "time", - fmt_time(node->time_created), + fmt_time(node->time_created_), GRPC_JSON_STRING, true); child = grpc_json_create_child( child, json, "state", - grpc_connectivity_state_name(node->connectivity_state), + grpc_connectivity_state_name(node->connectivity_state_), GRPC_JSON_STRING, false); - if (node->referenced_tracer != nullptr) { + if (node->referenced_tracer_ != nullptr) { char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, - node->referenced_tracer->channel_uuid); + node->referenced_tracer_->channel_uuid); child = grpc_json_create_child(child, json, "uuid", uuid_str, GRPC_JSON_NUMBER, true); - if (children && !TracerAlreadySeen(node->referenced_tracer)) { + if (children && !TracerAlreadySeen(node->referenced_tracer_)) { grpc_json* referenced_tracer = grpc_json_create_child( nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); - AddSeenTracer(node->referenced_tracer); + AddSeenTracer(node->referenced_tracer_); ChannelTracer* saved = current_tracer_; - current_tracer_ = node->referenced_tracer; + current_tracer_ = node->referenced_tracer_; RecursivelyPopulateJson(referenced_tracer); current_tracer_ = saved; } diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 6b7d719028c..b499f8dd7bf 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -27,7 +27,7 @@ namespace grpc_core { extern grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount; -typedef struct grpc_trace_node grpc_trace_node; +class TraceNode; class ChannelTracer { public: @@ -57,6 +57,8 @@ class ChannelTracer { static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); private: + void FreeNode(TraceNode* node); + friend class ChannelTracerRenderer; gpr_refcount refs; gpr_mu tracer_mu; @@ -64,8 +66,8 @@ class ChannelTracer { uint64_t num_nodes_logged; size_t list_size; size_t max_list_size; - grpc_trace_node* head_trace; - grpc_trace_node* tail_trace; + TraceNode* head_trace; + TraceNode* tail_trace; gpr_timespec time_created; }; From 99c7efdedbc13fa00384726c4078754af362454d Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 18 Jan 2018 23:14:09 -0800 Subject: [PATCH 12/67] Good C++ style --- src/core/lib/channel/channel_tracer.cc | 63 ++++++++++++-------------- src/core/lib/channel/channel_tracer.h | 20 ++++---- 2 files changed, 39 insertions(+), 44 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 7f7ca7dd247..54f66dd5ac0 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -35,9 +35,6 @@ namespace grpc_core { -grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount( - false, "channel_tracer_refcount"); - class TraceNode { public: TraceNode(grpc_slice data, grpc_error* error, @@ -65,21 +62,21 @@ class TraceNode { }; ChannelTracer::ChannelTracer(size_t max_nodes) - : num_nodes_logged(0), - list_size(0), - max_list_size(max_nodes), - head_trace(0), - tail_trace(0) { - gpr_mu_init(&tracer_mu); - gpr_ref_init(&refs, 1); - channel_uuid = grpc_object_registry_register_object( + : num_nodes_logged_(0), + list_size_(0), + max_list_size_(max_nodes), + head_trace_(0), + tail_trace_(0) { + gpr_mu_init(&tracer_mu_); + gpr_ref_init(&refs_, 1); + channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - max_list_size = max_nodes; - time_created = gpr_now(GPR_CLOCK_REALTIME); + max_list_size_ = max_nodes; + time_created_ = gpr_now(GPR_CLOCK_REALTIME); } ChannelTracer* ChannelTracer::Ref() { - gpr_ref(&refs); + gpr_ref(&refs_); return this; } @@ -93,42 +90,42 @@ void ChannelTracer::FreeNode(TraceNode* node) { } void ChannelTracer::Unref() { - if (gpr_unref(&refs)) { - TraceNode* it = head_trace; + if (gpr_unref(&refs_)) { + TraceNode* it = head_trace_; while (it != nullptr) { TraceNode* to_free = it; it = it->next_; FreeNode(to_free); } - gpr_mu_destroy(&tracer_mu); + gpr_mu_destroy(&tracer_mu_); } } -intptr_t ChannelTracer::GetUuid() { return channel_uuid; } +intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, ChannelTracer* referenced_tracer) { - ++num_nodes_logged; + ++num_nodes_logged_; // create and fill up the new node TraceNode* new_trace_node = New(data, error, connectivity_state, referenced_tracer); // first node case - if (head_trace == nullptr) { - head_trace = tail_trace = new_trace_node; + if (head_trace_ == nullptr) { + head_trace_ = tail_trace_ = new_trace_node; } // regular node add case else { - tail_trace->next_ = new_trace_node; - tail_trace = tail_trace->next_; + tail_trace_->next_ = new_trace_node; + tail_trace_ = tail_trace_->next_; } - ++list_size; + ++list_size_; // maybe garbage collect the end - if (list_size > max_list_size) { - TraceNode* to_free = head_trace; - head_trace = head_trace->next_; + if (list_size_ > max_list_size_) { + TraceNode* to_free = head_trace_; + head_trace_ = head_trace_->next_; FreeNode(to_free); - --list_size; + --list_size_; } } @@ -192,17 +189,17 @@ class ChannelTracerRenderer { grpc_json* child = nullptr; char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid); + gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid_); child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, GRPC_JSON_NUMBER, true); char* num_nodes_logged_str; gpr_asprintf(&num_nodes_logged_str, "%" PRId64, - current_tracer_->num_nodes_logged); + current_tracer_->num_nodes_logged_); child = grpc_json_create_child(child, channel_data, "numNodesLogged", num_nodes_logged_str, GRPC_JSON_NUMBER, true); child = grpc_json_create_child(child, channel_data, "startTime", - fmt_time(current_tracer_->time_created), + fmt_time(current_tracer_->time_created_), GRPC_JSON_STRING, true); child = grpc_json_create_child(child, channel_data, "nodes", nullptr, GRPC_JSON_ARRAY, false); @@ -211,7 +208,7 @@ class ChannelTracerRenderer { void PopulateNodeList(grpc_json* nodes, grpc_json* children) { grpc_json* child = nullptr; - TraceNode* it = current_tracer_->head_trace; + TraceNode* it = current_tracer_->head_trace_; while (it != nullptr) { child = grpc_json_create_child(child, nodes, nullptr, nullptr, GRPC_JSON_OBJECT, false); @@ -240,7 +237,7 @@ class ChannelTracerRenderer { if (node->referenced_tracer_ != nullptr) { char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, - node->referenced_tracer_->channel_uuid); + node->referenced_tracer_->channel_uuid_); child = grpc_json_create_child(child, json, "uuid", uuid_str, GRPC_JSON_NUMBER, true); if (children && !TracerAlreadySeen(node->referenced_tracer_)) { diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index b499f8dd7bf..cbc4f84af1c 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -25,8 +25,6 @@ namespace grpc_core { -extern grpc_core::DebugOnlyTraceFlag grpc_trace_channel_tracer_refcount; - class TraceNode; class ChannelTracer { @@ -60,15 +58,15 @@ class ChannelTracer { void FreeNode(TraceNode* node); friend class ChannelTracerRenderer; - gpr_refcount refs; - gpr_mu tracer_mu; - intptr_t channel_uuid; - uint64_t num_nodes_logged; - size_t list_size; - size_t max_list_size; - TraceNode* head_trace; - TraceNode* tail_trace; - gpr_timespec time_created; + gpr_refcount refs_; + gpr_mu tracer_mu_; + intptr_t channel_uuid_; + uint64_t num_nodes_logged_; + size_t list_size_; + size_t max_list_size_; + TraceNode* head_trace_; + TraceNode* tail_trace_; + gpr_timespec time_created_; }; } // namespace grpc_core From 9f144ebf5b5e708ca04644f63da3a8271766ed4c Mon Sep 17 00:00:00 2001 From: ncteisen Date: Sat, 20 Jan 2018 10:08:06 -0800 Subject: [PATCH 13/67] s/TraceNode/TraceEvent and make it a struct --- src/core/lib/channel/channel_tracer.cc | 32 +++++++++++--------------- src/core/lib/channel/channel_tracer.h | 8 +++---- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 54f66dd5ac0..bb8ba969eae 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -35,11 +35,10 @@ namespace grpc_core { -class TraceNode { - public: - TraceNode(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - ChannelTracer* referenced_tracer) +struct TraceEvent { + TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + ChannelTracer* referenced_tracer) : data_(data), error_(error), connectivity_state_(connectivity_state), @@ -47,16 +46,11 @@ class TraceNode { referenced_tracer_ = referenced_tracer ? referenced_tracer->Ref() : nullptr; time_created_ = gpr_now(GPR_CLOCK_REALTIME); } - - private: - friend class ChannelTracer; - friend class ChannelTracerRenderer; grpc_slice data_; grpc_error* error_; gpr_timespec time_created_; grpc_connectivity_state connectivity_state_; - TraceNode* next_; - + TraceEvent* next_; // the tracer object for the (sub)channel that this trace node refers to. ChannelTracer* referenced_tracer_; }; @@ -80,7 +74,7 @@ ChannelTracer* ChannelTracer::Ref() { return this; } -void ChannelTracer::FreeNode(TraceNode* node) { +void ChannelTracer::FreeNode(TraceEvent* node) { GRPC_ERROR_UNREF(node->error_); if (node->referenced_tracer_) { node->referenced_tracer_->Unref(); @@ -91,9 +85,9 @@ void ChannelTracer::FreeNode(TraceNode* node) { void ChannelTracer::Unref() { if (gpr_unref(&refs_)) { - TraceNode* it = head_trace_; + TraceEvent* it = head_trace_; while (it != nullptr) { - TraceNode* to_free = it; + TraceEvent* to_free = it; it = it->next_; FreeNode(to_free); } @@ -108,8 +102,8 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, ChannelTracer* referenced_tracer) { ++num_nodes_logged_; // create and fill up the new node - TraceNode* new_trace_node = - New(data, error, connectivity_state, referenced_tracer); + TraceEvent* new_trace_node = + New(data, error, connectivity_state, referenced_tracer); // first node case if (head_trace_ == nullptr) { head_trace_ = tail_trace_ = new_trace_node; @@ -122,7 +116,7 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, ++list_size_; // maybe garbage collect the end if (list_size_ > max_list_size_) { - TraceNode* to_free = head_trace_; + TraceEvent* to_free = head_trace_; head_trace_ = head_trace_->next_; FreeNode(to_free); --list_size_; @@ -208,7 +202,7 @@ class ChannelTracerRenderer { void PopulateNodeList(grpc_json* nodes, grpc_json* children) { grpc_json* child = nullptr; - TraceNode* it = current_tracer_->head_trace_; + TraceEvent* it = current_tracer_->head_trace_; while (it != nullptr) { child = grpc_json_create_child(child, nodes, nullptr, nullptr, GRPC_JSON_OBJECT, false); @@ -217,7 +211,7 @@ class ChannelTracerRenderer { } } - void PopulateNode(TraceNode* node, grpc_json* json, grpc_json* children) { + void PopulateNode(TraceEvent* node, grpc_json* json, grpc_json* children) { grpc_json* child = nullptr; child = grpc_json_create_child(child, json, "data", grpc_slice_to_c_string(node->data_), diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index cbc4f84af1c..2c2554ec9bf 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -25,7 +25,7 @@ namespace grpc_core { -class TraceNode; +struct TraceEvent; class ChannelTracer { public: @@ -55,7 +55,7 @@ class ChannelTracer { static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); private: - void FreeNode(TraceNode* node); + void FreeNode(TraceEvent* node); friend class ChannelTracerRenderer; gpr_refcount refs_; @@ -64,8 +64,8 @@ class ChannelTracer { uint64_t num_nodes_logged_; size_t list_size_; size_t max_list_size_; - TraceNode* head_trace_; - TraceNode* tail_trace_; + TraceEvent* head_trace_; + TraceEvent* tail_trace_; gpr_timespec time_created_; }; From f41e24b35fe9fd79c20531cf9a51281b47733ce2 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Sat, 20 Jan 2018 11:40:12 -0800 Subject: [PATCH 14/67] Remove uuid from channel --- src/core/lib/surface/channel.cc | 5 ----- src/core/lib/surface/channel.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e80c36465e4..12b920a2c40 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -54,7 +54,6 @@ typedef struct registered_call { } registered_call; struct grpc_channel { - intptr_t uuid; int is_client; grpc_compression_options compression_options; grpc_mdelem default_authority; @@ -104,7 +103,6 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - channel->uuid = -1; channel->tracer = nullptr; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -205,7 +203,6 @@ grpc_channel* grpc_channel_create_with_builder( if (max_nodes > 0) { channel->tracer = grpc_core::New( max_nodes); // TODO(ncteisen): leaky yo - channel->uuid = channel->tracer->GetUuid(); } } } @@ -220,8 +217,6 @@ char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { return channel->tracer ? channel->tracer->RenderTrace(recursive) : nullptr; } -intptr_t grpc_channel_get_uuid(grpc_channel* channel) { return channel->uuid; } - grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 507013f4529..5820bbbd80d 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -59,7 +59,6 @@ size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); -intptr_t grpc_channel_get_uuid(grpc_channel* channel); #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); From 6f196afc9ea527adf8c81cc7cf7e151e20e32116 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Sat, 20 Jan 2018 11:50:08 -0800 Subject: [PATCH 15/67] Switch to use manual constructor --- src/core/lib/channel/channel_tracer.cc | 8 +++++++- src/core/lib/surface/channel.cc | 15 +++++++-------- test/core/channel/channel_tracer_test.cc | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index bb8ba969eae..df0e56d19a5 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -56,11 +56,13 @@ struct TraceEvent { }; ChannelTracer::ChannelTracer(size_t max_nodes) - : num_nodes_logged_(0), + : channel_uuid_(-1), + num_nodes_logged_(0), list_size_(0), max_list_size_(max_nodes), head_trace_(0), tail_trace_(0) { + if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 gpr_mu_init(&tracer_mu_); gpr_ref_init(&refs_, 1); channel_uuid_ = grpc_object_registry_register_object( @@ -70,6 +72,7 @@ ChannelTracer::ChannelTracer(size_t max_nodes) } ChannelTracer* ChannelTracer::Ref() { + if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 gpr_ref(&refs_); return this; } @@ -84,6 +87,7 @@ void ChannelTracer::FreeNode(TraceEvent* node) { } void ChannelTracer::Unref() { + if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 if (gpr_unref(&refs_)) { TraceEvent* it = head_trace_; while (it != nullptr) { @@ -100,6 +104,7 @@ intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, ChannelTracer* referenced_tracer) { + if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 ++num_nodes_logged_; // create and fill up the new node TraceEvent* new_trace_node = @@ -254,6 +259,7 @@ class ChannelTracerRenderer { }; char* ChannelTracer::RenderTrace(bool recursive) { + if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 ChannelTracerRenderer renderer(this, recursive); return renderer.Run(); } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 12b920a2c40..5d36e5b313b 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,6 +32,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/support/manual_constructor.h" #include "src/core/lib/support/memory.h" #include "src/core/lib/support/object_registry.h" #include "src/core/lib/support/string.h" @@ -63,7 +64,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::ChannelTracer* tracer; + grpc_core::ManualConstructor tracer; char* target; }; @@ -103,7 +104,7 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - channel->tracer = nullptr; + bool tracer_initialized = false; gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -195,15 +196,13 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(channel->tracer == nullptr); + GPR_ASSERT(!tracer_initialized); + tracer_initialized = true; // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); - if (max_nodes > 0) { - channel->tracer = grpc_core::New( - max_nodes); // TODO(ncteisen): leaky yo - } + channel->tracer.Init(max_nodes); } } @@ -214,7 +213,7 @@ grpc_channel* grpc_channel_create_with_builder( } char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { - return channel->tracer ? channel->tracer->RenderTrace(recursive) : nullptr; + return channel->tracer->RenderTrace(recursive); } grpc_channel* grpc_channel_create(const char* target, diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 131ea567fc9..c1c9e5b57f5 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -41,6 +41,7 @@ static void add_simple_trace(ChannelTracer* tracer) { static void validate_tracer(ChannelTracer* tracer, size_t expected_num_nodes_logged, size_t max_nodes) { + if (!max_nodes) return; char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); validate_channel_data(json, expected_num_nodes_logged, @@ -51,6 +52,7 @@ static void validate_tracer(ChannelTracer* tracer, static void validate_tracer_data_matches_uuid_lookup(ChannelTracer* tracer) { intptr_t uuid = tracer->GetUuid(); + if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled char* tracer_json_str = tracer->RenderTrace(true); char* uuid_lookup_json_str = ChannelTracer::GetChannelTraceFromUuid(uuid, true); From dedc4a0cbda96b41b9b2d7ac77c1bf967ca7d540 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 22 Jan 2018 19:35:27 -0800 Subject: [PATCH 16/67] Reviewer feedback --- .../ext/filters/client_channel/subchannel.cc | 4 +- src/core/lib/channel/channel_tracer.cc | 63 ++++++++++++++++++- src/core/lib/channel/channel_tracer.h | 5 +- src/core/lib/support/object_registry.h | 5 ++ test/core/channel/channel_tracer_test.cc | 14 +++++ 5 files changed, 84 insertions(+), 7 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 0310f152cce..bb6ba5fc27f 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -79,7 +79,6 @@ typedef struct external_state_watcher { } external_state_watcher; struct grpc_subchannel { - intptr_t uuid; grpc_connector* connector; /** refcount @@ -137,7 +136,7 @@ struct grpc_subchannel { /** our alarm */ grpc_timer alarm; - grpc_core::ChannelTracer* tracer; + grpc_core::ManualConstructor tracer; }; struct grpc_subchannel_call { @@ -344,7 +343,6 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(); c = (grpc_subchannel*)gpr_zalloc(sizeof(*c)); - c->uuid = -1; c->key = key; gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS); c->connector = connector; diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index df0e56d19a5..e03dd27675e 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -35,7 +35,8 @@ namespace grpc_core { -struct TraceEvent { +class TraceEvent { + public: TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, ChannelTracer* referenced_tracer) @@ -46,6 +47,10 @@ struct TraceEvent { referenced_tracer_ = referenced_tracer ? referenced_tracer->Ref() : nullptr; time_created_ = gpr_now(GPR_CLOCK_REALTIME); } + + private: + friend class ChannelTracer; + friend class ChannelTracerRenderer; grpc_slice data_; grpc_error* error_; gpr_timespec time_created_; @@ -138,8 +143,50 @@ static char* fmt_time(gpr_timespec tm) { return full_time_str; } +// Helper class that is responsible for walking the tree of ChannelTracer +// objects and rendering the trace as JSON according to: +// https://github.com/grpc/proposal/pull/7 + +// The rendered JSON should be of this format: +// { +// "channelData": { +// "numNodesLogged": number, +// "startTime": timestamp string, +// "nodes": [ +// { +// "uuid": string, +// "data": string, +// "error": string, +// "time": timestamp string, +// // can only be one of the states in connectivity_state.h +// "state": enum string, +// // uuid of referenced subchannel +// "subchannel_uuid": string +// }, +// ] +// }, +// "numSubchannelsSeen": number, +// "subchannelData": [ +// { +// "uuid": string, +// "numNodesLogged": number, +// "startTime": timestamp string, +// "nodes": [ +// { +// "data": string, +// "error": string, +// "time": timestamp string, +// "state": enum string, +// }, +// ] +// }, +// ] +// } + class ChannelTracerRenderer { public: + // If recursive==true, then the entire tree of trace will be rendered. + // If not, then only the top level data will be. ChannelTracerRenderer(ChannelTracer* tracer, bool recursive) : current_tracer_(tracer), recursive_(recursive), @@ -147,17 +194,20 @@ class ChannelTracerRenderer { size_(0), cap_(0) {} + // Renders the trace and returns an allocated char* with the formatted JSON char* Run() { grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); AddSeenTracer(current_tracer_); RecursivelyPopulateJson(json); gpr_free(seen_tracers_); - char* json_str = grpc_json_dump_to_string(json, 1); + char* json_str = grpc_json_dump_to_string(json, 0); grpc_json_destroy(json); return json_str; } private: + // tracks that a tracer has already been rendered to avoid infinite + // recursion. void AddSeenTracer(ChannelTracer* newly_seen) { if (size_ >= cap_) { cap_ = GPR_MAX(5 * sizeof(newly_seen), 3 * cap_ / 2); @@ -166,6 +216,7 @@ class ChannelTracerRenderer { seen_tracers_[size_++] = newly_seen; } + // Checks if a tracer has already been seen. bool TracerAlreadySeen(ChannelTracer* tracer) { for (size_t i = 0; i < size_; ++i) { if (seen_tracers_[i] == tracer) return true; @@ -173,6 +224,8 @@ class ChannelTracerRenderer { return false; } + // Recursively fills up json by walking over all of the trace of + // current_tracer_. void RecursivelyPopulateJson(grpc_json* json) { grpc_json* channel_data = grpc_json_create_child( nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); @@ -251,8 +304,14 @@ class ChannelTracerRenderer { } } + // Tracks the current tracer we are rendering as we walk the tree of tracers. ChannelTracer* current_tracer_; + + // If true, we will render the data of all of this tracer's children. bool recursive_; + + // These members are used to track tracers we have already rendered. This is + // a dynamically growing array that is deallocated when the rendering is done. ChannelTracer** seen_tracers_; size_t size_; size_t cap_; diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 2c2554ec9bf..c2d8c1071a2 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -25,7 +25,7 @@ namespace grpc_core { -struct TraceEvent; +class TraceEvent; class ChannelTracer { public: @@ -51,10 +51,11 @@ class ChannelTracer { char* RenderTrace(bool recursive); /* util functions that perform the uuid -> tracer step for you, and then - returns the trace for the uuid given. */ + returns the trace for the uuid given. */ static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); private: + // Internal helper that frees a TraceEvent. void FreeNode(TraceEvent* node); friend class ChannelTracerRenderer; diff --git a/src/core/lib/support/object_registry.h b/src/core/lib/support/object_registry.h index 1b8e13d054a..cc8fc6d878b 100644 --- a/src/core/lib/support/object_registry.h +++ b/src/core/lib/support/object_registry.h @@ -21,8 +21,13 @@ #include +// Different types that may be stored in the general object registry typedef enum { + // Used to hold uuid -> ChannelTracer mappings to allow for the trace data + // to be looked up by uuid, rather then have to walk the entire tree of + // trace. GRPC_OBJECT_REGISTRY_CHANNEL_TRACER, + // Usually represents an error has occurred in the object lookup. GRPC_OBJECT_REGISTRY_UNKNOWN, } grpc_object_registry_type; diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index c1c9e5b57f5..c0ef2a4459e 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -71,6 +71,8 @@ static void validate_children(ChannelTracer* tracer, gpr_free(json_str); } +// Tests basic ChannelTracer functionality like construction, adding trace, and +// lookups by uuid. static void test_basic_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; ChannelTracer tracer(max_nodes); @@ -97,6 +99,8 @@ static void test_basic_channel_tracing(size_t max_nodes) { tracer.Unref(); } +// Calls basic test with various values for max_nodes (including 0, which turns +// the tracer off). static void test_basic_channel_sizing() { test_basic_channel_tracing(0); test_basic_channel_tracing(1); @@ -106,6 +110,9 @@ static void test_basic_channel_sizing() { test_basic_channel_tracing(15); } +// Tests more complex functionality, like a parent channel tracking +// subchannles. This exercises the ref/unref patterns since the parent tracer +// and this function will both hold refs to the subchannel. static void test_complex_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; ChannelTracer tracer(max_nodes); @@ -145,6 +152,7 @@ static void test_complex_channel_tracing(size_t max_nodes) { tracer.Unref(); } +// Calls the complex test with a sweep of sizes for max_nodes. static void test_complex_channel_sizing() { test_complex_channel_tracing(0); test_complex_channel_tracing(1); @@ -154,6 +162,9 @@ static void test_complex_channel_sizing() { test_complex_channel_tracing(15); } +// Tests edge case in which the parent channel tracer is destroyed before the +// subchannel. Not sure if it is a realistic scenario, but the refcounting +// balance should still hold. static void test_delete_parent_first() { grpc_core::ExecCtx exec_ctx; ChannelTracer tracer(3); @@ -167,6 +178,9 @@ static void test_delete_parent_first() { sc1.Unref(); } +// Test a case in which the parent channel has subchannels and the subchannels +// have connections. Ensures that everything lives as long as it should then +// gets deleted. static void test_nesting() { grpc_core::ExecCtx exec_ctx; ChannelTracer tracer(10); From 90a00f8db60e5a0bbcdf1f0111b7f3ff60579016 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 08:33:59 -0800 Subject: [PATCH 17/67] Reviewer feedback; comments --- src/core/lib/channel/channel_tracer.cc | 50 +++++++++++++----------- src/core/lib/channel/channel_tracer.h | 1 + test/core/channel/channel_tracer_test.cc | 4 +- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index e03dd27675e..f08fb83fb95 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -63,6 +63,7 @@ class TraceEvent { ChannelTracer::ChannelTracer(size_t max_nodes) : channel_uuid_(-1), num_nodes_logged_(0), + num_children_seen_(0), list_size_(0), max_list_size_(max_nodes), head_trace_(0), @@ -111,6 +112,7 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, ChannelTracer* referenced_tracer) { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 ++num_nodes_logged_; + if (referenced_tracer != nullptr) ++num_children_seen_; // create and fill up the new node TraceEvent* new_trace_node = New(data, error, connectivity_state, referenced_tracer); @@ -150,36 +152,27 @@ static char* fmt_time(gpr_timespec tm) { // The rendered JSON should be of this format: // { // "channelData": { +// "uuid": string, // "numNodesLogged": number, // "startTime": timestamp string, // "nodes": [ // { -// "uuid": string, // "data": string, // "error": string, // "time": timestamp string, // // can only be one of the states in connectivity_state.h // "state": enum string, -// // uuid of referenced subchannel -// "subchannel_uuid": string +// // uuid of referenced subchannel. +// // Optional, only present if this event refers to a child object. +// // and example of a referenced child would be a trace event for a +// // subchannel being created. +// "child_uuid": string // }, // ] // }, -// "numSubchannelsSeen": number, -// "subchannelData": [ -// { -// "uuid": string, -// "numNodesLogged": number, -// "startTime": timestamp string, -// "nodes": [ -// { -// "data": string, -// "error": string, -// "time": timestamp string, -// "state": enum string, -// }, -// ] -// }, +// // Optional, only present if this channel has children +// "childData": [ +// // List of child data, which is of the exact same format as the // ] // } @@ -225,19 +218,22 @@ class ChannelTracerRenderer { } // Recursively fills up json by walking over all of the trace of - // current_tracer_. + // current_tracer_. Starts at the top level, by creating the fields + // channelData, and childData. void RecursivelyPopulateJson(grpc_json* json) { grpc_json* channel_data = grpc_json_create_child( nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); grpc_json* children = nullptr; if (recursive_) { - children = grpc_json_create_child(channel_data, json, "children", nullptr, - GRPC_JSON_ARRAY, false); + children = grpc_json_create_child(channel_data, json, "childData", + nullptr, GRPC_JSON_ARRAY, false); } - PopulateTracer(channel_data, children); + PopulateChannelData(channel_data, children); } - void PopulateTracer(grpc_json* channel_data, grpc_json* children) { + // Fills up the channelData object. If children is not null, it will + // recursively populate each referenced child as it passes that node. + void PopulateChannelData(grpc_json* channel_data, grpc_json* children) { grpc_json* child = nullptr; char* uuid_str; @@ -258,6 +254,7 @@ class ChannelTracerRenderer { PopulateNodeList(child, children); } + // Iterated over the list of TraceEvents and populates their data. void PopulateNodeList(grpc_json* nodes, grpc_json* children) { grpc_json* child = nullptr; TraceEvent* it = current_tracer_->head_trace_; @@ -269,6 +266,9 @@ class ChannelTracerRenderer { } } + // Fills in all the data for a single TraceEvent. If children is not null + // and the TraceEvent refers to a child Tracer object and recursive_ is true, + // then that child object will be rendered into the trace. void PopulateNode(TraceEvent* node, grpc_json* json, grpc_json* children) { grpc_json* child = nullptr; child = grpc_json_create_child(child, json, "data", @@ -292,6 +292,10 @@ class ChannelTracerRenderer { node->referenced_tracer_->channel_uuid_); child = grpc_json_create_child(child, json, "uuid", uuid_str, GRPC_JSON_NUMBER, true); + + // If we are recursively populating everything, and this node + // references a tracer we haven't seen yet, we render that tracer + // in full, adding it to the parent JSON's "children" field. if (children && !TracerAlreadySeen(node->referenced_tracer_)) { grpc_json* referenced_tracer = grpc_json_create_child( nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index c2d8c1071a2..42f6e5ccb85 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -63,6 +63,7 @@ class ChannelTracer { gpr_mu tracer_mu_; intptr_t channel_uuid_; uint64_t num_nodes_logged_; + uint64_t num_children_seen_; size_t list_size_; size_t max_list_size_; TraceEvent* head_trace_; diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index c0ef2a4459e..7f0efb34b18 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -66,7 +66,7 @@ static void validate_children(ChannelTracer* tracer, size_t expected_num_children) { char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); - validate_json_array_size(json, "children", expected_num_children); + validate_json_array_size(json, "childData", expected_num_children); grpc_json_destroy(json); gpr_free(json_str); } @@ -146,7 +146,7 @@ static void test_complex_channel_tracing(size_t max_nodes) { add_simple_trace(&tracer); add_simple_trace(&tracer); add_simple_trace(&tracer); - // validate_tracer_data_matches_uuid_lookup(&tracer); + validate_tracer_data_matches_uuid_lookup(&tracer); sc1.Unref(); sc2.Unref(); tracer.Unref(); From 34ebf5dd9eea03be7f744ea456cbd4acd950da86 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 09:10:14 -0800 Subject: [PATCH 18/67] Move object registry out of gpr --- BUILD | 2 ++ CMakeLists.txt | 7 ++++++- Makefile | 7 ++++++- build.yaml | 4 ++-- config.m4 | 2 +- config.w32 | 2 +- gRPC-Core.podspec | 6 +++--- grpc.gemspec | 4 ++-- grpc.gyp | 5 ++++- package.xml | 4 ++-- src/core/ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_tracer.cc | 3 ++- src/core/lib/{gpr => channel}/object_registry.cc | 2 +- src/core/lib/{gpr => channel}/object_registry.h | 0 src/core/lib/surface/channel.cc | 2 +- src/core/lib/surface/init.cc | 2 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 ++-- tools/run_tests/generated/sources_and_headers.json | 6 +++--- 20 files changed, 42 insertions(+), 26 deletions(-) rename src/core/lib/{gpr => channel}/object_registry.cc (98%) rename src/core/lib/{gpr => channel}/object_registry.h (100%) diff --git a/BUILD b/BUILD index 30b0488dc32..1df5df7f3d8 100644 --- a/BUILD +++ b/BUILD @@ -626,6 +626,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack_builder.cc", "src/core/lib/channel/channel_tracer.cc", "src/core/lib/channel/connected_channel.cc", + "src/core/lib/channel/object_registry.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", @@ -762,6 +763,7 @@ grpc_cc_library( "src/core/lib/channel/channel_tracer.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", + "src/core/lib/channel/object_registry.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 1057ade8ec5..91aca47ddf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -645,7 +645,6 @@ add_library(gpr src/core/lib/gpr/log_windows.cc src/core/lib/gpr/mpscq.cc src/core/lib/gpr/murmur_hash.cc - src/core/lib/gpr/object_registry.cc src/core/lib/gpr/string.cc src/core/lib/gpr/string_posix.cc src/core/lib/gpr/string_util_windows.cc @@ -803,6 +802,7 @@ add_library(grpc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1144,6 +1144,7 @@ add_library(grpc_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1469,6 +1470,7 @@ add_library(grpc_test_util src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1738,6 +1740,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -1989,6 +1992,7 @@ add_library(grpc_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc @@ -2728,6 +2732,7 @@ add_library(grpc++_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/message_compress.cc src/core/lib/compression/stream_compression.cc diff --git a/Makefile b/Makefile index eddd3ad6dcd..69b1ed70cbe 100644 --- a/Makefile +++ b/Makefile @@ -2865,7 +2865,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/log_windows.cc \ src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/murmur_hash.cc \ - src/core/lib/gpr/object_registry.cc \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ @@ -3004,6 +3003,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -3347,6 +3347,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -3673,6 +3674,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -3935,6 +3937,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -4166,6 +4169,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ @@ -4898,6 +4902,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ diff --git a/build.yaml b/build.yaml index 29483845963..fc647009702 100644 --- a/build.yaml +++ b/build.yaml @@ -47,7 +47,6 @@ filegroups: - src/core/lib/gpr/log_windows.cc - src/core/lib/gpr/mpscq.cc - src/core/lib/gpr/murmur_hash.cc - - src/core/lib/gpr/object_registry.cc - src/core/lib/gpr/string.cc - src/core/lib/gpr/string_posix.cc - src/core/lib/gpr/string_util_windows.cc @@ -107,7 +106,6 @@ filegroups: - src/core/lib/gpr/fork.h - src/core/lib/gpr/mpscq.h - src/core/lib/gpr/murmur_hash.h - - src/core/lib/gpr/object_registry.h - src/core/lib/gpr/spinlock.h - src/core/lib/gpr/string.h - src/core/lib/gpr/string_windows.h @@ -161,6 +159,7 @@ filegroups: - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc + - src/core/lib/channel/object_registry.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/message_compress.cc - src/core/lib/compression/stream_compression.cc @@ -318,6 +317,7 @@ filegroups: - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h + - src/core/lib/channel/object_registry.cc - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/message_compress.h - src/core/lib/compression/stream_compression.h diff --git a/config.m4 b/config.m4 index b030b37438d..8a6ccc8d0d3 100644 --- a/config.m4 +++ b/config.m4 @@ -60,7 +60,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/log_windows.cc \ src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/murmur_hash.cc \ - src/core/lib/gpr/object_registry.cc \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ @@ -94,6 +93,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ src/core/lib/compression/stream_compression.cc \ diff --git a/config.w32 b/config.w32 index 838e17ae815..42a47fca152 100644 --- a/config.w32 +++ b/config.w32 @@ -37,7 +37,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\log_windows.cc " + "src\\core\\lib\\gpr\\mpscq.cc " + "src\\core\\lib\\gpr\\murmur_hash.cc " + - "src\\core\\lib\\gpr\\object_registry.cc " + "src\\core\\lib\\gpr\\string.cc " + "src\\core\\lib\\gpr\\string_posix.cc " + "src\\core\\lib\\gpr\\string_util_windows.cc " + @@ -71,6 +70,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + + "src\\core\\lib\\channel\\object_registry.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\message_compress.cc " + "src\\core\\lib\\compression\\stream_compression.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 21e39af0727..8c4ae86bc46 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -197,7 +197,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', - 'src/core/lib/gpr/object_registry.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', 'src/core/lib/gpr/string_windows.h', @@ -232,7 +231,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/log_windows.cc', 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/object_registry.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', @@ -340,6 +338,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', @@ -482,6 +481,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -727,7 +727,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/fork.h', 'src/core/lib/gpr/mpscq.h', 'src/core/lib/gpr/murmur_hash.h', - 'src/core/lib/gpr/object_registry.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', 'src/core/lib/gpr/string_windows.h', @@ -825,6 +824,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', diff --git a/grpc.gemspec b/grpc.gemspec index 085b093c8ed..9d2b4a94b10 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -88,7 +88,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/fork.h ) s.files += %w( src/core/lib/gpr/mpscq.h ) s.files += %w( src/core/lib/gpr/murmur_hash.h ) - s.files += %w( src/core/lib/gpr/object_registry.h ) s.files += %w( src/core/lib/gpr/spinlock.h ) s.files += %w( src/core/lib/gpr/string.h ) s.files += %w( src/core/lib/gpr/string_windows.h ) @@ -123,7 +122,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/log_windows.cc ) s.files += %w( src/core/lib/gpr/mpscq.cc ) s.files += %w( src/core/lib/gpr/murmur_hash.cc ) - s.files += %w( src/core/lib/gpr/object_registry.cc ) s.files += %w( src/core/lib/gpr/string.cc ) s.files += %w( src/core/lib/gpr/string_posix.cc ) s.files += %w( src/core/lib/gpr/string_util_windows.cc ) @@ -266,6 +264,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) + s.files += %w( src/core/lib/channel/object_registry.cc ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/message_compress.h ) s.files += %w( src/core/lib/compression/stream_compression.h ) @@ -412,6 +411,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) + s.files += %w( src/core/lib/channel/object_registry.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) s.files += %w( src/core/lib/compression/stream_compression.cc ) diff --git a/grpc.gyp b/grpc.gyp index 324f65215f1..43f7724ab40 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -182,7 +182,6 @@ 'src/core/lib/gpr/log_windows.cc', 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/object_registry.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', @@ -235,6 +234,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -531,6 +531,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -745,6 +746,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', @@ -940,6 +942,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', diff --git a/package.xml b/package.xml index 00b54d3dc12..98c2707e0f8 100644 --- a/package.xml +++ b/package.xml @@ -95,7 +95,6 @@ - @@ -130,7 +129,6 @@ - @@ -273,6 +271,7 @@ + @@ -419,6 +418,7 @@ + diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 32cc5fff6b2..51fe70304b4 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -37,8 +37,8 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_tracer.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/object_registry.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/sockaddr_utils.h" diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index bdad3c6067a..0a375074ef3 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -17,6 +17,7 @@ */ #include "src/core/lib/channel/channel_tracer.h" + #include #include #include @@ -25,7 +26,7 @@ #include #include -#include "src/core/lib/gpr/object_registry.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/iomgr/error.h" diff --git a/src/core/lib/gpr/object_registry.cc b/src/core/lib/channel/object_registry.cc similarity index 98% rename from src/core/lib/gpr/object_registry.cc rename to src/core/lib/channel/object_registry.cc index 5c9e5416c2b..550bb6f788a 100644 --- a/src/core/lib/gpr/object_registry.cc +++ b/src/core/lib/channel/object_registry.cc @@ -16,7 +16,7 @@ * */ -#include "src/core/lib/gpr/object_registry.h" +#include "src/core/lib/channel/object_registry.h" #include #include diff --git a/src/core/lib/gpr/object_registry.h b/src/core/lib/channel/object_registry.h similarity index 100% rename from src/core/lib/gpr/object_registry.h rename to src/core/lib/channel/object_registry.h diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index c60fe51f3f2..fcc5fd4311f 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -29,8 +29,8 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gpr/object_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index be930d97379..119616c23c5 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -29,10 +29,10 @@ #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/fork.h" -#include "src/core/lib/gpr/object_registry.h" #include "src/core/lib/gpr/thd_internal.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/call_combiner.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 17dd792be8e..2cd796b52f3 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -36,7 +36,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/log_windows.cc', 'src/core/lib/gpr/mpscq.cc', 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/object_registry.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', @@ -70,6 +69,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/message_compress.cc', 'src/core/lib/compression/stream_compression.cc', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 1cf985d1edc..60122540d67 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -943,6 +943,7 @@ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/object_registry.cc \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/message_compress.h \ src/core/lib/compression/stream_compression.h \ @@ -956,7 +957,6 @@ src/core/lib/gpr/env.h \ src/core/lib/gpr/fork.h \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.h \ -src/core/lib/gpr/object_registry.h \ src/core/lib/gpr/spinlock.h \ src/core/lib/gpr/string.h \ src/core/lib/gpr/string_windows.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 998a3749a2e..49642dbb664 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1050,6 +1050,8 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/object_registry.cc \ +src/core/lib/channel/object_registry.cc \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ @@ -1093,8 +1095,6 @@ src/core/lib/gpr/mpscq.cc \ src/core/lib/gpr/mpscq.h \ src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gpr/murmur_hash.h \ -src/core/lib/gpr/object_registry.cc \ -src/core/lib/gpr/object_registry.h \ src/core/lib/gpr/spinlock.h \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c4109162aaf..5fd6e5f60fb 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7865,7 +7865,6 @@ "src/core/lib/gpr/log_windows.cc", "src/core/lib/gpr/mpscq.cc", "src/core/lib/gpr/murmur_hash.cc", - "src/core/lib/gpr/object_registry.cc", "src/core/lib/gpr/string.cc", "src/core/lib/gpr/string_posix.cc", "src/core/lib/gpr/string_util_windows.cc", @@ -7929,7 +7928,6 @@ "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", - "src/core/lib/gpr/object_registry.h", "src/core/lib/gpr/spinlock.h", "src/core/lib/gpr/string.h", "src/core/lib/gpr/string_windows.h", @@ -7979,7 +7977,6 @@ "src/core/lib/gpr/fork.h", "src/core/lib/gpr/mpscq.h", "src/core/lib/gpr/murmur_hash.h", - "src/core/lib/gpr/object_registry.h", "src/core/lib/gpr/spinlock.h", "src/core/lib/gpr/string.h", "src/core/lib/gpr/string_windows.h", @@ -8086,6 +8083,7 @@ "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", + "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/message_compress.cc", "src/core/lib/compression/stream_compression.cc", @@ -8244,6 +8242,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/compression/stream_compression.h", @@ -8386,6 +8385,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/compression/stream_compression.h", From f935ab414108fb057c241aa02bc42e179c1b5b14 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 10:43:54 -0800 Subject: [PATCH 19/67] Fix include guard sanity --- src/core/lib/channel/object_registry.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h index cc8fc6d878b..744bbd8e994 100644 --- a/src/core/lib/channel/object_registry.h +++ b/src/core/lib/channel/object_registry.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H -#define GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H +#ifndef GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H +#define GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H #include @@ -40,4 +40,4 @@ void grpc_object_registry_unregister_object(intptr_t uuid); grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, void** object); -#endif /* GRPC_CORE_LIB_SUPPORT_OBJECT_REGISTRY_H */ +#endif /* GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H */ From 0084d3d5eaf747ee17cfc7b4afc9aa23b72fbc7e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 10:44:05 -0800 Subject: [PATCH 20/67] Fix clang tidy --- src/core/lib/channel/channel_tracer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 0a375074ef3..11983958751 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -67,8 +67,8 @@ ChannelTracer::ChannelTracer(size_t max_nodes) num_children_seen_(0), list_size_(0), max_list_size_(max_nodes), - head_trace_(0), - tail_trace_(0) { + head_trace_(nullptr), + tail_trace_(nullptr) { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 gpr_mu_init(&tracer_mu_); gpr_ref_init(&refs_, 1); From 4e8bcb2ceeb1fb1f79bba0d1498745824c9d19ca Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 10:44:15 -0800 Subject: [PATCH 21/67] Fix header dependancy --- build.yaml | 2 +- gRPC-Core.podspec | 4 ++-- grpc.gemspec | 2 +- package.xml | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.yaml b/build.yaml index fc647009702..2d53e963b61 100644 --- a/build.yaml +++ b/build.yaml @@ -317,7 +317,7 @@ filegroups: - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h - - src/core/lib/channel/object_registry.cc + - src/core/lib/channel/object_registry.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/message_compress.h - src/core/lib/compression/stream_compression.h diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 8c4ae86bc46..2400c3fae80 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -338,7 +338,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.cc', + 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', @@ -824,7 +824,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.cc', + 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', diff --git a/grpc.gemspec b/grpc.gemspec index 9d2b4a94b10..58d4c312d70 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -264,7 +264,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) - s.files += %w( src/core/lib/channel/object_registry.cc ) + s.files += %w( src/core/lib/channel/object_registry.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/message_compress.h ) s.files += %w( src/core/lib/compression/stream_compression.h ) diff --git a/package.xml b/package.xml index 98c2707e0f8..b137acf34ac 100644 --- a/package.xml +++ b/package.xml @@ -271,7 +271,7 @@ - + diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 60122540d67..2aba658c6c1 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -943,7 +943,7 @@ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/object_registry.cc \ +src/core/lib/channel/object_registry.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/message_compress.h \ src/core/lib/compression/stream_compression.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 49642dbb664..fea0ce6cf5d 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1051,7 +1051,7 @@ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ src/core/lib/channel/object_registry.cc \ -src/core/lib/channel/object_registry.cc \ +src/core/lib/channel/object_registry.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/message_compress.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 5fd6e5f60fb..35289c6d832 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8242,7 +8242,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/object_registry.cc", + "src/core/lib/channel/object_registry.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/compression/stream_compression.h", @@ -8385,7 +8385,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/object_registry.cc", + "src/core/lib/channel/object_registry.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/compression/stream_compression.h", From 7042b519e8076c10b42ad216afe8f80ba7ffcccc Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 11:31:53 -0800 Subject: [PATCH 22/67] Switch to using RefCounted --- .../ext/filters/client_channel/subchannel.cc | 3 +- src/core/lib/channel/channel_tracer.cc | 45 ++++++++----------- src/core/lib/channel/channel_tracer.h | 19 ++++---- src/core/lib/surface/channel.cc | 8 ++-- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 51fe70304b4..478fd3fbb95 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -41,6 +41,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" @@ -134,7 +135,7 @@ struct grpc_subchannel { /** our alarm */ grpc_timer alarm; - grpc_core::ManualConstructor tracer; + grpc_core::RefCountedPtr tracer; }; struct grpc_subchannel_call { diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 11983958751..077ee61193b 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -40,12 +40,12 @@ class TraceEvent { public: TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - ChannelTracer* referenced_tracer) + RefCountedPtr referenced_tracer) : data_(data), error_(error), connectivity_state_(connectivity_state), next_(nullptr) { - referenced_tracer_ = referenced_tracer ? referenced_tracer->Ref() : nullptr; + referenced_tracer_ = referenced_tracer; time_created_ = gpr_now(GPR_CLOCK_REALTIME); } @@ -58,7 +58,7 @@ class TraceEvent { grpc_connectivity_state connectivity_state_; TraceEvent* next_; // the tracer object for the (sub)channel that this trace node refers to. - ChannelTracer* referenced_tracer_; + RefCountedPtr referenced_tracer_; }; ChannelTracer::ChannelTracer(size_t max_nodes) @@ -71,46 +71,34 @@ ChannelTracer::ChannelTracer(size_t max_nodes) tail_trace_(nullptr) { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 gpr_mu_init(&tracer_mu_); - gpr_ref_init(&refs_, 1); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); max_list_size_ = max_nodes; time_created_ = gpr_now(GPR_CLOCK_REALTIME); } -ChannelTracer* ChannelTracer::Ref() { - if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 - gpr_ref(&refs_); - return this; -} - void ChannelTracer::FreeNode(TraceEvent* node) { GRPC_ERROR_UNREF(node->error_); - if (node->referenced_tracer_) { - node->referenced_tracer_->Unref(); - } grpc_slice_unref_internal(node->data_); gpr_free(node); } -void ChannelTracer::Unref() { +ChannelTracer::~ChannelTracer() { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 - if (gpr_unref(&refs_)) { - TraceEvent* it = head_trace_; - while (it != nullptr) { - TraceEvent* to_free = it; - it = it->next_; - FreeNode(to_free); - } - gpr_mu_destroy(&tracer_mu_); + TraceEvent* it = head_trace_; + while (it != nullptr) { + TraceEvent* to_free = it; + it = it->next_; + FreeNode(to_free); } + gpr_mu_destroy(&tracer_mu_); } intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - ChannelTracer* referenced_tracer) { + RefCountedPtr referenced_tracer) { if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 ++num_nodes_logged_; if (referenced_tracer != nullptr) ++num_children_seen_; @@ -136,6 +124,11 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, } } +void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) { + AddTrace(data, error, connectivity_state, RefCountedPtr()); +} + // returns an allocated string that represents tm according to RFC-3339. static char* fmt_time(gpr_timespec tm) { char buffer[35]; @@ -297,12 +290,12 @@ class ChannelTracerRenderer { // If we are recursively populating everything, and this node // references a tracer we haven't seen yet, we render that tracer // in full, adding it to the parent JSON's "children" field. - if (children && !TracerAlreadySeen(node->referenced_tracer_)) { + if (children && !TracerAlreadySeen(node->referenced_tracer_.get())) { grpc_json* referenced_tracer = grpc_json_create_child( nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); - AddSeenTracer(node->referenced_tracer_); + AddSeenTracer(node->referenced_tracer_.get()); ChannelTracer* saved = current_tracer_; - current_tracer_ = node->referenced_tracer_; + current_tracer_ = node->referenced_tracer_.get(); RecursivelyPopulateJson(referenced_tracer); current_tracer_ = saved; } diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 42f6e5ccb85..ab55dcf31d2 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -20,6 +20,8 @@ #define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H #include +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/json/json.h" @@ -27,22 +29,24 @@ namespace grpc_core { class TraceEvent; -class ChannelTracer { +class ChannelTracer : public RefCounted { public: ChannelTracer(size_t max_nodes); - ~ChannelTracer() {} - - // TODO(ncteisen): incorporate RefCounted class - ChannelTracer* Ref(); - void Unref(); + ~ChannelTracer(); /* returns the tracers uuid */ intptr_t GetUuid(); /* Adds a new trace node to the tracing object */ + void AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state); + + /* Adds a new trace node to the tracing object. This trace node refers to a + an event on a child of the channel. For example this could log when a + particular subchannel becomes connected */ void AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - ChannelTracer* subchannel); + RefCountedPtr referenced_tracer); /* Returns the tracing data rendered as a grpc json string. The string is owned by the caller and must be freed. If recursive @@ -59,7 +63,6 @@ class ChannelTracer { void FreeNode(TraceEvent* node); friend class ChannelTracerRenderer; - gpr_refcount refs_; gpr_mu tracer_mu_; intptr_t channel_uuid_; uint64_t num_nodes_logged_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index fcc5fd4311f..613a83cd016 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -34,6 +34,7 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -64,7 +65,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::ManualConstructor tracer; + grpc_core::RefCountedPtr tracer; char* target; }; @@ -202,13 +203,14 @@ grpc_channel* grpc_channel_create_with_builder( const grpc_integer_options options = {10, 0, 100}; size_t max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); - channel->tracer.Init(max_nodes); + channel->tracer = + grpc_core::MakeRefCounted(max_nodes); } } grpc_channel_args_destroy(args); channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, nullptr); + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE); return channel; } From 39c65638c096f88ff649003632b1e43e90e2c8f7 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 11:32:08 -0800 Subject: [PATCH 23/67] Update test --- test/core/channel/channel_tracer_test.cc | 187 ++++++++++------------- 1 file changed, 83 insertions(+), 104 deletions(-) diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 7f0efb34b18..564fbf3ed94 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -30,15 +30,17 @@ #include "test/core/util/test_config.h" using grpc_core::ChannelTracer; +using grpc_core::MakeRefCounted; +using grpc_core::RefCountedPtr; -static void add_simple_trace(ChannelTracer* tracer) { +static void add_simple_trace(RefCountedPtr tracer) { tracer->AddTrace(grpc_slice_from_static_string("simple trace"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY, nullptr); + GRPC_CHANNEL_READY); } // checks for the existence of all the required members of the tracer. -static void validate_tracer(ChannelTracer* tracer, +static void validate_tracer(RefCountedPtr tracer, size_t expected_num_nodes_logged, size_t max_nodes) { if (!max_nodes) return; @@ -50,7 +52,8 @@ static void validate_tracer(ChannelTracer* tracer, gpr_free(json_str); } -static void validate_tracer_data_matches_uuid_lookup(ChannelTracer* tracer) { +static void validate_tracer_data_matches_uuid_lookup( + RefCountedPtr tracer) { intptr_t uuid = tracer->GetUuid(); if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled char* tracer_json_str = tracer->RenderTrace(true); @@ -62,7 +65,7 @@ static void validate_tracer_data_matches_uuid_lookup(ChannelTracer* tracer) { } // ensures the tracer has the correct number of children tracers. -static void validate_children(ChannelTracer* tracer, +static void validate_children(RefCountedPtr tracer, size_t expected_num_children) { char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); @@ -75,28 +78,28 @@ static void validate_children(ChannelTracer* tracer, // lookups by uuid. static void test_basic_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; - ChannelTracer tracer(max_nodes); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - validate_tracer_data_matches_uuid_lookup(&tracer); - tracer.AddTrace( + RefCountedPtr tracer = + MakeRefCounted(max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer_data_matches_uuid_lookup(tracer); + tracer->AddTrace( grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, 2), - GRPC_CHANNEL_IDLE, nullptr); - tracer.AddTrace(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, - GRPC_CHANNEL_SHUTDOWN, nullptr); - validate_tracer(&tracer, 4, max_nodes); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - validate_tracer(&tracer, 6, max_nodes); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - validate_tracer(&tracer, 10, max_nodes); - validate_tracer_data_matches_uuid_lookup(&tracer); - tracer.Unref(); + GRPC_CHANNEL_IDLE); + tracer->AddTrace(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, + GRPC_CHANNEL_SHUTDOWN); + validate_tracer(tracer, 4, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer(tracer, 6, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer(tracer, 10, max_nodes); + validate_tracer_data_matches_uuid_lookup(tracer); } // Calls basic test with various values for max_nodes (including 0, which turns @@ -115,41 +118,39 @@ static void test_basic_channel_sizing() { // and this function will both hold refs to the subchannel. static void test_complex_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; - ChannelTracer tracer(max_nodes); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - ChannelTracer sc1(max_nodes); - tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); - validate_tracer(&tracer, 3, max_nodes); - add_simple_trace(&sc1); - add_simple_trace(&sc1); - add_simple_trace(&sc1); - validate_tracer(&sc1, 3, max_nodes); - add_simple_trace(&sc1); - add_simple_trace(&sc1); - add_simple_trace(&sc1); - validate_tracer(&sc1, 6, max_nodes); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - validate_tracer(&tracer, 5, max_nodes); - validate_tracer_data_matches_uuid_lookup(&tracer); - ChannelTracer sc2(max_nodes); - tracer.AddTrace(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc2); - tracer.AddTrace(grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); - validate_tracer(&tracer, 7, max_nodes); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - validate_tracer_data_matches_uuid_lookup(&tracer); - sc1.Unref(); - sc2.Unref(); - tracer.Unref(); + RefCountedPtr tracer = + MakeRefCounted(max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + RefCountedPtr sc1 = MakeRefCounted(max_nodes); + tracer->AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + validate_tracer(tracer, 3, max_nodes); + add_simple_trace(sc1); + add_simple_trace(sc1); + add_simple_trace(sc1); + validate_tracer(sc1, 3, max_nodes); + add_simple_trace(sc1); + add_simple_trace(sc1); + add_simple_trace(sc1); + validate_tracer(sc1, 6, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer(tracer, 5, max_nodes); + validate_tracer_data_matches_uuid_lookup(tracer); + RefCountedPtr sc2 = MakeRefCounted(max_nodes); + tracer->AddTrace(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTrace(grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + validate_tracer(tracer, 7, max_nodes); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + add_simple_trace(tracer); + validate_tracer_data_matches_uuid_lookup(tracer); } // Calls the complex test with a sweep of sizes for max_nodes. @@ -162,59 +163,38 @@ static void test_complex_channel_sizing() { test_complex_channel_tracing(15); } -// Tests edge case in which the parent channel tracer is destroyed before the -// subchannel. Not sure if it is a realistic scenario, but the refcounting -// balance should still hold. -static void test_delete_parent_first() { - grpc_core::ExecCtx exec_ctx; - ChannelTracer tracer(3); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - ChannelTracer sc1(3); - tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); - // this will cause the tracer destructor to run. - tracer.Unref(); - sc1.Unref(); -} - // Test a case in which the parent channel has subchannels and the subchannels // have connections. Ensures that everything lives as long as it should then // gets deleted. static void test_nesting() { grpc_core::ExecCtx exec_ctx; - ChannelTracer tracer(10); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - ChannelTracer sc1(5); - tracer.AddTrace(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); + RefCountedPtr tracer = MakeRefCounted(10); + add_simple_trace(tracer); + add_simple_trace(tracer); + RefCountedPtr sc1 = MakeRefCounted(5); + tracer->AddTrace(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); // channel has only one subchannel right here. - validate_children(&tracer, 1); - add_simple_trace(&sc1); - ChannelTracer conn1(5); + validate_children(tracer, 1); + add_simple_trace(sc1); + RefCountedPtr conn1 = MakeRefCounted(5); // nesting one level deeper. - sc1.AddTrace(grpc_slice_from_static_string("connection one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &conn1); - validate_children(&sc1, 1); - add_simple_trace(&conn1); - add_simple_trace(&tracer); - add_simple_trace(&tracer); - ChannelTracer sc2(5); - tracer.AddTrace(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc2); - validate_children(&tracer, 2); + sc1->AddTrace(grpc_slice_from_static_string("connection one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); + validate_children(sc1, 1); + add_simple_trace(conn1); + add_simple_trace(tracer); + add_simple_trace(tracer); + RefCountedPtr sc2 = MakeRefCounted(5); + tracer->AddTrace(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + validate_children(tracer, 2); // this trace should not get added to the parents children since it is already // present in the tracer. - tracer.AddTrace(grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, &sc1); - validate_children(&tracer, 2); - add_simple_trace(&tracer); - - conn1.Unref(); - sc1.Unref(); - sc2.Unref(); - tracer.Unref(); + tracer->AddTrace(grpc_slice_from_static_string("subchannel one inactive"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + validate_children(tracer, 2); + add_simple_trace(tracer); } int main(int argc, char** argv) { @@ -224,7 +204,6 @@ int main(int argc, char** argv) { test_basic_channel_sizing(); test_complex_channel_tracing(5); test_complex_channel_sizing(); - test_delete_parent_first(); test_nesting(); grpc_shutdown(); return 0; From a4533974da9403fd86c3c87d43e62ab00fe67ad3 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 12:08:38 -0800 Subject: [PATCH 24/67] Fix bazel build --- BUILD | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BUILD b/BUILD index 1df5df7f3d8..89bdb7345af 100644 --- a/BUILD +++ b/BUILD @@ -888,6 +888,9 @@ grpc_cc_library( "gpr++_base", "grpc_codegen", "grpc_trace", + ":ref_counted", + ":ref_counted_ptr", + ":debug_location", ], ) From 765cc955526092dc835dd7dce2cd9cb3d61746ad Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 12:08:56 -0800 Subject: [PATCH 25/67] Fix test compile --- test/core/channel/channel_tracer_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 564fbf3ed94..8a107ec5ec5 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -59,7 +59,7 @@ static void validate_tracer_data_matches_uuid_lookup( char* tracer_json_str = tracer->RenderTrace(true); char* uuid_lookup_json_str = ChannelTracer::GetChannelTraceFromUuid(uuid, true); - strcmp(tracer_json_str, uuid_lookup_json_str); + GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); gpr_free(tracer_json_str); gpr_free(uuid_lookup_json_str); } From cd6d0cce8e014ff2f0f6485c6fcaf5b49179588d Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 13:29:56 -0800 Subject: [PATCH 26/67] Refactor --- src/core/lib/channel/channel_tracer.cc | 35 ++++++++++++++++++-------- src/core/lib/channel/channel_tracer.h | 3 +++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 077ee61193b..8c58ea2fcce 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -44,8 +44,18 @@ class TraceEvent { : data_(data), error_(error), connectivity_state_(connectivity_state), - next_(nullptr) { - referenced_tracer_ = referenced_tracer; + next_(nullptr), + referenced_tracer_(referenced_tracer) { + time_created_ = gpr_now(GPR_CLOCK_REALTIME); + } + + TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) + : data_(data), + error_(error), + connectivity_state_(connectivity_state), + next_(nullptr), + referenced_tracer_(nullptr) { time_created_ = gpr_now(GPR_CLOCK_REALTIME); } @@ -96,15 +106,8 @@ ChannelTracer::~ChannelTracer() { intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } -void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { - if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 +void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { ++num_nodes_logged_; - if (referenced_tracer != nullptr) ++num_children_seen_; - // create and fill up the new node - TraceEvent* new_trace_node = - New(data, error, connectivity_state, referenced_tracer); // first node case if (head_trace_ == nullptr) { head_trace_ = tail_trace_ = new_trace_node; @@ -124,9 +127,19 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, } } +void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) { + if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 + ++num_children_seen_; + // create and fill up the new node + AddTraceEventNode( + New(data, error, connectivity_state, referenced_tracer)); +} + void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state) { - AddTrace(data, error, connectivity_state, RefCountedPtr()); + AddTraceEventNode(New(data, error, connectivity_state)); } // returns an allocated string that represents tm according to RFC-3339. diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index ab55dcf31d2..4e717d21c93 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -62,6 +62,9 @@ class ChannelTracer : public RefCounted { // Internal helper that frees a TraceEvent. void FreeNode(TraceEvent* node); + // Internal helper to add and link in a tracenode + void AddTraceEventNode(TraceEvent* new_trace_node); + friend class ChannelTracerRenderer; gpr_mu tracer_mu_; intptr_t channel_uuid_; From 9f9724aac1602aaca2a5af8874a2021f356cc9c8 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 23 Jan 2018 13:40:41 -0800 Subject: [PATCH 27/67] Fix initialization bug --- src/core/lib/surface/channel.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 613a83cd016..2c408805796 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -105,7 +105,7 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - bool tracer_initialized = false; + int64_t channel_tracer_max_nodes = 0; // default to off gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -197,18 +197,17 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(!tracer_initialized); - tracer_initialized = true; + GPR_ASSERT(channel_tracer_max_nodes == -1); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; - size_t max_nodes = + channel_tracer_max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); - channel->tracer = - grpc_core::MakeRefCounted(max_nodes); } } grpc_channel_args_destroy(args); + channel->tracer = grpc_core::MakeRefCounted( + channel_tracer_max_nodes); channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE); return channel; From 0a538e6dcf20fd392fc51a4e187ebf1e44c5a8c8 Mon Sep 17 00:00:00 2001 From: Noah Eisen Date: Wed, 24 Jan 2018 16:24:12 -0800 Subject: [PATCH 28/67] regenerate project on linux --- gRPC-C++.podspec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index abbb69c88ff..8f9f6afc557 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -298,11 +298,13 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_tracer.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', @@ -469,11 +471,13 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', + 'src/core/lib/channel/channel_tracer.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/compression/stream_compression.h', @@ -616,6 +620,7 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.h', 'test/core/end2end/fixtures/proxy.h', 'test/core/iomgr/endpoint_tests.h', + 'test/core/util/channel_tracing_utils.h', 'test/core/util/debugger_macros.h', 'test/core/util/grpc_profiler.h', 'test/core/util/histogram.h', From 804507d638f3bd0b2bcec1fcb2fd1cdbc361a90b Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 24 Jan 2018 16:59:32 -0800 Subject: [PATCH 29/67] Add get_uuid method to channel --- src/core/lib/surface/channel.cc | 4 ++++ src/core/lib/surface/channel.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 2c408805796..b78a218b1c6 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -217,6 +217,10 @@ char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { return channel->tracer->RenderTrace(recursive); } +intptr_t grpc_channel_get_uuid(grpc_channel* channel) { + return channel->tracer->GetUuid(); +} + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* input_args, grpc_channel_stack_type channel_stack_type, diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 5820bbbd80d..12a806ecd79 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -58,8 +58,14 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); +// Returns the JSON formatted channel trace for this channel. If recursive +// is true, it will render all of the trace for this channel's subchannels. char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); +// Returns the channel uuid, which can be used to look up its trace at a +// later time. +intptr_t grpc_channel_get_uuid(grpc_channel* channel); + #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); void grpc_channel_internal_unref(grpc_channel* channel, const char* reason); From 2bdc3ee70ca1eb1976d5a96c3e1130b3f6eec75f Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 29 Jan 2018 11:07:26 -0800 Subject: [PATCH 30/67] Fix asan --- src/core/lib/surface/channel.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 635daca8c86..63a7bd9d91b 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -398,6 +398,7 @@ static void destroy_channel(void* arg, grpc_error* error) { GRPC_MDELEM_UNREF(rc->authority); gpr_free(rc); } + channel->tracer.reset(nullptr); GRPC_MDELEM_UNREF(channel->default_authority); gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); From 42403d74ea338f5729d30d4e5aae1afcae14939f Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 29 Jan 2018 13:15:57 -0800 Subject: [PATCH 31/67] Fix objc build --- src/core/lib/surface/channel.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 63a7bd9d91b..11002eea1ef 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -105,7 +105,7 @@ grpc_channel* grpc_channel_create_with_builder( memset(channel, 0, sizeof(*channel)); channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); - int64_t channel_tracer_max_nodes = 0; // default to off + size_t channel_tracer_max_nodes = 0; // default to off gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = nullptr; @@ -170,7 +170,7 @@ grpc_channel* grpc_channel_create_with_builder( 0x1; /* always support no compression */ } else if (0 == strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { - GPR_ASSERT(channel_tracer_max_nodes == -1); + GPR_ASSERT(channel_tracer_max_nodes == 0); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; channel_tracer_max_nodes = From 8a7f65d727ce853e0ea65ece24ffce635238b488 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 29 Jan 2018 13:17:45 -0800 Subject: [PATCH 32/67] fix test mem leak --- src/core/lib/channel/channel_tracer.cc | 1 + test/core/channel/channel_tracer_test.cc | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 8c58ea2fcce..5f8563fdb9c 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -89,6 +89,7 @@ ChannelTracer::ChannelTracer(size_t max_nodes) void ChannelTracer::FreeNode(TraceEvent* node) { GRPC_ERROR_UNREF(node->error_); + node->referenced_tracer_.reset(nullptr); grpc_slice_unref_internal(node->data_); gpr_free(node); } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 8a107ec5ec5..6166b85ea87 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -100,6 +100,7 @@ static void test_basic_channel_tracing(size_t max_nodes) { add_simple_trace(tracer); validate_tracer(tracer, 10, max_nodes); validate_tracer_data_matches_uuid_lookup(tracer); + tracer.reset(nullptr); } // Calls basic test with various values for max_nodes (including 0, which turns @@ -151,6 +152,9 @@ static void test_complex_channel_tracing(size_t max_nodes) { add_simple_trace(tracer); add_simple_trace(tracer); validate_tracer_data_matches_uuid_lookup(tracer); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); } // Calls the complex test with a sweep of sizes for max_nodes. @@ -195,6 +199,10 @@ static void test_nesting() { GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_children(tracer, 2); add_simple_trace(tracer); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); + conn1.reset(nullptr); } int main(int argc, char** argv) { From bc43b0e683678d47e14e1ecd9a2aba0ab7abc7cd Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 30 Jan 2018 08:14:25 -0800 Subject: [PATCH 33/67] Remove duplicate line --- src/core/lib/channel/channel_tracer.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 5f8563fdb9c..0ebc9b5adbc 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -83,7 +83,6 @@ ChannelTracer::ChannelTracer(size_t max_nodes) gpr_mu_init(&tracer_mu_); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - max_list_size_ = max_nodes; time_created_ = gpr_now(GPR_CLOCK_REALTIME); } From 95cf05794ad43b534df75dfa3a7e146761a0cf6e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 20:12:41 -0800 Subject: [PATCH 34/67] Reviewer feedback --- include/grpc/impl/codegen/grpc_types.h | 4 +- src/core/lib/channel/channel_tracer.cc | 63 +++++++------------------- src/core/lib/channel/channel_tracer.h | 2 - src/core/lib/surface/channel.cc | 2 +- 4 files changed, 20 insertions(+), 51 deletions(-) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 7d410c88b3c..22132cc1a4f 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -281,9 +281,9 @@ typedef struct { #define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" /** The grpc_socket_factory instance to create and bind sockets. A pointer. */ #define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" -/** The maximum number of trace nodes to keep in the tracer for each channel or +/** The maximum number of trace events to keep in the tracer for each channel or * subchannel. The default is 10. If set to 0, channel tracing is disabled. */ -#define GRPC_ARG_CHANNEL_TRACING_MAX_NODES "grpc.channel_tracing_max_nodes" +#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE "grpc.max_channel_trace_events_per_node" /** If non-zero, Cronet transport will coalesce packets to fewer frames * when possible. */ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index d4c33127819..bd1396f04e4 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -45,7 +45,7 @@ class TraceEvent { error_(error), connectivity_state_(connectivity_state), next_(nullptr), - referenced_tracer_(referenced_tracer) { + referenced_tracer_(std::move(referenced_tracer)) { time_created_ = gpr_now(GPR_CLOCK_REALTIME); } @@ -59,6 +59,12 @@ class TraceEvent { time_created_ = gpr_now(GPR_CLOCK_REALTIME); } + ~TraceEvent() { + GRPC_ERROR_UNREF(error_); + referenced_tracer_.reset(); + grpc_slice_unref_internal(data_); + } + private: friend class ChannelTracer; friend class ChannelTracerRenderer; @@ -79,27 +85,20 @@ ChannelTracer::ChannelTracer(size_t max_nodes) max_list_size_(max_nodes), head_trace_(nullptr), tail_trace_(nullptr) { - if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 gpr_mu_init(&tracer_mu_); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); time_created_ = gpr_now(GPR_CLOCK_REALTIME); } -void ChannelTracer::FreeNode(TraceEvent* node) { - GRPC_ERROR_UNREF(node->error_); - node->referenced_tracer_.reset(nullptr); - grpc_slice_unref_internal(node->data_); - gpr_free(node); -} - ChannelTracer::~ChannelTracer() { - if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 TraceEvent* it = head_trace_; while (it != nullptr) { TraceEvent* to_free = it; it = it->next_; - FreeNode(to_free); + gpr_free(to_free); } gpr_mu_destroy(&tracer_mu_); } @@ -122,7 +121,7 @@ void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { if (list_size_ > max_list_size_) { TraceEvent* to_free = head_trace_; head_trace_ = head_trace_->next_; - FreeNode(to_free); + gpr_free(to_free); --list_size_; } } @@ -130,11 +129,11 @@ void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer) { - if (!max_list_size_) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 ++num_children_seen_; // create and fill up the new node AddTraceEventNode( - New(data, error, connectivity_state, referenced_tracer)); + New(data, error, connectivity_state, std::move(referenced_tracer))); } void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, @@ -142,8 +141,10 @@ void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, AddTraceEventNode(New(data, error, connectivity_state)); } +namespace { + // returns an allocated string that represents tm according to RFC-3339. -static char* fmt_time(gpr_timespec tm) { +char* fmt_time(gpr_timespec tm) { char buffer[35]; struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", tm_info); @@ -152,36 +153,7 @@ static char* fmt_time(gpr_timespec tm) { return full_time_str; } -// Helper class that is responsible for walking the tree of ChannelTracer -// objects and rendering the trace as JSON according to: -// https://github.com/grpc/proposal/pull/7 - -// The rendered JSON should be of this format: -// { -// "channelData": { -// "uuid": string, -// "numNodesLogged": number, -// "startTime": timestamp string, -// "nodes": [ -// { -// "data": string, -// "error": string, -// "time": timestamp string, -// // can only be one of the states in connectivity_state.h -// "state": enum string, -// // uuid of referenced subchannel. -// // Optional, only present if this event refers to a child object. -// // and example of a referenced child would be a trace event for a -// // subchannel being created. -// "child_uuid": string -// }, -// ] -// }, -// // Optional, only present if this channel has children -// "childData": [ -// // List of child data, which is of the exact same format as the -// ] -// } +} // anonymous namespace class ChannelTracerRenderer { public: @@ -242,7 +214,6 @@ class ChannelTracerRenderer { // recursively populate each referenced child as it passes that node. void PopulateChannelData(grpc_json* channel_data, grpc_json* children) { grpc_json* child = nullptr; - char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid_); child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 3f8849ff465..58e99d340f6 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -59,8 +59,6 @@ class ChannelTracer : public RefCounted { static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); private: - // Internal helper that frees a TraceEvent. - void FreeNode(TraceEvent* node); // Internal helper to add and link in a tracenode void AddTraceEventNode(TraceEvent* new_trace_node); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 8851aac7399..76ab9582566 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -171,7 +171,7 @@ grpc_channel* grpc_channel_create_with_builder( static_cast(args->args[i].value.integer) | 0x1; /* always support no compression */ } else if (0 == - strcmp(args->args[i].key, GRPC_ARG_CHANNEL_TRACING_MAX_NODES)) { + strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; From 6ea7f3330e238f69925062b281185fbfaefd4ee2 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 20:19:25 -0800 Subject: [PATCH 35/67] Reviewer comments --- include/grpc/impl/codegen/grpc_types.h | 3 +- .../ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_tracer.cc | 96 ++++++++++--------- src/core/lib/channel/channel_tracer.h | 31 +++--- src/core/lib/json/json.h | 1 - src/core/lib/surface/channel.cc | 13 +-- 6 files changed, 74 insertions(+), 72 deletions(-) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 22132cc1a4f..b671ad653e3 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -283,7 +283,8 @@ typedef struct { #define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" /** The maximum number of trace events to keep in the tracer for each channel or * subchannel. The default is 10. If set to 0, channel tracing is disabled. */ -#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE "grpc.max_channel_trace_events_per_node" +#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE \ + "grpc.max_channel_trace_events_per_node" /** If non-zero, Cronet transport will coalesce packets to fewer frames * when possible. */ #define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 68cd9260ba9..77c0fe2c430 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -136,7 +136,7 @@ struct grpc_subchannel { /** our alarm */ grpc_timer alarm; - grpc_core::RefCountedPtr tracer; + grpc_core::RefCountedPtr tracer; }; struct grpc_subchannel_call { diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index bd1396f04e4..982b86447db 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -40,7 +40,7 @@ class TraceEvent { public: TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) + RefCountedPtr referenced_tracer) : data_(data), error_(error), connectivity_state_(connectivity_state), @@ -66,34 +66,34 @@ class TraceEvent { } private: - friend class ChannelTracer; - friend class ChannelTracerRenderer; + friend class ChannelTrace; + friend class ChannelTraceRenderer; grpc_slice data_; grpc_error* error_; gpr_timespec time_created_; grpc_connectivity_state connectivity_state_; TraceEvent* next_; - // the tracer object for the (sub)channel that this trace node refers to. - RefCountedPtr referenced_tracer_; + // the tracer object for the (sub)channel that this trace event refers to. + RefCountedPtr referenced_tracer_; }; -ChannelTracer::ChannelTracer(size_t max_nodes) +ChannelTrace::ChannelTrace(size_t max_events) : channel_uuid_(-1), - num_nodes_logged_(0), + num_events_logged_(0), num_children_seen_(0), list_size_(0), - max_list_size_(max_nodes), + max_list_size_(max_events), head_trace_(nullptr), tail_trace_(nullptr) { - if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 gpr_mu_init(&tracer_mu_); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); time_created_ = gpr_now(GPR_CLOCK_REALTIME); } -ChannelTracer::~ChannelTracer() { - if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 +ChannelTrace::~ChannelTrace() { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 TraceEvent* it = head_trace_; while (it != nullptr) { TraceEvent* to_free = it; @@ -103,17 +103,17 @@ ChannelTracer::~ChannelTracer() { gpr_mu_destroy(&tracer_mu_); } -intptr_t ChannelTracer::GetUuid() { return channel_uuid_; } +intptr_t ChannelTrace::GetUuid() { return channel_uuid_; } -void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { - ++num_nodes_logged_; - // first node case +void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { + ++num_events_logged_; + // first event case if (head_trace_ == nullptr) { - head_trace_ = tail_trace_ = new_trace_node; + head_trace_ = tail_trace_ = new_trace_event; } - // regular node add case + // regular event add case else { - tail_trace_->next_ = new_trace_node; + tail_trace_->next_ = new_trace_event; tail_trace_ = tail_trace_->next_; } ++list_size_; @@ -126,19 +126,20 @@ void ChannelTracer::AddTraceEventNode(TraceEvent* new_trace_node) { } } -void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { - if (max_list_size_ == 0) return; // tracing is disabled if max_nodes == 0 +void ChannelTrace::AddTraceEvent( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 ++num_children_seen_; - // create and fill up the new node - AddTraceEventNode( - New(data, error, connectivity_state, std::move(referenced_tracer))); + // create and fill up the new event + AddTraceEventHelper(New(data, error, connectivity_state, + std::move(referenced_tracer))); } -void ChannelTracer::AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) { - AddTraceEventNode(New(data, error, connectivity_state)); +void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) { + AddTraceEventHelper(New(data, error, connectivity_state)); } namespace { @@ -153,13 +154,13 @@ char* fmt_time(gpr_timespec tm) { return full_time_str; } -} // anonymous namespace +} // anonymous namespace -class ChannelTracerRenderer { +class ChannelTraceRenderer { public: // If recursive==true, then the entire tree of trace will be rendered. // If not, then only the top level data will be. - ChannelTracerRenderer(ChannelTracer* tracer, bool recursive) + ChannelTraceRenderer(ChannelTrace* tracer, bool recursive) : current_tracer_(tracer), recursive_(recursive), seen_tracers_(nullptr), @@ -180,16 +181,16 @@ class ChannelTracerRenderer { private: // tracks that a tracer has already been rendered to avoid infinite // recursion. - void AddSeenTracer(ChannelTracer* newly_seen) { + void AddSeenTracer(ChannelTrace* newly_seen) { if (size_ >= cap_) { cap_ = GPR_MAX(5 * sizeof(newly_seen), 3 * cap_ / 2); - seen_tracers_ = (ChannelTracer**)gpr_realloc(seen_tracers_, cap_); + seen_tracers_ = (ChannelTrace**)gpr_realloc(seen_tracers_, cap_); } seen_tracers_[size_++] = newly_seen; } // Checks if a tracer has already been seen. - bool TracerAlreadySeen(ChannelTracer* tracer) { + bool TracerAlreadySeen(ChannelTrace* tracer) { for (size_t i = 0; i < size_; ++i) { if (seen_tracers_[i] == tracer) return true; } @@ -211,19 +212,19 @@ class ChannelTracerRenderer { } // Fills up the channelData object. If children is not null, it will - // recursively populate each referenced child as it passes that node. + // recursively populate each referenced child as it passes that event. void PopulateChannelData(grpc_json* channel_data, grpc_json* children) { grpc_json* child = nullptr; char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid_); child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, GRPC_JSON_NUMBER, true); - char* num_nodes_logged_str; - gpr_asprintf(&num_nodes_logged_str, "%" PRId64, - current_tracer_->num_nodes_logged_); + char* num_events_logged_str; + gpr_asprintf(&num_events_logged_str, "%" PRId64, + current_tracer_->num_events_logged_); child = grpc_json_create_child(child, channel_data, "numNodesLogged", - num_nodes_logged_str, GRPC_JSON_NUMBER, true); + num_events_logged_str, GRPC_JSON_NUMBER, true); child = grpc_json_create_child(child, channel_data, "startTime", fmt_time(current_tracer_->time_created_), GRPC_JSON_STRING, true); @@ -278,7 +279,7 @@ class ChannelTracerRenderer { grpc_json* referenced_tracer = grpc_json_create_child( nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); AddSeenTracer(node->referenced_tracer_.get()); - ChannelTracer* saved = current_tracer_; + ChannelTrace* saved = current_tracer_; current_tracer_ = node->referenced_tracer_.get(); RecursivelyPopulateJson(referenced_tracer); current_tracer_ = saved; @@ -287,30 +288,31 @@ class ChannelTracerRenderer { } // Tracks the current tracer we are rendering as we walk the tree of tracers. - ChannelTracer* current_tracer_; + ChannelTrace* current_tracer_; // If true, we will render the data of all of this tracer's children. bool recursive_; // These members are used to track tracers we have already rendered. This is // a dynamically growing array that is deallocated when the rendering is done. - ChannelTracer** seen_tracers_; + ChannelTrace** seen_tracers_; size_t size_; size_t cap_; }; -char* ChannelTracer::RenderTrace(bool recursive) { - if (!max_list_size_) return nullptr; // tracing is disabled if max_nodes == 0 - ChannelTracerRenderer renderer(this, recursive); +char* ChannelTrace::RenderTrace(bool recursive) { + if (!max_list_size_) + return nullptr; // tracing is disabled if max_events == 0 + ChannelTraceRenderer renderer(this, recursive); return renderer.Run(); } -char* ChannelTracer::GetChannelTraceFromUuid(intptr_t uuid, bool recursive) { +char* ChannelTrace::GetChannelTraceFromUuid(intptr_t uuid, bool recursive) { void* object; grpc_object_registry_type type = grpc_object_registry_get_object(uuid, &object); GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - return static_cast(object)->RenderTrace(recursive); + return static_cast(object)->RenderTrace(recursive); } } // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 58e99d340f6..72bdee48f8c 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -29,24 +29,24 @@ namespace grpc_core { class TraceEvent; -class ChannelTracer : public RefCounted { +class ChannelTrace : public RefCounted { public: - ChannelTracer(size_t max_nodes); - ~ChannelTracer(); + ChannelTrace(size_t max_events); + ~ChannelTrace(); - /* returns the tracers uuid */ + /* returns the tracer's uuid */ intptr_t GetUuid(); - /* Adds a new trace node to the tracing object */ - void AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); + /* Adds a new trace event to the tracing object */ + void AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state); - /* Adds a new trace node to the tracing object. This trace node refers to a + /* Adds a new trace event to the tracing object. This trace event refers to a an event on a child of the channel. For example this could log when a particular subchannel becomes connected */ - void AddTrace(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + void AddTraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer); /* Returns the tracing data rendered as a grpc json string. The string is owned by the caller and must be freed. If recursive @@ -59,14 +59,13 @@ class ChannelTracer : public RefCounted { static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); private: + // Internal helper to add and link in a trace event + void AddTraceEventHelper(TraceEvent* new_trace_event); - // Internal helper to add and link in a tracenode - void AddTraceEventNode(TraceEvent* new_trace_node); - - friend class ChannelTracerRenderer; + friend class ChannelTraceRenderer; gpr_mu tracer_mu_; intptr_t channel_uuid_; - uint64_t num_nodes_logged_; + uint64_t num_events_logged_; uint64_t num_children_seen_; size_t list_size_; size_t max_list_size_; diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index c8a87a7b878..f93b43048b9 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -19,7 +19,6 @@ #ifndef GRPC_CORE_LIB_JSON_JSON_H #define GRPC_CORE_LIB_JSON_JSON_H - #include #include diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 76ab9582566..837e78e85f4 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -67,7 +67,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call* registered_calls; - grpc_core::RefCountedPtr tracer; + grpc_core::RefCountedPtr tracer; char* target; }; @@ -170,8 +170,8 @@ grpc_channel* grpc_channel_create_with_builder( channel->compression_options.enabled_algorithms_bitset = static_cast(args->args[i].value.integer) | 0x1; /* always support no compression */ - } else if (0 == - strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { + } else if (0 == strcmp(args->args[i].key, + GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); // max_nodes defaults to 10, clamped between 0 and 100. const grpc_integer_options options = {10, 0, 100}; @@ -181,10 +181,11 @@ grpc_channel* grpc_channel_create_with_builder( } grpc_channel_args_destroy(args); - channel->tracer = grpc_core::MakeRefCounted( + channel->tracer = grpc_core::MakeRefCounted( channel_tracer_max_nodes); - channel->tracer->AddTrace(grpc_slice_from_static_string("Channel created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE); + channel->tracer->AddTraceEvent( + grpc_slice_from_static_string("Channel created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE); return channel; } From 240fbf9fd60fd2b61e0c0ddd937ab5bb891f59ef Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 20:29:13 -0800 Subject: [PATCH 36/67] reviewer comment --- src/core/lib/channel/channel_tracer.cc | 8 --- src/core/lib/channel/channel_tracer.h | 8 +-- test/core/channel/channel_tracer_test.cc | 79 +++++++++++++----------- 3 files changed, 45 insertions(+), 50 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 982b86447db..b1c76408a04 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -307,12 +307,4 @@ char* ChannelTrace::RenderTrace(bool recursive) { return renderer.Run(); } -char* ChannelTrace::GetChannelTraceFromUuid(intptr_t uuid, bool recursive) { - void* object; - grpc_object_registry_type type = - grpc_object_registry_get_object(uuid, &object); - GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - return static_cast(object)->RenderTrace(recursive); -} - } // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 72bdee48f8c..e3ab32cfcd1 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -43,7 +43,9 @@ class ChannelTrace : public RefCounted { /* Adds a new trace event to the tracing object. This trace event refers to a an event on a child of the channel. For example this could log when a - particular subchannel becomes connected */ + particular subchannel becomes connected. + TODO(ncteisen): Once channelz is implemented, the events should reference + the channelz object, not the channel trace. */ void AddTraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer); @@ -54,10 +56,6 @@ class ChannelTrace : public RefCounted { subtracing objects. */ char* RenderTrace(bool recursive); - /* util functions that perform the uuid -> tracer step for you, and then - returns the trace for the uuid given. */ - static char* GetChannelTraceFromUuid(intptr_t uuid, bool recursive); - private: // Internal helper to add and link in a trace event void AddTraceEventHelper(TraceEvent* new_trace_event); diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 5ac15ff6cde..52e57bafbb2 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -23,24 +23,25 @@ #include #include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/channel_tracing_utils.h" #include "test/core/util/test_config.h" -using grpc_core::ChannelTracer; +using grpc_core::ChannelTrace; using grpc_core::MakeRefCounted; using grpc_core::RefCountedPtr; -static void add_simple_trace(RefCountedPtr tracer) { - tracer->AddTrace(grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY); +static void add_simple_trace(RefCountedPtr tracer) { + tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_CHANNEL_READY); } // checks for the existence of all the required members of the tracer. -static void validate_tracer(RefCountedPtr tracer, +static void validate_tracer(RefCountedPtr tracer, size_t expected_num_nodes_logged, size_t max_nodes) { if (!max_nodes) return; @@ -53,19 +54,23 @@ static void validate_tracer(RefCountedPtr tracer, } static void validate_tracer_data_matches_uuid_lookup( - RefCountedPtr tracer) { + RefCountedPtr tracer) { intptr_t uuid = tracer->GetUuid(); if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled char* tracer_json_str = tracer->RenderTrace(true); + void* object; + grpc_object_registry_type type = + grpc_object_registry_get_object(uuid, &object); + GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); char* uuid_lookup_json_str = - ChannelTracer::GetChannelTraceFromUuid(uuid, true); + static_cast(object)->RenderTrace(true); GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); gpr_free(tracer_json_str); gpr_free(uuid_lookup_json_str); } // ensures the tracer has the correct number of children tracers. -static void validate_children(RefCountedPtr tracer, +static void validate_children(RefCountedPtr tracer, size_t expected_num_children) { char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); @@ -74,22 +79,21 @@ static void validate_children(RefCountedPtr tracer, gpr_free(json_str); } -// Tests basic ChannelTracer functionality like construction, adding trace, and +// Tests basic ChannelTrace functionality like construction, adding trace, and // lookups by uuid. static void test_basic_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = - MakeRefCounted(max_nodes); + RefCountedPtr tracer = MakeRefCounted(max_nodes); add_simple_trace(tracer); add_simple_trace(tracer); validate_tracer_data_matches_uuid_lookup(tracer); - tracer->AddTrace( + tracer->AddTraceEvent( grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, 2), GRPC_CHANNEL_IDLE); - tracer->AddTrace(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, - GRPC_CHANNEL_SHUTDOWN); + tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), + GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); validate_tracer(tracer, 4, max_nodes); add_simple_trace(tracer); add_simple_trace(tracer); @@ -119,13 +123,12 @@ static void test_basic_channel_sizing() { // and this function will both hold refs to the subchannel. static void test_complex_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = - MakeRefCounted(max_nodes); + RefCountedPtr tracer = MakeRefCounted(max_nodes); add_simple_trace(tracer); add_simple_trace(tracer); - RefCountedPtr sc1 = MakeRefCounted(max_nodes); - tracer->AddTrace(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + RefCountedPtr sc1 = MakeRefCounted(max_nodes); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_tracer(tracer, 3, max_nodes); add_simple_trace(sc1); add_simple_trace(sc1); @@ -139,11 +142,12 @@ static void test_complex_channel_tracing(size_t max_nodes) { add_simple_trace(tracer); validate_tracer(tracer, 5, max_nodes); validate_tracer_data_matches_uuid_lookup(tracer); - RefCountedPtr sc2 = MakeRefCounted(max_nodes); - tracer->AddTrace(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - tracer->AddTrace(grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + RefCountedPtr sc2 = MakeRefCounted(max_nodes); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEvent( + grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); validate_tracer(tracer, 7, max_nodes); add_simple_trace(tracer); add_simple_trace(tracer); @@ -172,31 +176,32 @@ static void test_complex_channel_sizing() { // gets deleted. static void test_nesting() { grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(10); + RefCountedPtr tracer = MakeRefCounted(10); add_simple_trace(tracer); add_simple_trace(tracer); - RefCountedPtr sc1 = MakeRefCounted(5); - tracer->AddTrace(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + RefCountedPtr sc1 = MakeRefCounted(5); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); // channel has only one subchannel right here. validate_children(tracer, 1); add_simple_trace(sc1); - RefCountedPtr conn1 = MakeRefCounted(5); + RefCountedPtr conn1 = MakeRefCounted(5); // nesting one level deeper. - sc1->AddTrace(grpc_slice_from_static_string("connection one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); + sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); validate_children(sc1, 1); add_simple_trace(conn1); add_simple_trace(tracer); add_simple_trace(tracer); - RefCountedPtr sc2 = MakeRefCounted(5); - tracer->AddTrace(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + RefCountedPtr sc2 = MakeRefCounted(5); + tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); validate_children(tracer, 2); // this trace should not get added to the parents children since it is already // present in the tracer. - tracer->AddTrace(grpc_slice_from_static_string("subchannel one inactive"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + tracer->AddTraceEvent( + grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); validate_children(tracer, 2); add_simple_trace(tracer); tracer.reset(nullptr); From bf5237a723501c3a0c6324f7d8662b2759bfb816 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 20:45:26 -0800 Subject: [PATCH 37/67] reviewer comments --- include/grpc/grpc.h | 8 +++ src/core/lib/channel/object_registry.cc | 5 +- src/core/lib/channel/object_registry.h | 9 +++- src/core/lib/surface/channel.cc | 6 +-- src/core/lib/surface/channel.h | 8 --- test/core/channel/channel_tracer_test.cc | 68 ++++++++++++------------ test/core/util/channel_tracing_utils.cc | 5 +- test/core/util/channel_tracing_utils.h | 5 +- 8 files changed, 62 insertions(+), 52 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index c129a66949f..2ad247abb13 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,6 +286,14 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); +// Returns the JSON formatted channel trace for this channel. If recursive +// is true, it will render all of the trace for this channel's subchannels. +GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); + +// Returns the channel uuid, which can be used to look up its trace at a +// later time. +GRPCAPI intptr_t grpc_channel_get_uuid(grpc_channel* channel); + /** Error handling for grpc_call Most grpc_call functions return a grpc_error. If the error is not GRPC_OK then the operation failed due to some unsatisfied precondition. diff --git a/src/core/lib/channel/object_registry.cc b/src/core/lib/channel/object_registry.cc index ef2aa1d591f..108552a3c63 100644 --- a/src/core/lib/channel/object_registry.cc +++ b/src/core/lib/channel/object_registry.cc @@ -18,6 +18,7 @@ #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/avl/avl.h" +#include "src/core/lib/gpr/useful.h" #include #include @@ -25,7 +26,7 @@ // file global lock and avl. static gpr_mu g_mu; static grpc_avl g_avl; -static intptr_t g_uuid = 0; +static gpr_atm g_uuid = 0; typedef struct { void* object; @@ -37,7 +38,7 @@ typedef struct { static void destroy_intptr(void* not_used, void* user_data) {} static void* copy_intptr(void* key, void* user_data) { return key; } static long compare_intptr(void* key1, void* key2, void* user_data) { - return (intptr_t)key1 - (intptr_t)key2; + return GPR_ICMP(key1, key2); } static void destroy_tracker(void* tracker, void* user_data) { diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h index 744bbd8e994..2747522cc1a 100644 --- a/src/core/lib/channel/object_registry.h +++ b/src/core/lib/channel/object_registry.h @@ -21,7 +21,10 @@ #include -// Different types that may be stored in the general object registry +// TODO(ncteisen): convert this file to C++ + +// Different types that may be stored in the general object registry. For now, +// the only use case is channel tracers, but the design has been left general. typedef enum { // Used to hold uuid -> ChannelTracer mappings to allow for the trace data // to be looked up by uuid, rather then have to walk the entire tree of @@ -34,9 +37,13 @@ typedef enum { void grpc_object_registry_init(); void grpc_object_registry_shutdown(); +// globally registers the object. Returns its unique uuid intptr_t grpc_object_registry_register_object(void* object, grpc_object_registry_type type); +// globally unregisters the object that is associated to uuid. void grpc_object_registry_unregister_object(intptr_t uuid); +// if object with uuid has previously been registered, stores it in *object. +// if not, returns GRPC_OBJECT_REGISTRY_UNKNOWN and sets *object unchanged. grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, void** object); diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 837e78e85f4..18ff89d5bb1 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -173,8 +173,8 @@ grpc_channel* grpc_channel_create_with_builder( } else if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); - // max_nodes defaults to 10, clamped between 0 and 100. - const grpc_integer_options options = {10, 0, 100}; + // max_nodes defaults to 0 (which is off), clamped between 0 and 100. + const grpc_integer_options options = {0, 0, 100}; channel_tracer_max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); } @@ -405,7 +405,7 @@ static void destroy_channel(void* arg, grpc_error* error) { GRPC_MDELEM_UNREF(rc->authority); gpr_free(rc); } - channel->tracer.reset(nullptr); + channel->tracer.reset(); GRPC_MDELEM_UNREF(channel->default_authority); gpr_mu_destroy(&channel->registered_call_mu); gpr_free(channel->target); diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index c9801515376..288313951e4 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -60,14 +60,6 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); -// Returns the JSON formatted channel trace for this channel. If recursive -// is true, it will render all of the trace for this channel's subchannels. -char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); - -// Returns the channel uuid, which can be used to look up its trace at a -// later time. -intptr_t grpc_channel_get_uuid(grpc_channel* channel); - #ifndef NDEBUG void grpc_channel_internal_ref(grpc_channel* channel, const char* reason); void grpc_channel_internal_unref(grpc_channel* channel, const char* reason); diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 52e57bafbb2..1f2ed33e334 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -34,7 +34,7 @@ using grpc_core::ChannelTrace; using grpc_core::MakeRefCounted; using grpc_core::RefCountedPtr; -static void add_simple_trace(RefCountedPtr tracer) { +static void add_simple_trace_event(RefCountedPtr tracer) { tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_CHANNEL_READY); @@ -47,8 +47,8 @@ static void validate_tracer(RefCountedPtr tracer, if (!max_nodes) return; char* json_str = tracer->RenderTrace(true); grpc_json* json = grpc_json_parse_string(json_str); - validate_channel_data(json, expected_num_nodes_logged, - GPR_MIN(expected_num_nodes_logged, max_nodes)); + validate_channel_trace_data(json, expected_num_nodes_logged, + GPR_MIN(expected_num_nodes_logged, max_nodes)); grpc_json_destroy(json); gpr_free(json_str); } @@ -84,8 +84,8 @@ static void validate_children(RefCountedPtr tracer, static void test_basic_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer_data_matches_uuid_lookup(tracer); tracer->AddTraceEvent( grpc_slice_from_static_string("trace three"), @@ -95,13 +95,13 @@ static void test_basic_channel_tracing(size_t max_nodes) { tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); validate_tracer(tracer, 4, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer(tracer, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer(tracer, 10, max_nodes); validate_tracer_data_matches_uuid_lookup(tracer); tracer.reset(nullptr); @@ -124,22 +124,22 @@ static void test_basic_channel_sizing() { static void test_complex_channel_tracing(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); RefCountedPtr sc1 = MakeRefCounted(max_nodes); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_tracer(tracer, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); validate_tracer(sc1, 3, max_nodes); - add_simple_trace(sc1); - add_simple_trace(sc1); - add_simple_trace(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); + add_simple_trace_event(sc1); validate_tracer(sc1, 6, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer(tracer, 5, max_nodes); validate_tracer_data_matches_uuid_lookup(tracer); RefCountedPtr sc2 = MakeRefCounted(max_nodes); @@ -149,12 +149,12 @@ static void test_complex_channel_tracing(size_t max_nodes) { grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_tracer(tracer, 7, max_nodes); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); validate_tracer_data_matches_uuid_lookup(tracer); tracer.reset(nullptr); sc1.reset(nullptr); @@ -177,22 +177,22 @@ static void test_complex_channel_sizing() { static void test_nesting() { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(10); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); RefCountedPtr sc1 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); // channel has only one subchannel right here. validate_children(tracer, 1); - add_simple_trace(sc1); + add_simple_trace_event(sc1); RefCountedPtr conn1 = MakeRefCounted(5); // nesting one level deeper. sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); validate_children(sc1, 1); - add_simple_trace(conn1); - add_simple_trace(tracer); - add_simple_trace(tracer); + add_simple_trace_event(conn1); + add_simple_trace_event(tracer); + add_simple_trace_event(tracer); RefCountedPtr sc2 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); @@ -203,7 +203,7 @@ static void test_nesting() { grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_children(tracer, 2); - add_simple_trace(tracer); + add_simple_trace_event(tracer); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr); diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index 7e96d2d57d3..8262776f298 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -45,8 +45,9 @@ void validate_json_array_size(grpc_json* json, const char* key, GPR_ASSERT(count == expected_size); } -void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, - size_t actual_num_nodes_expected) { +void validate_channel_trace_data(grpc_json* json, + size_t num_nodes_logged_expected, + size_t actual_num_nodes_expected) { GPR_ASSERT(json); grpc_json* channel_data = get_json_child(json, "channelData"); grpc_json* num_nodes_logged_json = diff --git a/test/core/util/channel_tracing_utils.h b/test/core/util/channel_tracing_utils.h index 6a3eac98a91..7eac114cc53 100644 --- a/test/core/util/channel_tracing_utils.h +++ b/test/core/util/channel_tracing_utils.h @@ -24,7 +24,8 @@ void validate_json_array_size(grpc_json* json, const char* key, size_t expected_size); -void validate_channel_data(grpc_json* json, size_t num_nodes_logged_expected, - size_t actual_num_nodes_expected); +void validate_channel_trace_data(grpc_json* json, + size_t num_nodes_logged_expected, + size_t actual_num_nodes_expected); #endif /* GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H */ From ee013d25b3237b62185d1248e4ccc873a0d6be3e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 1 Mar 2018 23:15:47 -0800 Subject: [PATCH 38/67] Fix build and sanity --- grpc.def | 2 ++ include/grpc/grpc.h | 10 +++++----- src/core/lib/channel/channel_tracer.cc | 2 ++ src/core/lib/channel/channel_tracer.h | 2 ++ src/core/lib/channel/object_registry.cc | 4 +++- src/core/lib/channel/object_registry.h | 2 ++ src/core/lib/surface/channel.cc | 2 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 4 ++++ src/ruby/ext/grpc/rb_grpc_imports.generated.h | 6 ++++++ test/core/surface/public_headers_must_be_c89.c | 2 ++ 10 files changed, 29 insertions(+), 7 deletions(-) diff --git a/grpc.def b/grpc.def index 2bafebbbd49..5ff3a1efe8a 100644 --- a/grpc.def +++ b/grpc.def @@ -45,6 +45,8 @@ EXPORTS grpc_insecure_channel_create grpc_lame_client_channel_create grpc_channel_destroy + grpc_channel_get_trace + grpc_channel_get_uuid grpc_call_cancel grpc_call_cancel_with_status grpc_call_ref diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 2ad247abb13..e3b60a93a28 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,12 +286,12 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); -// Returns the JSON formatted channel trace for this channel. If recursive -// is true, it will render all of the trace for this channel's subchannels. -GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, bool recursive); +/** Returns the JSON formatted channel trace for this channel. If recursive + is non 0, it will render all of the trace for this channel's subchannels. */ +GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, int recursive); -// Returns the channel uuid, which can be used to look up its trace at a -// later time. +/** Returns the channel uuid, which can be used to look up its trace at a + later time. */ GRPCAPI intptr_t grpc_channel_get_uuid(grpc_channel* channel); /** Error handling for grpc_call diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index b1c76408a04..6e3cd35db9d 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -16,6 +16,8 @@ * */ +#include + #include "src/core/lib/channel/channel_tracer.h" #include diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index e3ab32cfcd1..e2a0442a26c 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -19,6 +19,8 @@ #ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H #define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H +#include + #include #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/channel/object_registry.cc b/src/core/lib/channel/object_registry.cc index 108552a3c63..987c5366cad 100644 --- a/src/core/lib/channel/object_registry.cc +++ b/src/core/lib/channel/object_registry.cc @@ -16,8 +16,10 @@ * */ -#include "src/core/lib/channel/object_registry.h" +#include + #include "src/core/lib/avl/avl.h" +#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/useful.h" #include diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h index 2747522cc1a..446d0cb41f8 100644 --- a/src/core/lib/channel/object_registry.h +++ b/src/core/lib/channel/object_registry.h @@ -19,6 +19,8 @@ #ifndef GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H #define GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H +#include + #include // TODO(ncteisen): convert this file to C++ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 18ff89d5bb1..4813855de83 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -189,7 +189,7 @@ grpc_channel* grpc_channel_create_with_builder( return channel; } -char* grpc_channel_get_trace(grpc_channel* channel, bool recursive) { +char* grpc_channel_get_trace(grpc_channel* channel, int recursive) { return channel->tracer->RenderTrace(recursive); } diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index c045480ff46..1c042739a89 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -68,6 +68,8 @@ grpc_channel_get_info_type grpc_channel_get_info_import; grpc_insecure_channel_create_type grpc_insecure_channel_create_import; grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; grpc_channel_destroy_type grpc_channel_destroy_import; +grpc_channel_get_trace_type grpc_channel_get_trace_import; +grpc_channel_get_uuid_type grpc_channel_get_uuid_import; grpc_call_cancel_type grpc_call_cancel_import; grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; grpc_call_ref_type grpc_call_ref_import; @@ -304,6 +306,8 @@ void grpc_rb_load_imports(HMODULE library) { grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create"); grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create"); grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy"); + grpc_channel_get_trace_import = (grpc_channel_get_trace_type) GetProcAddress(library, "grpc_channel_get_trace"); + grpc_channel_get_uuid_import = (grpc_channel_get_uuid_type) GetProcAddress(library, "grpc_channel_get_uuid"); grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel"); grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status"); grpc_call_ref_import = (grpc_call_ref_type) GetProcAddress(library, "grpc_call_ref"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 4f07452c685..2c640adb874 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -179,6 +179,12 @@ extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_impo typedef void(*grpc_channel_destroy_type)(grpc_channel* channel); extern grpc_channel_destroy_type grpc_channel_destroy_import; #define grpc_channel_destroy grpc_channel_destroy_import +typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel, bool recursive); +extern grpc_channel_get_trace_type grpc_channel_get_trace_import; +#define grpc_channel_get_trace grpc_channel_get_trace_import +typedef intptr_t(*grpc_channel_get_uuid_type)(grpc_channel* channel); +extern grpc_channel_get_uuid_type grpc_channel_get_uuid_import; +#define grpc_channel_get_uuid grpc_channel_get_uuid_import typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call* call, void* reserved); extern grpc_call_cancel_type grpc_call_cancel_import; #define grpc_call_cancel grpc_call_cancel_import diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index bd4dc0b60e3..d858603e478 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -106,6 +106,8 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_insecure_channel_create); printf("%lx", (unsigned long) grpc_lame_client_channel_create); printf("%lx", (unsigned long) grpc_channel_destroy); + printf("%lx", (unsigned long) grpc_channel_get_trace); + printf("%lx", (unsigned long) grpc_channel_get_uuid); printf("%lx", (unsigned long) grpc_call_cancel); printf("%lx", (unsigned long) grpc_call_cancel_with_status); printf("%lx", (unsigned long) grpc_call_ref); From 21687ea63fc26f37890f51dd357ee3e8a71cf866 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 2 Mar 2018 14:15:05 -0800 Subject: [PATCH 39/67] fix mem leak --- src/core/lib/channel/channel_tracer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 6e3cd35db9d..801fc0a95cb 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -100,7 +100,7 @@ ChannelTrace::~ChannelTrace() { while (it != nullptr) { TraceEvent* to_free = it; it = it->next_; - gpr_free(to_free); + Delete(to_free); } gpr_mu_destroy(&tracer_mu_); } @@ -123,7 +123,7 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { if (list_size_ > max_list_size_) { TraceEvent* to_free = head_trace_; head_trace_ = head_trace_->next_; - gpr_free(to_free); + Delete(to_free); --list_size_; } } From 77917688b92974a716b608325b757a907b367047 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 2 Mar 2018 14:30:41 -0800 Subject: [PATCH 40/67] reviewer feedback --- src/core/lib/channel/channel_tracer.cc | 58 ++++++-------------------- src/core/lib/channel/channel_tracer.h | 43 ++++++++++++++++++- 2 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 801fc0a95cb..092a22fcf05 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -38,46 +38,11 @@ namespace grpc_core { -class TraceEvent { - public: - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) - : data_(data), - error_(error), - connectivity_state_(connectivity_state), - next_(nullptr), - referenced_tracer_(std::move(referenced_tracer)) { - time_created_ = gpr_now(GPR_CLOCK_REALTIME); - } - - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) - : data_(data), - error_(error), - connectivity_state_(connectivity_state), - next_(nullptr), - referenced_tracer_(nullptr) { - time_created_ = gpr_now(GPR_CLOCK_REALTIME); - } - - ~TraceEvent() { - GRPC_ERROR_UNREF(error_); - referenced_tracer_.reset(); - grpc_slice_unref_internal(data_); - } - - private: - friend class ChannelTrace; - friend class ChannelTraceRenderer; - grpc_slice data_; - grpc_error* error_; - gpr_timespec time_created_; - grpc_connectivity_state connectivity_state_; - TraceEvent* next_; - // the tracer object for the (sub)channel that this trace event refers to. - RefCountedPtr referenced_tracer_; -}; +ChannelTrace::TraceEvent::~TraceEvent() { + GRPC_ERROR_UNREF(error_); + referenced_tracer_.reset(); + grpc_slice_unref_internal(data_); +} ChannelTrace::ChannelTrace(size_t max_events) : channel_uuid_(-1), @@ -99,7 +64,7 @@ ChannelTrace::~ChannelTrace() { TraceEvent* it = head_trace_; while (it != nullptr) { TraceEvent* to_free = it; - it = it->next_; + it = it->next(); Delete(to_free); } gpr_mu_destroy(&tracer_mu_); @@ -115,14 +80,14 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { } // regular event add case else { - tail_trace_->next_ = new_trace_event; - tail_trace_ = tail_trace_->next_; + tail_trace_->set_next(new_trace_event); + tail_trace_ = tail_trace_->next(); } ++list_size_; // maybe garbage collect the end if (list_size_ > max_list_size_) { TraceEvent* to_free = head_trace_; - head_trace_ = head_trace_->next_; + head_trace_ = head_trace_->next(); Delete(to_free); --list_size_; } @@ -238,7 +203,7 @@ class ChannelTraceRenderer { // Iterated over the list of TraceEvents and populates their data. void PopulateNodeList(grpc_json* nodes, grpc_json* children) { grpc_json* child = nullptr; - TraceEvent* it = current_tracer_->head_trace_; + ChannelTrace::TraceEvent* it = current_tracer_->head_trace_; while (it != nullptr) { child = grpc_json_create_child(child, nodes, nullptr, nullptr, GRPC_JSON_OBJECT, false); @@ -250,7 +215,8 @@ class ChannelTraceRenderer { // Fills in all the data for a single TraceEvent. If children is not null // and the TraceEvent refers to a child Tracer object and recursive_ is true, // then that child object will be rendered into the trace. - void PopulateNode(TraceEvent* node, grpc_json* json, grpc_json* children) { + void PopulateNode(ChannelTrace::TraceEvent* node, grpc_json* json, + grpc_json* children) { grpc_json* child = nullptr; child = grpc_json_create_child(child, json, "data", grpc_slice_to_c_string(node->data_), diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index e2a0442a26c..4547a0fb0be 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -29,8 +29,6 @@ namespace grpc_core { -class TraceEvent; - class ChannelTrace : public RefCounted { public: ChannelTrace(size_t max_events); @@ -59,6 +57,47 @@ class ChannelTrace : public RefCounted { char* RenderTrace(bool recursive); private: + // Private class to encapsulate all the data and bookkeeping needed for a + // a trace event. + class TraceEvent { + public: + TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) + : data_(data), + error_(error), + connectivity_state_(connectivity_state), + next_(nullptr), + referenced_tracer_(std::move(referenced_tracer)) { + time_created_ = gpr_now(GPR_CLOCK_REALTIME); + } + + TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) + : data_(data), + error_(error), + connectivity_state_(connectivity_state), + next_(nullptr), + referenced_tracer_(nullptr) { + time_created_ = gpr_now(GPR_CLOCK_REALTIME); + } + + ~TraceEvent(); + + TraceEvent* next() { return next_; } + void set_next(TraceEvent* next) { next_ = next; } + + private: + friend class ChannelTraceRenderer; + grpc_slice data_; + grpc_error* error_; + gpr_timespec time_created_; + grpc_connectivity_state connectivity_state_; + TraceEvent* next_; + // the tracer object for the (sub)channel that this trace event refers to. + RefCountedPtr referenced_tracer_; + }; // TraceEvent + // Internal helper to add and link in a trace event void AddTraceEventHelper(TraceEvent* new_trace_event); From cd6755b13c7227dbfea2f8f8385b41eca15da8ca Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 2 Mar 2018 15:16:50 -0800 Subject: [PATCH 41/67] Re write rendered --- include/grpc/grpc.h | 5 +- src/core/lib/channel/channel_tracer.cc | 191 ++++++------------------- src/core/lib/channel/channel_tracer.h | 39 +++-- src/core/lib/surface/channel.cc | 4 +- 4 files changed, 76 insertions(+), 163 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index e3b60a93a28..5c6cabb3802 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,9 +286,8 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); -/** Returns the JSON formatted channel trace for this channel. If recursive - is non 0, it will render all of the trace for this channel's subchannels. */ -GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel, int recursive); +/** Returns the JSON formatted channel trace for this channel. */ +GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel); /** Returns the channel uuid, which can be used to look up its trace at a later time. */ diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 092a22fcf05..86b7a6cce92 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -123,156 +123,59 @@ char* fmt_time(gpr_timespec tm) { } // anonymous namespace -class ChannelTraceRenderer { - public: - // If recursive==true, then the entire tree of trace will be rendered. - // If not, then only the top level data will be. - ChannelTraceRenderer(ChannelTrace* tracer, bool recursive) - : current_tracer_(tracer), - recursive_(recursive), - seen_tracers_(nullptr), - size_(0), - cap_(0) {} - - // Renders the trace and returns an allocated char* with the formatted JSON - char* Run() { - grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); - AddSeenTracer(current_tracer_); - RecursivelyPopulateJson(json); - gpr_free(seen_tracers_); - char* json_str = grpc_json_dump_to_string(json, 0); - grpc_json_destroy(json); - return json_str; - } - - private: - // tracks that a tracer has already been rendered to avoid infinite - // recursion. - void AddSeenTracer(ChannelTrace* newly_seen) { - if (size_ >= cap_) { - cap_ = GPR_MAX(5 * sizeof(newly_seen), 3 * cap_ / 2); - seen_tracers_ = (ChannelTrace**)gpr_realloc(seen_tracers_, cap_); - } - seen_tracers_[size_++] = newly_seen; +void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { + grpc_json* json_iterator = nullptr; + json_iterator = grpc_json_create_child(json_iterator, json, "description", + grpc_slice_to_c_string(data_), + GRPC_JSON_STRING, true); + // TODO(ncteisen): Either format this as google.rpc.Status here, or ensure + // it is done in the layers above core. + if (error_ != GRPC_ERROR_NONE) { + json_iterator = grpc_json_create_child( + json_iterator, json, "status", gpr_strdup(grpc_error_string(error_)), + GRPC_JSON_STRING, true); } - - // Checks if a tracer has already been seen. - bool TracerAlreadySeen(ChannelTrace* tracer) { - for (size_t i = 0; i < size_; ++i) { - if (seen_tracers_[i] == tracer) return true; - } - return false; - } - - // Recursively fills up json by walking over all of the trace of - // current_tracer_. Starts at the top level, by creating the fields - // channelData, and childData. - void RecursivelyPopulateJson(grpc_json* json) { - grpc_json* channel_data = grpc_json_create_child( - nullptr, json, "channelData", nullptr, GRPC_JSON_OBJECT, false); - grpc_json* children = nullptr; - if (recursive_) { - children = grpc_json_create_child(channel_data, json, "childData", - nullptr, GRPC_JSON_ARRAY, false); - } - PopulateChannelData(channel_data, children); - } - - // Fills up the channelData object. If children is not null, it will - // recursively populate each referenced child as it passes that event. - void PopulateChannelData(grpc_json* channel_data, grpc_json* children) { - grpc_json* child = nullptr; + json_iterator = + grpc_json_create_child(json_iterator, json, "timestamp", + fmt_time(time_created_), GRPC_JSON_STRING, true); + json_iterator = + grpc_json_create_child(json_iterator, json, "state", + grpc_connectivity_state_name(connectivity_state_), + GRPC_JSON_STRING, false); + if (referenced_tracer_ != nullptr) { char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, current_tracer_->channel_uuid_); - child = grpc_json_create_child(child, channel_data, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - char* num_events_logged_str; - gpr_asprintf(&num_events_logged_str, "%" PRId64, - current_tracer_->num_events_logged_); - child = - grpc_json_create_child(child, channel_data, "numNodesLogged", - num_events_logged_str, GRPC_JSON_NUMBER, true); - child = grpc_json_create_child(child, channel_data, "startTime", - fmt_time(current_tracer_->time_created_), - GRPC_JSON_STRING, true); - child = grpc_json_create_child(child, channel_data, "nodes", nullptr, - GRPC_JSON_ARRAY, false); - PopulateNodeList(child, children); + gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); + json_iterator = grpc_json_create_child(json_iterator, json, "child_ref", + uuid_str, GRPC_JSON_NUMBER, true); } +} - // Iterated over the list of TraceEvents and populates their data. - void PopulateNodeList(grpc_json* nodes, grpc_json* children) { - grpc_json* child = nullptr; - ChannelTrace::TraceEvent* it = current_tracer_->head_trace_; - while (it != nullptr) { - child = grpc_json_create_child(child, nodes, nullptr, nullptr, - GRPC_JSON_OBJECT, false); - PopulateNode(it, child, children); - it = it->next_; - } - } - - // Fills in all the data for a single TraceEvent. If children is not null - // and the TraceEvent refers to a child Tracer object and recursive_ is true, - // then that child object will be rendered into the trace. - void PopulateNode(ChannelTrace::TraceEvent* node, grpc_json* json, - grpc_json* children) { - grpc_json* child = nullptr; - child = grpc_json_create_child(child, json, "data", - grpc_slice_to_c_string(node->data_), - GRPC_JSON_STRING, true); - if (node->error_ != GRPC_ERROR_NONE) { - child = grpc_json_create_child( - child, json, "error", gpr_strdup(grpc_error_string(node->error_)), - GRPC_JSON_STRING, true); - } - child = grpc_json_create_child(child, json, "time", - fmt_time(node->time_created_), - GRPC_JSON_STRING, true); - child = grpc_json_create_child( - child, json, "state", - grpc_connectivity_state_name(node->connectivity_state_), - GRPC_JSON_STRING, false); - if (node->referenced_tracer_ != nullptr) { - char* uuid_str; - gpr_asprintf(&uuid_str, "%" PRIdPTR, - node->referenced_tracer_->channel_uuid_); - child = grpc_json_create_child(child, json, "uuid", uuid_str, - GRPC_JSON_NUMBER, true); - - // If we are recursively populating everything, and this node - // references a tracer we haven't seen yet, we render that tracer - // in full, adding it to the parent JSON's "children" field. - if (children && !TracerAlreadySeen(node->referenced_tracer_.get())) { - grpc_json* referenced_tracer = grpc_json_create_child( - nullptr, children, nullptr, nullptr, GRPC_JSON_OBJECT, false); - AddSeenTracer(node->referenced_tracer_.get()); - ChannelTrace* saved = current_tracer_; - current_tracer_ = node->referenced_tracer_.get(); - RecursivelyPopulateJson(referenced_tracer); - current_tracer_ = saved; - } - } - } - - // Tracks the current tracer we are rendering as we walk the tree of tracers. - ChannelTrace* current_tracer_; - - // If true, we will render the data of all of this tracer's children. - bool recursive_; - - // These members are used to track tracers we have already rendered. This is - // a dynamically growing array that is deallocated when the rendering is done. - ChannelTrace** seen_tracers_; - size_t size_; - size_t cap_; -}; - -char* ChannelTrace::RenderTrace(bool recursive) { +char* ChannelTrace::RenderTrace() { if (!max_list_size_) return nullptr; // tracing is disabled if max_events == 0 - ChannelTraceRenderer renderer(this, recursive); - return renderer.Run(); + grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); + char* num_events_logged_str; + gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_); + grpc_json* json_iterator = nullptr; + json_iterator = + grpc_json_create_child(json_iterator, json, "num_events_logged", + num_events_logged_str, GRPC_JSON_NUMBER, true); + json_iterator = + grpc_json_create_child(json_iterator, json, "creation_time", + fmt_time(time_created_), GRPC_JSON_STRING, true); + grpc_json* events = grpc_json_create_child(json_iterator, json, "events", + nullptr, GRPC_JSON_ARRAY, false); + json_iterator = nullptr; + TraceEvent* it = head_trace_; + while (it != nullptr) { + json_iterator = grpc_json_create_child(json_iterator, events, nullptr, + nullptr, GRPC_JSON_OBJECT, false); + it->RenderTraceEvent(json_iterator); + it = it->next(); + } + char* json_str = grpc_json_dump_to_string(json, 0); + grpc_json_destroy(json); + return json_str; } } // namespace grpc_core diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 4547a0fb0be..976e66c49e9 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -29,38 +29,44 @@ namespace grpc_core { +// Object used to hold live data for a channel. This data is exposed via the +// channelz service: +// https://github.com/grpc/proposal/blob/master/A14-channelz.md class ChannelTrace : public RefCounted { public: ChannelTrace(size_t max_events); ~ChannelTrace(); - /* returns the tracer's uuid */ + // returns the tracer's uuid intptr_t GetUuid(); - /* Adds a new trace event to the tracing object */ + // Adds a new trace event to the tracing object void AddTraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state); - /* Adds a new trace event to the tracing object. This trace event refers to a - an event on a child of the channel. For example this could log when a - particular subchannel becomes connected. - TODO(ncteisen): Once channelz is implemented, the events should reference - the channelz object, not the channel trace. */ + // Adds a new trace event to the tracing object. This trace event refers to a + // an event on a child of the channel. For example, if this channel has + // created a new subchannel, then it would record that with a TraceEvent + // referencing the new subchannel. + + // TODO(ncteisen): Once channelz is implemented, the events should reference + // the overall channelz object, not just the ChannelTrace object. void AddTraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer); - /* Returns the tracing data rendered as a grpc json string. - The string is owned by the caller and must be freed. If recursive - is true, then the string will include the recursive trace for all - subtracing objects. */ - char* RenderTrace(bool recursive); + // Returns the tracing data rendered as a grpc json string. + // The string is owned by the caller and must be freed. + char* RenderTrace(); private: // Private class to encapsulate all the data and bookkeeping needed for a // a trace event. class TraceEvent { public: + // Constructor for a TraceEvent that references a different channel. + // TODO(ncteisen): once channelz is implemented, this should reference the + // overall channelz object, not just the ChannelTrace object TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer) @@ -72,6 +78,8 @@ class ChannelTrace : public RefCounted { time_created_ = gpr_now(GPR_CLOCK_REALTIME); } + // Constructor for a TraceEvent that does not reverence a different + // channel. TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state) : data_(data), @@ -84,11 +92,15 @@ class ChannelTrace : public RefCounted { ~TraceEvent(); + // Renders the data inside of this TraceEvent into a json object. This is + // used by the ChannelTrace, when it is rendering itself. + void RenderTraceEvent(grpc_json* json); + + // set and get for the next_ pointer. TraceEvent* next() { return next_; } void set_next(TraceEvent* next) { next_ = next; } private: - friend class ChannelTraceRenderer; grpc_slice data_; grpc_error* error_; gpr_timespec time_created_; @@ -101,7 +113,6 @@ class ChannelTrace : public RefCounted { // Internal helper to add and link in a trace event void AddTraceEventHelper(TraceEvent* new_trace_event); - friend class ChannelTraceRenderer; gpr_mu tracer_mu_; intptr_t channel_uuid_; uint64_t num_events_logged_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 4813855de83..1488736c499 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -189,8 +189,8 @@ grpc_channel* grpc_channel_create_with_builder( return channel; } -char* grpc_channel_get_trace(grpc_channel* channel, int recursive) { - return channel->tracer->RenderTrace(recursive); +char* grpc_channel_get_trace(grpc_channel* channel) { + return channel->tracer->RenderTrace(); } intptr_t grpc_channel_get_uuid(grpc_channel* channel) { From 72c443187b672edf389ce6d59d2b0b4826aef2b4 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 2 Mar 2018 15:31:33 -0800 Subject: [PATCH 42/67] Fix test --- test/core/channel/channel_tracer_test.cc | 27 ++++++------------------ test/core/util/channel_tracing_utils.cc | 21 +++++++++--------- test/core/util/channel_tracing_utils.h | 4 ++-- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 1f2ed33e334..78d4dad0b1d 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -42,13 +42,13 @@ static void add_simple_trace_event(RefCountedPtr tracer) { // checks for the existence of all the required members of the tracer. static void validate_tracer(RefCountedPtr tracer, - size_t expected_num_nodes_logged, + size_t expected_num_event_logged, size_t max_nodes) { if (!max_nodes) return; - char* json_str = tracer->RenderTrace(true); + char* json_str = tracer->RenderTrace(); grpc_json* json = grpc_json_parse_string(json_str); - validate_channel_trace_data(json, expected_num_nodes_logged, - GPR_MIN(expected_num_nodes_logged, max_nodes)); + validate_channel_trace_data(json, expected_num_event_logged, + GPR_MIN(expected_num_event_logged, max_nodes)); grpc_json_destroy(json); gpr_free(json_str); } @@ -57,28 +57,18 @@ static void validate_tracer_data_matches_uuid_lookup( RefCountedPtr tracer) { intptr_t uuid = tracer->GetUuid(); if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled - char* tracer_json_str = tracer->RenderTrace(true); + char* tracer_json_str = tracer->RenderTrace(); void* object; grpc_object_registry_type type = grpc_object_registry_get_object(uuid, &object); GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); char* uuid_lookup_json_str = - static_cast(object)->RenderTrace(true); + static_cast(object)->RenderTrace(); GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); gpr_free(tracer_json_str); gpr_free(uuid_lookup_json_str); } -// ensures the tracer has the correct number of children tracers. -static void validate_children(RefCountedPtr tracer, - size_t expected_num_children) { - char* json_str = tracer->RenderTrace(true); - grpc_json* json = grpc_json_parse_string(json_str); - validate_json_array_size(json, "childData", expected_num_children); - grpc_json_destroy(json); - gpr_free(json_str); -} - // Tests basic ChannelTrace functionality like construction, adding trace, and // lookups by uuid. static void test_basic_channel_tracing(size_t max_nodes) { @@ -182,27 +172,22 @@ static void test_nesting() { RefCountedPtr sc1 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - // channel has only one subchannel right here. - validate_children(tracer, 1); add_simple_trace_event(sc1); RefCountedPtr conn1 = MakeRefCounted(5); // nesting one level deeper. sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); - validate_children(sc1, 1); add_simple_trace_event(conn1); add_simple_trace_event(tracer); add_simple_trace_event(tracer); RefCountedPtr sc2 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - validate_children(tracer, 2); // this trace should not get added to the parents children since it is already // present in the tracer. tracer->AddTraceEvent( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_children(tracer, 2); add_simple_trace_event(tracer); tracer.reset(nullptr); sc1.reset(nullptr); diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index 8262776f298..7733098871a 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -46,17 +46,16 @@ void validate_json_array_size(grpc_json* json, const char* key, } void validate_channel_trace_data(grpc_json* json, - size_t num_nodes_logged_expected, - size_t actual_num_nodes_expected) { + size_t num_events_logged_expected, + size_t actual_num_events_expected) { GPR_ASSERT(json); - grpc_json* channel_data = get_json_child(json, "channelData"); - grpc_json* num_nodes_logged_json = - get_json_child(channel_data, "numNodesLogged"); - GPR_ASSERT(num_nodes_logged_json); - grpc_json* start_time = get_json_child(channel_data, "startTime"); + grpc_json* num_events_logged_json = + get_json_child(json, "num_events_logged"); + GPR_ASSERT(num_events_logged_json); + grpc_json* start_time = get_json_child(json, "creation_time"); GPR_ASSERT(start_time); - size_t num_nodes_logged = - (size_t)strtol(num_nodes_logged_json->value, nullptr, 0); - GPR_ASSERT(num_nodes_logged == num_nodes_logged_expected); - validate_json_array_size(channel_data, "nodes", actual_num_nodes_expected); + size_t num_events_logged = + (size_t)strtol(num_events_logged_json->value, nullptr, 0); + GPR_ASSERT(num_events_logged == num_events_logged_expected); + validate_json_array_size(json, "events", actual_num_events_expected); } diff --git a/test/core/util/channel_tracing_utils.h b/test/core/util/channel_tracing_utils.h index 7eac114cc53..fc04d8bae68 100644 --- a/test/core/util/channel_tracing_utils.h +++ b/test/core/util/channel_tracing_utils.h @@ -25,7 +25,7 @@ void validate_json_array_size(grpc_json* json, const char* key, size_t expected_size); void validate_channel_trace_data(grpc_json* json, - size_t num_nodes_logged_expected, - size_t actual_num_nodes_expected); + size_t num_events_logged_expected, + size_t actual_num_events_expected); #endif /* GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H */ From c1284576f81efc4b2d9c33c4337d8c9fbafc29de Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 2 Mar 2018 16:20:50 -0800 Subject: [PATCH 43/67] Fix build and sanity --- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 2 +- test/core/util/channel_tracing_utils.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 2c640adb874..9a09321364b 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -179,7 +179,7 @@ extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_impo typedef void(*grpc_channel_destroy_type)(grpc_channel* channel); extern grpc_channel_destroy_type grpc_channel_destroy_import; #define grpc_channel_destroy grpc_channel_destroy_import -typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel, bool recursive); +typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel); extern grpc_channel_get_trace_type grpc_channel_get_trace_import; #define grpc_channel_get_trace grpc_channel_get_trace_import typedef intptr_t(*grpc_channel_get_uuid_type)(grpc_channel* channel); diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index 7733098871a..a2449cc4bd2 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -49,8 +49,7 @@ void validate_channel_trace_data(grpc_json* json, size_t num_events_logged_expected, size_t actual_num_events_expected) { GPR_ASSERT(json); - grpc_json* num_events_logged_json = - get_json_child(json, "num_events_logged"); + grpc_json* num_events_logged_json = get_json_child(json, "num_events_logged"); GPR_ASSERT(num_events_logged_json); grpc_json* start_time = get_json_child(json, "creation_time"); GPR_ASSERT(start_time); From ac945eba98a11795faaa41b5d93fe27a8b5a89df Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 5 Mar 2018 22:23:23 -0800 Subject: [PATCH 44/67] Reviewer comments --- include/grpc/grpc.h | 3 ++- src/core/lib/channel/channel_tracer.cc | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 5c6cabb3802..dd8a5d7d5f8 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -286,7 +286,8 @@ GRPCAPI grpc_channel* grpc_lame_client_channel_create( /** Close and destroy a grpc channel */ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); -/** Returns the JSON formatted channel trace for this channel. */ +/** Returns the JSON formatted channel trace for this channel. The caller + owns the returned string and is responsible for freeing it. */ GRPCAPI char* grpc_channel_get_trace(grpc_channel* channel); /** Returns the channel uuid, which can be used to look up its trace at a diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 86b7a6cce92..fdb96570cdc 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -27,6 +27,7 @@ #include #include +#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" @@ -35,12 +36,12 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/connectivity_state.h" +#include "src/core/lib/transport/error_utils.h" namespace grpc_core { ChannelTrace::TraceEvent::~TraceEvent() { GRPC_ERROR_UNREF(error_); - referenced_tracer_.reset(); grpc_slice_unref_internal(data_); } @@ -56,7 +57,8 @@ ChannelTrace::ChannelTrace(size_t max_events) gpr_mu_init(&tracer_mu_); channel_uuid_ = grpc_object_registry_register_object( this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - time_created_ = gpr_now(GPR_CLOCK_REALTIME); + time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME); } ChannelTrace::~ChannelTrace() { @@ -131,9 +133,20 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { // TODO(ncteisen): Either format this as google.rpc.Status here, or ensure // it is done in the layers above core. if (error_ != GRPC_ERROR_NONE) { - json_iterator = grpc_json_create_child( - json_iterator, json, "status", gpr_strdup(grpc_error_string(error_)), - GRPC_JSON_STRING, true); + grpc_status_code code; + grpc_slice message; + grpc_error_get_status(error_, GRPC_MILLIS_INF_FUTURE, &code, &message, + nullptr, nullptr); + grpc_json* status = grpc_json_create_child( + json_iterator, json, "status", nullptr, GRPC_JSON_OBJECT, false); + json_iterator = grpc_json_create_child(nullptr, status, "code", + grpc_status_code_to_string(code), + GRPC_JSON_STRING, false); + grpc_json_create_child(json_iterator, status, "message", + grpc_slice_to_c_string(message), GRPC_JSON_STRING, + true); + grpc_slice_unref_internal(message); + json_iterator = status; } json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", From 7d90d5497c2115599665728056c818efc575b4c4 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 5 Mar 2018 22:53:44 -0800 Subject: [PATCH 45/67] Reviewer feedback --- CMakeLists.txt | 66 ++++++++------- Makefile | 84 +++++++++++-------- build.yaml | 26 +++--- src/core/lib/channel/channel_tracer.cc | 29 ++++++- src/core/lib/channel/channel_tracer.h | 28 ++----- src/core/lib/surface/channel.cc | 5 +- test/core/channel/channel_tracer_test.cc | 25 +++--- .../generated/sources_and_headers.json | 36 ++++---- tools/run_tests/generated/tests.json | 48 +++++------ 9 files changed, 192 insertions(+), 155 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c80744d827c..93d3b129624 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -283,7 +283,6 @@ add_dependencies(buildtests_c grpc_byte_buffer_reader_test) add_dependencies(buildtests_c grpc_channel_args_test) add_dependencies(buildtests_c grpc_channel_stack_builder_test) add_dependencies(buildtests_c grpc_channel_stack_test) -add_dependencies(buildtests_c grpc_channel_tracer_test) add_dependencies(buildtests_c grpc_completion_queue_test) add_dependencies(buildtests_c grpc_completion_queue_threading_test) add_dependencies(buildtests_c grpc_credentials_test) @@ -518,6 +517,7 @@ add_dependencies(buildtests_cxx bm_pollset) endif() add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) +add_dependencies(buildtests_cxx channel_tracer_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) add_dependencies(buildtests_cxx cli_call_test) add_dependencies(buildtests_cxx client_channel_stress_test) @@ -6559,33 +6559,6 @@ target_link_libraries(grpc_channel_stack_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(grpc_channel_tracer_test - test/core/channel/channel_tracer_test.cc -) - - -target_include_directories(grpc_channel_tracer_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} -) - -target_link_libraries(grpc_channel_tracer_test - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc - gpr_test_util - gpr -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(grpc_completion_queue_test test/core/surface/completion_queue_test.cc ) @@ -9512,6 +9485,43 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(channel_tracer_test + test/core/channel/channel_tracer_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(channel_tracer_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(channel_tracer_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++ + grpc + gpr_test_util + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(chttp2_settings_timeout_test test/core/transport/chttp2/settings_timeout_test.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index 02a72910ff1..d5777d0e106 100644 --- a/Makefile +++ b/Makefile @@ -1006,7 +1006,6 @@ grpc_byte_buffer_reader_test: $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test grpc_channel_args_test: $(BINDIR)/$(CONFIG)/grpc_channel_args_test grpc_channel_stack_builder_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test grpc_channel_stack_test: $(BINDIR)/$(CONFIG)/grpc_channel_stack_test -grpc_channel_tracer_test: $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test grpc_completion_queue_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_test grpc_completion_queue_threading_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt @@ -1115,6 +1114,7 @@ bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test +channel_tracer_test: $(BINDIR)/$(CONFIG)/channel_tracer_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test client_channel_stress_test: $(BINDIR)/$(CONFIG)/client_channel_stress_test @@ -1425,7 +1425,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/grpc_channel_args_test \ $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test \ $(BINDIR)/$(CONFIG)/grpc_channel_stack_test \ - $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \ $(BINDIR)/$(CONFIG)/grpc_credentials_test \ @@ -1584,6 +1583,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_tracer_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -1732,6 +1732,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_tracer_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -1918,8 +1919,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_stack_builder_test || ( echo test grpc_channel_stack_builder_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_channel_stack_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_stack_test || ( echo test grpc_channel_stack_test failed ; exit 1 ) - $(E) "[RUN] Testing grpc_channel_tracer_test" - $(Q) $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test || ( echo test grpc_channel_tracer_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_completion_queue_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_test || ( echo test grpc_completion_queue_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_completion_queue_threading_test" @@ -2130,6 +2129,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) + $(E) "[RUN] Testing channel_tracer_test" + $(Q) $(BINDIR)/$(CONFIG)/channel_tracer_test || ( echo test channel_tracer_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_settings_timeout_test" $(Q) $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test || ( echo test chttp2_settings_timeout_test failed ; exit 1 ) $(E) "[RUN] Testing cli_call_test" @@ -11414,38 +11415,6 @@ endif endif -GRPC_CHANNEL_TRACER_TEST_SRC = \ - test/core/channel/channel_tracer_test.cc \ - -GRPC_CHANNEL_TRACER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CHANNEL_TRACER_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/grpc_channel_tracer_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/grpc_channel_tracer_test: $(GRPC_CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GRPC_CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_channel_tracer_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/channel/channel_tracer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_grpc_channel_tracer_test: $(GRPC_CHANNEL_TRACER_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GRPC_CHANNEL_TRACER_TEST_OBJS:.o=.dep) -endif -endif - - GRPC_COMPLETION_QUEUE_TEST_SRC = \ test/core/surface/completion_queue_test.cc \ @@ -15165,6 +15134,49 @@ endif endif +CHANNEL_TRACER_TEST_SRC = \ + test/core/channel/channel_tracer_test.cc \ + +CHANNEL_TRACER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACER_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/channel_tracer_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/channel_tracer_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/channel_tracer_test: $(PROTOBUF_DEP) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_tracer_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_tracer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_channel_tracer_test: $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) +endif +endif + + CHTTP2_SETTINGS_TIMEOUT_TEST_SRC = \ test/core/transport/chttp2/settings_timeout_test.cc \ diff --git a/build.yaml b/build.yaml index d03b7a113c0..bdc6db8d8d9 100644 --- a/build.yaml +++ b/build.yaml @@ -2432,17 +2432,6 @@ targets: - gpr_test_util - gpr uses_polling: false -- name: grpc_channel_tracer_test - build: test - language: c - src: - - test/core/channel/channel_tracer_test.cc - deps: - - grpc_test_util - - grpc - - gpr_test_util - - gpr - uses_polling: false - name: grpc_completion_queue_test build: test language: c @@ -3896,6 +3885,21 @@ targets: - grpc - gpr uses_polling: false +- name: channel_tracer_test + gtest: true + build: test + language: c++ + src: + - test/core/channel/channel_tracer_test.cc + deps: + - grpc_test_util + - grpc++ + - grpc + - gpr_test_util + - gpr + uses: + - grpc++_test + uses_polling: false - name: chttp2_settings_timeout_test gtest: true build: test diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index fdb96570cdc..38a5b1ee202 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -40,6 +40,27 @@ namespace grpc_core { +ChannelTrace::TraceEvent::TraceEvent( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) + : data_(data), + error_(error), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + connectivity_state_(connectivity_state), + next_(nullptr), + referenced_tracer_(std::move(referenced_tracer)) {} + +ChannelTrace::TraceEvent::TraceEvent(grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state) + : data_(data), + error_(error), + timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), + GPR_CLOCK_REALTIME)), + connectivity_state_(connectivity_state), + next_(nullptr) {} + ChannelTrace::TraceEvent::~TraceEvent() { GRPC_ERROR_UNREF(error_); grpc_slice_unref_internal(data_); @@ -72,7 +93,7 @@ ChannelTrace::~ChannelTrace() { gpr_mu_destroy(&tracer_mu_); } -intptr_t ChannelTrace::GetUuid() { return channel_uuid_; } +intptr_t ChannelTrace::GetUuid() const { return channel_uuid_; } void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { ++num_events_logged_; @@ -125,7 +146,7 @@ char* fmt_time(gpr_timespec tm) { } // anonymous namespace -void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { +void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { grpc_json* json_iterator = nullptr; json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), @@ -150,7 +171,7 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { } json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", - fmt_time(time_created_), GRPC_JSON_STRING, true); + fmt_time(timestamp_), GRPC_JSON_STRING, true); json_iterator = grpc_json_create_child(json_iterator, json, "state", grpc_connectivity_state_name(connectivity_state_), @@ -163,7 +184,7 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) { } } -char* ChannelTrace::RenderTrace() { +char* ChannelTrace::RenderTrace() const { if (!max_list_size_) return nullptr; // tracing is disabled if max_events == 0 grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT); diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_tracer.h index 976e66c49e9..3339be85e30 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_tracer.h @@ -38,7 +38,7 @@ class ChannelTrace : public RefCounted { ~ChannelTrace(); // returns the tracer's uuid - intptr_t GetUuid(); + intptr_t GetUuid() const; // Adds a new trace event to the tracing object void AddTraceEvent(grpc_slice data, grpc_error* error, @@ -57,7 +57,7 @@ class ChannelTrace : public RefCounted { // Returns the tracing data rendered as a grpc json string. // The string is owned by the caller and must be freed. - char* RenderTrace(); + char* RenderTrace() const; private: // Private class to encapsulate all the data and bookkeeping needed for a @@ -69,41 +69,27 @@ class ChannelTrace : public RefCounted { // overall channelz object, not just the ChannelTrace object TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) - : data_(data), - error_(error), - connectivity_state_(connectivity_state), - next_(nullptr), - referenced_tracer_(std::move(referenced_tracer)) { - time_created_ = gpr_now(GPR_CLOCK_REALTIME); - } + RefCountedPtr referenced_tracer); // Constructor for a TraceEvent that does not reverence a different // channel. TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) - : data_(data), - error_(error), - connectivity_state_(connectivity_state), - next_(nullptr), - referenced_tracer_(nullptr) { - time_created_ = gpr_now(GPR_CLOCK_REALTIME); - } + grpc_connectivity_state connectivity_state); ~TraceEvent(); // Renders the data inside of this TraceEvent into a json object. This is // used by the ChannelTrace, when it is rendering itself. - void RenderTraceEvent(grpc_json* json); + void RenderTraceEvent(grpc_json* json) const; // set and get for the next_ pointer. - TraceEvent* next() { return next_; } + TraceEvent* next() const { return next_; } void set_next(TraceEvent* next) { next_ = next; } private: grpc_slice data_; grpc_error* error_; - gpr_timespec time_created_; + gpr_timespec timestamp_; grpc_connectivity_state connectivity_state_; TraceEvent* next_; // the tracer object for the (sub)channel that this trace event refers to. diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 1488736c499..fb435b98817 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -21,6 +21,7 @@ #include "src/core/lib/surface/channel.h" #include +#include #include #include @@ -173,8 +174,8 @@ grpc_channel* grpc_channel_create_with_builder( } else if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE)) { GPR_ASSERT(channel_tracer_max_nodes == 0); - // max_nodes defaults to 0 (which is off), clamped between 0 and 100. - const grpc_integer_options options = {0, 0, 100}; + // max_nodes defaults to 0 (which is off), clamped between 0 and INT_MAX + const grpc_integer_options options = {0, 0, INT_MAX}; channel_tracer_max_nodes = (size_t)grpc_channel_arg_get_integer(&args->args[i], options); } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 78d4dad0b1d..d76daccbdb1 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -22,6 +22,8 @@ #include #include +#include + #include "src/core/lib/channel/channel_tracer.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/useful.h" @@ -30,9 +32,8 @@ #include "test/core/util/channel_tracing_utils.h" #include "test/core/util/test_config.h" -using grpc_core::ChannelTrace; -using grpc_core::MakeRefCounted; -using grpc_core::RefCountedPtr; +namespace grpc_core { +namespace testing { static void add_simple_trace_event(RefCountedPtr tracer) { tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), @@ -99,7 +100,7 @@ static void test_basic_channel_tracing(size_t max_nodes) { // Calls basic test with various values for max_nodes (including 0, which turns // the tracer off). -static void test_basic_channel_sizing() { +TEST(ChannelTracerTest, BasicTest) { test_basic_channel_tracing(0); test_basic_channel_tracing(1); test_basic_channel_tracing(2); @@ -152,7 +153,7 @@ static void test_complex_channel_tracing(size_t max_nodes) { } // Calls the complex test with a sweep of sizes for max_nodes. -static void test_complex_channel_sizing() { +TEST(ChannelTracerTest, ComplexTest) { test_complex_channel_tracing(0); test_complex_channel_tracing(1); test_complex_channel_tracing(2); @@ -164,7 +165,7 @@ static void test_complex_channel_sizing() { // Test a case in which the parent channel has subchannels and the subchannels // have connections. Ensures that everything lives as long as it should then // gets deleted. -static void test_nesting() { +TEST(ChannelTracerTest, TestNesting) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(10); add_simple_trace_event(tracer); @@ -195,14 +196,14 @@ static void test_nesting() { conn1.reset(nullptr); } +} // namespace testing +} // namespace grpc_core + int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); - test_basic_channel_tracing(5); - test_basic_channel_sizing(); - test_complex_channel_tracing(5); - test_complex_channel_sizing(); - test_nesting(); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); grpc_shutdown(); - return 0; + return ret; } diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 94f45c82caf..e4741fc0d2b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -916,23 +916,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "grpc_channel_tracer_test", - "src": [ - "test/core/channel/channel_tracer_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -2842,6 +2825,25 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc++", + "grpc++_test", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "channel_tracer_test", + "src": [ + "test/core/channel/channel_tracer_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index fdcac9318cb..4d86843f13c 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1223,30 +1223,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "grpc_channel_tracer_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, @@ -3361,6 +3337,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "channel_tracer_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, From 31c05ba668ee6ede5326c669277204a7f778a9ab Mon Sep 17 00:00:00 2001 From: ncteisen Date: Mon, 5 Mar 2018 23:06:12 -0800 Subject: [PATCH 46/67] reviewer feedback, rename --- CMakeLists.txt | 22 +++---- Makefile | 42 +++++++------- build.yaml | 8 +-- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 4 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 8 +-- package.xml | 4 +- .../ext/filters/client_channel/subchannel.cc | 2 +- .../{channel_tracer.cc => channel_trace.cc} | 3 +- .../{channel_tracer.h => channel_trace.h} | 6 +- src/core/lib/surface/channel.cc | 2 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/channel/BUILD | 8 ++- ...l_tracer_test.cc => channel_trace_test.cc} | 58 +++++++++---------- test/core/util/channel_tracing_utils.cc | 2 +- test/core/util/channel_tracing_utils.h | 2 - tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- .../generated/sources_and_headers.json | 10 ++-- tools/run_tests/generated/tests.json | 2 +- 23 files changed, 104 insertions(+), 101 deletions(-) rename src/core/lib/channel/{channel_tracer.cc => channel_trace.cc} (98%) rename src/core/lib/channel/{channel_tracer.h => channel_trace.h} (96%) rename test/core/channel/{channel_tracer_test.cc => channel_trace_test.cc} (84%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93d3b129624..651fb6bde94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -517,7 +517,7 @@ add_dependencies(buildtests_cxx bm_pollset) endif() add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) -add_dependencies(buildtests_cxx channel_tracer_test) +add_dependencies(buildtests_cxx channel_trace_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) add_dependencies(buildtests_cxx cli_call_test) add_dependencies(buildtests_cxx client_channel_stress_test) @@ -800,7 +800,7 @@ add_library(grpc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1144,7 +1144,7 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1475,7 +1475,7 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -1767,7 +1767,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2038,7 +2038,7 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -2843,7 +2843,7 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_tracer.cc + src/core/lib/channel/channel_trace.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc @@ -9485,14 +9485,14 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(channel_tracer_test - test/core/channel/channel_tracer_test.cc +add_executable(channel_trace_test + test/core/channel/channel_trace_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) -target_include_directories(channel_tracer_test +target_include_directories(channel_trace_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${_gRPC_SSL_INCLUDE_DIR} @@ -9508,7 +9508,7 @@ target_include_directories(channel_tracer_test PRIVATE ${_gRPC_PROTO_GENS_DIR} ) -target_link_libraries(channel_tracer_test +target_link_libraries(channel_trace_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util diff --git a/Makefile b/Makefile index d5777d0e106..01bad6692d1 100644 --- a/Makefile +++ b/Makefile @@ -1114,7 +1114,7 @@ bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test -channel_tracer_test: $(BINDIR)/$(CONFIG)/channel_tracer_test +channel_trace_test: $(BINDIR)/$(CONFIG)/channel_trace_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test client_channel_stress_test: $(BINDIR)/$(CONFIG)/client_channel_stress_test @@ -1583,7 +1583,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_tracer_test \ + $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -1732,7 +1732,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_tracer_test \ + $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_channel_stress_test \ @@ -2129,8 +2129,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) - $(E) "[RUN] Testing channel_tracer_test" - $(Q) $(BINDIR)/$(CONFIG)/channel_tracer_test || ( echo test channel_tracer_test failed ; exit 1 ) + $(E) "[RUN] Testing channel_trace_test" + $(Q) $(BINDIR)/$(CONFIG)/channel_trace_test || ( echo test channel_trace_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_settings_timeout_test" $(Q) $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test || ( echo test chttp2_settings_timeout_test failed ; exit 1 ) $(E) "[RUN] Testing cli_call_test" @@ -3040,7 +3040,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3386,7 +3386,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -3718,7 +3718,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4003,7 +4003,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -4254,7 +4254,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -5058,7 +5058,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ @@ -15134,15 +15134,15 @@ endif endif -CHANNEL_TRACER_TEST_SRC = \ - test/core/channel/channel_tracer_test.cc \ +CHANNEL_TRACE_TEST_SRC = \ + test/core/channel/channel_trace_test.cc \ -CHANNEL_TRACER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACER_TEST_SRC)))) +CHANNEL_TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_TEST_SRC)))) ifeq ($(NO_SECURE),true) # You can't build secure targets if you don't have OpenSSL. -$(BINDIR)/$(CONFIG)/channel_tracer_test: openssl_dep_error +$(BINDIR)/$(CONFIG)/channel_trace_test: openssl_dep_error else @@ -15153,26 +15153,26 @@ ifeq ($(NO_PROTOBUF),true) # You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. -$(BINDIR)/$(CONFIG)/channel_tracer_test: protobuf_dep_error +$(BINDIR)/$(CONFIG)/channel_trace_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/channel_tracer_test: $(PROTOBUF_DEP) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/channel_trace_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_tracer_test + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_test endif endif -$(OBJDIR)/$(CONFIG)/test/core/channel/channel_tracer_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a -deps_channel_tracer_test: $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) +deps_channel_trace_test: $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) ifneq ($(NO_DEPS),true) --include $(CHANNEL_TRACER_TEST_OBJS:.o=.dep) +-include $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) endif endif diff --git a/build.yaml b/build.yaml index bdc6db8d8d9..9ef6092e03e 100644 --- a/build.yaml +++ b/build.yaml @@ -154,7 +154,7 @@ filegroups: - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - - src/core/lib/channel/channel_tracer.cc + - src/core/lib/channel/channel_trace.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc @@ -312,7 +312,7 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - - src/core/lib/channel/channel_tracer.h + - src/core/lib/channel/channel_trace.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h @@ -3885,12 +3885,12 @@ targets: - grpc - gpr uses_polling: false -- name: channel_tracer_test +- name: channel_trace_test gtest: true build: test language: c++ src: - - test/core/channel/channel_tracer_test.cc + - test/core/channel/channel_trace_test.cc deps: - grpc_test_util - grpc++ diff --git a/config.m4 b/config.m4 index 5f79cbcb6a3..d53c2f4589f 100644 --- a/config.m4 +++ b/config.m4 @@ -84,7 +84,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ - src/core/lib/channel/channel_tracer.cc \ + src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ diff --git a/config.w32 b/config.w32 index 5471d5cc561..548ae73e31b 100644 --- a/config.w32 +++ b/config.w32 @@ -61,7 +61,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + - "src\\core\\lib\\channel\\channel_tracer.cc " + + "src\\core\\lib\\channel\\channel_trace.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index d9237752c57..4403af53c5e 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -316,7 +316,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -497,7 +497,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6546fe8af2b..852992e6066 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -327,7 +327,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', @@ -473,7 +473,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -825,7 +825,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/channel_tracer.h', + 'src/core/lib/channel/channel_trace.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', diff --git a/grpc.gemspec b/grpc.gemspec index d33333ace9e..a53cdfdfe9e 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -253,7 +253,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) - s.files += %w( src/core/lib/channel/channel_tracer.h ) + s.files += %w( src/core/lib/channel/channel_trace.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) @@ -403,7 +403,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) - s.files += %w( src/core/lib/channel/channel_tracer.cc ) + s.files += %w( src/core/lib/channel/channel_trace.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) diff --git a/grpc.gyp b/grpc.gyp index 9b5ae58ee4c..ca76c680777 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -225,7 +225,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -527,7 +527,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -747,7 +747,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', @@ -945,7 +945,7 @@ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/package.xml b/package.xml index 1cf10540eeb..a0841886a94 100644 --- a/package.xml +++ b/package.xml @@ -260,7 +260,7 @@ - + @@ -410,7 +410,7 @@ - + diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 77c0fe2c430..e8ff352be8a 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -36,7 +36,7 @@ #include "src/core/ext/filters/client_channel/uri_parser.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_trace.cc similarity index 98% rename from src/core/lib/channel/channel_tracer.cc rename to src/core/lib/channel/channel_trace.cc index 38a5b1ee202..3217a83fba2 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -18,7 +18,7 @@ #include -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include #include @@ -129,6 +129,7 @@ void ChannelTrace::AddTraceEvent( void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 AddTraceEventHelper(New(data, error, connectivity_state)); } diff --git a/src/core/lib/channel/channel_tracer.h b/src/core/lib/channel/channel_trace.h similarity index 96% rename from src/core/lib/channel/channel_tracer.h rename to src/core/lib/channel/channel_trace.h index 3339be85e30..536f51a1f6c 100644 --- a/src/core/lib/channel/channel_tracer.h +++ b/src/core/lib/channel/channel_trace.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H -#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H #include @@ -112,4 +112,4 @@ class ChannelTrace : public RefCounted { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACER_H */ +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index fb435b98817..c470f6d0d8e 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -31,7 +31,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index bf8fb90c5f6..3c3c1d69439 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -60,7 +60,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', - 'src/core/lib/channel/channel_tracer.cc', + 'src/core/lib/channel/channel_trace.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index b215aa205cc..633c424eae3 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -67,12 +67,16 @@ grpc_cc_test( ) grpc_cc_test( - name = "channel_tracer_test", - srcs = ["channel_tracer_test.cc"], + name = "channel_trace_test", + srcs = ["channel_trace_test.cc"], + external_deps = [ + "gtest", + ], language = "C++", deps = [ "//:gpr", "//:grpc", + "//:grpc++", "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_trace_test.cc similarity index 84% rename from test/core/channel/channel_tracer_test.cc rename to test/core/channel/channel_trace_test.cc index d76daccbdb1..c0cccb77acd 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -24,7 +24,7 @@ #include -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/object_registry.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -42,7 +42,7 @@ static void add_simple_trace_event(RefCountedPtr tracer) { } // checks for the existence of all the required members of the tracer. -static void validate_tracer(RefCountedPtr tracer, +static void validate_trace(RefCountedPtr tracer, size_t expected_num_event_logged, size_t max_nodes) { if (!max_nodes) return; @@ -54,7 +54,7 @@ static void validate_tracer(RefCountedPtr tracer, gpr_free(json_str); } -static void validate_tracer_data_matches_uuid_lookup( +static void validate_trace_data_matches_uuid_lookup( RefCountedPtr tracer) { intptr_t uuid = tracer->GetUuid(); if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled @@ -72,12 +72,12 @@ static void validate_tracer_data_matches_uuid_lookup( // Tests basic ChannelTrace functionality like construction, adding trace, and // lookups by uuid. -static void test_basic_channel_tracing(size_t max_nodes) { +static void test_basic_channel_trace(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); add_simple_trace_event(tracer); add_simple_trace_event(tracer); - validate_tracer_data_matches_uuid_lookup(tracer); + validate_trace_data_matches_uuid_lookup(tracer); tracer->AddTraceEvent( grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), @@ -85,34 +85,34 @@ static void test_basic_channel_tracing(size_t max_nodes) { GRPC_CHANNEL_IDLE); tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); - validate_tracer(tracer, 4, max_nodes); + validate_trace(tracer, 4, max_nodes); add_simple_trace_event(tracer); add_simple_trace_event(tracer); - validate_tracer(tracer, 6, max_nodes); + validate_trace(tracer, 6, max_nodes); add_simple_trace_event(tracer); add_simple_trace_event(tracer); add_simple_trace_event(tracer); add_simple_trace_event(tracer); - validate_tracer(tracer, 10, max_nodes); - validate_tracer_data_matches_uuid_lookup(tracer); + validate_trace(tracer, 10, max_nodes); + validate_trace_data_matches_uuid_lookup(tracer); tracer.reset(nullptr); } // Calls basic test with various values for max_nodes (including 0, which turns // the tracer off). TEST(ChannelTracerTest, BasicTest) { - test_basic_channel_tracing(0); - test_basic_channel_tracing(1); - test_basic_channel_tracing(2); - test_basic_channel_tracing(6); - test_basic_channel_tracing(10); - test_basic_channel_tracing(15); + test_basic_channel_trace(0); + test_basic_channel_trace(1); + test_basic_channel_trace(2); + test_basic_channel_trace(6); + test_basic_channel_trace(10); + test_basic_channel_trace(15); } // Tests more complex functionality, like a parent channel tracking // subchannles. This exercises the ref/unref patterns since the parent tracer // and this function will both hold refs to the subchannel. -static void test_complex_channel_tracing(size_t max_nodes) { +static void test_complex_channel_trace(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); add_simple_trace_event(tracer); @@ -120,33 +120,33 @@ static void test_complex_channel_tracing(size_t max_nodes) { RefCountedPtr sc1 = MakeRefCounted(max_nodes); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 3, max_nodes); + validate_trace(tracer, 3, max_nodes); add_simple_trace_event(sc1); add_simple_trace_event(sc1); add_simple_trace_event(sc1); - validate_tracer(sc1, 3, max_nodes); + validate_trace(sc1, 3, max_nodes); add_simple_trace_event(sc1); add_simple_trace_event(sc1); add_simple_trace_event(sc1); - validate_tracer(sc1, 6, max_nodes); + validate_trace(sc1, 6, max_nodes); add_simple_trace_event(tracer); add_simple_trace_event(tracer); - validate_tracer(tracer, 5, max_nodes); - validate_tracer_data_matches_uuid_lookup(tracer); + validate_trace(tracer, 5, max_nodes); + validate_trace_data_matches_uuid_lookup(tracer); RefCountedPtr sc2 = MakeRefCounted(max_nodes); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); tracer->AddTraceEvent( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_tracer(tracer, 7, max_nodes); + validate_trace(tracer, 7, max_nodes); add_simple_trace_event(tracer); add_simple_trace_event(tracer); add_simple_trace_event(tracer); add_simple_trace_event(tracer); add_simple_trace_event(tracer); add_simple_trace_event(tracer); - validate_tracer_data_matches_uuid_lookup(tracer); + validate_trace_data_matches_uuid_lookup(tracer); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr); @@ -154,12 +154,12 @@ static void test_complex_channel_tracing(size_t max_nodes) { // Calls the complex test with a sweep of sizes for max_nodes. TEST(ChannelTracerTest, ComplexTest) { - test_complex_channel_tracing(0); - test_complex_channel_tracing(1); - test_complex_channel_tracing(2); - test_complex_channel_tracing(6); - test_complex_channel_tracing(10); - test_complex_channel_tracing(15); + test_complex_channel_trace(0); + test_complex_channel_trace(1); + test_complex_channel_trace(2); + test_complex_channel_trace(6); + test_complex_channel_trace(10); + test_complex_channel_trace(15); } // Test a case in which the parent channel has subchannels and the subchannels diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc index a2449cc4bd2..be37703ecc3 100644 --- a/test/core/util/channel_tracing_utils.cc +++ b/test/core/util/channel_tracing_utils.cc @@ -20,7 +20,7 @@ #include #include -#include "src/core/lib/channel/channel_tracer.h" +#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/json/json.h" diff --git a/test/core/util/channel_tracing_utils.h b/test/core/util/channel_tracing_utils.h index fc04d8bae68..2038cd83aab 100644 --- a/test/core/util/channel_tracing_utils.h +++ b/test/core/util/channel_tracing_utils.h @@ -19,8 +19,6 @@ #ifndef GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H #define GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H -#include "src/core/lib/channel/channel_tracer.h" - void validate_json_array_size(grpc_json* json, const char* key, size_t expected_size); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 4a7428e2d88..72fb62d1f2a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1007,7 +1007,7 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/channel_tracer.h \ +src/core/lib/channel/channel_trace.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e1856bf9aa9..a64ff1eaf19 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1034,8 +1034,8 @@ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/channel_tracer.cc \ -src/core/lib/channel/channel_tracer.h \ +src/core/lib/channel/channel_trace.cc \ +src/core/lib/channel/channel_trace.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e4741fc0d2b..1854b33ce1f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2837,9 +2837,9 @@ "headers": [], "is_filegroup": false, "language": "c++", - "name": "channel_tracer_test", + "name": "channel_trace_test", "src": [ - "test/core/channel/channel_tracer_test.cc" + "test/core/channel/channel_trace_test.cc" ], "third_party": false, "type": "target" @@ -8575,7 +8575,7 @@ "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/channel_tracer.cc", + "src/core/lib/channel/channel_trace.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", @@ -8734,7 +8734,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_tracer.h", + "src/core/lib/channel/channel_trace.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", @@ -8880,7 +8880,7 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_tracer.h", + "src/core/lib/channel/channel_trace.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 4d86843f13c..cae60dd29a0 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3352,7 +3352,7 @@ "flaky": false, "gtest": true, "language": "c++", - "name": "channel_tracer_test", + "name": "channel_trace_test", "platforms": [ "linux", "mac", From 1cc064dbfc5fd91a6f705881427b39ca4675abe3 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 07:53:58 -0800 Subject: [PATCH 47/67] Reviewer feedback, s/object_registry/channel_trace_registry --- CMakeLists.txt | 12 ++-- Makefile | 12 ++-- build.yaml | 4 +- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 4 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 8 +-- package.xml | 4 +- .../ext/filters/client_channel/subchannel.cc | 2 +- src/core/lib/channel/channel_trace.cc | 6 +- ..._registry.cc => channel_trace_registry.cc} | 59 ++++++------------- src/core/lib/channel/channel_trace_registry.h | 43 ++++++++++++++ src/core/lib/channel/object_registry.h | 52 ---------------- src/core/lib/surface/channel.cc | 1 - src/core/lib/surface/init.cc | 6 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/channel/channel_trace_test.cc | 14 ++--- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- .../generated/sources_and_headers.json | 6 +- 22 files changed, 109 insertions(+), 146 deletions(-) rename src/core/lib/channel/{object_registry.cc => channel_trace_registry.cc} (50%) create mode 100644 src/core/lib/channel/channel_trace_registry.h delete mode 100644 src/core/lib/channel/object_registry.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 651fb6bde94..9c4d6a30700 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -801,11 +801,11 @@ add_library(grpc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1145,11 +1145,11 @@ add_library(grpc_cronet src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1476,11 +1476,11 @@ add_library(grpc_test_util src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1768,11 +1768,11 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2039,11 +2039,11 @@ add_library(grpc_unsecure src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2844,11 +2844,11 @@ add_library(grpc++_cronet src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc + src/core/lib/channel/channel_trace_registry.cc src/core/lib/channel/connected_channel.cc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc - src/core/lib/channel/object_registry.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc diff --git a/Makefile b/Makefile index 01bad6692d1..ed87a6a2c4f 100644 --- a/Makefile +++ b/Makefile @@ -3041,11 +3041,11 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3387,11 +3387,11 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3719,11 +3719,11 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4004,11 +4004,11 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4255,11 +4255,11 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -5059,11 +5059,11 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ diff --git a/build.yaml b/build.yaml index 9ef6092e03e..85ea6e79936 100644 --- a/build.yaml +++ b/build.yaml @@ -155,11 +155,11 @@ filegroups: - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc + - src/core/lib/channel/channel_trace_registry.cc - src/core/lib/channel/connected_channel.cc - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc - - src/core/lib/channel/object_registry.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_internal.cc - src/core/lib/compression/message_compress.cc @@ -313,12 +313,12 @@ filegroups: - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/channel_trace.h + - src/core/lib/channel/channel_trace_registry.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h - - src/core/lib/channel/object_registry.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/compression_internal.h - src/core/lib/compression/message_compress.h diff --git a/config.m4 b/config.m4 index d53c2f4589f..b46eb4078b3 100644 --- a/config.m4 +++ b/config.m4 @@ -85,11 +85,11 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ + src/core/lib/channel/channel_trace_registry.cc \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ - src/core/lib/channel/object_registry.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ diff --git a/config.w32 b/config.w32 index 548ae73e31b..ea90cb54245 100644 --- a/config.w32 +++ b/config.w32 @@ -62,11 +62,11 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + "src\\core\\lib\\channel\\channel_trace.cc " + + "src\\core\\lib\\channel\\channel_trace_registry.cc " + "src\\core\\lib\\channel\\connected_channel.cc " + "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + - "src\\core\\lib\\channel\\object_registry.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\compression_internal.cc " + "src\\core\\lib\\compression\\message_compress.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 4403af53c5e..ae45fe12f32 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -317,12 +317,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -498,12 +498,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 852992e6066..cf26d7e73d0 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -328,12 +328,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -474,11 +474,11 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -826,12 +826,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', + 'src/core/lib/channel/channel_trace_registry.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/object_registry.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/grpc.gemspec b/grpc.gemspec index a53cdfdfe9e..a20d8efe148 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -254,12 +254,12 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) s.files += %w( src/core/lib/channel/channel_trace.h ) + s.files += %w( src/core/lib/channel/channel_trace_registry.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) - s.files += %w( src/core/lib/channel/object_registry.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/compression_internal.h ) s.files += %w( src/core/lib/compression/message_compress.h ) @@ -404,11 +404,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) s.files += %w( src/core/lib/channel/channel_trace.cc ) + s.files += %w( src/core/lib/channel/channel_trace_registry.cc ) s.files += %w( src/core/lib/channel/connected_channel.cc ) s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) - s.files += %w( src/core/lib/channel/object_registry.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/compression_internal.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) diff --git a/grpc.gyp b/grpc.gyp index ca76c680777..0b7b3b9dafb 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -226,11 +226,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -528,11 +528,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -748,11 +748,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -946,11 +946,11 @@ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', diff --git a/package.xml b/package.xml index a0841886a94..a2b59e73397 100644 --- a/package.xml +++ b/package.xml @@ -261,12 +261,12 @@ + - @@ -411,11 +411,11 @@ + - diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index e8ff352be8a..4802110e5a2 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -37,8 +37,8 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 3217a83fba2..226ab0292d0 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -28,7 +28,7 @@ #include #include "src/core/ext/filters/client_channel/status_util.h" -#include "src/core/lib/channel/object_registry.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" @@ -76,8 +76,7 @@ ChannelTrace::ChannelTrace(size_t max_events) tail_trace_(nullptr) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 gpr_mu_init(&tracer_mu_); - channel_uuid_ = grpc_object_registry_register_object( - this, GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); + channel_uuid_ = grpc_channel_trace_registry_register_channel_trace(this); time_created_ = grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME); } @@ -90,6 +89,7 @@ ChannelTrace::~ChannelTrace() { it = it->next(); Delete(to_free); } + grpc_channel_trace_registry_unregister_channel_trace(channel_uuid_); gpr_mu_destroy(&tracer_mu_); } diff --git a/src/core/lib/channel/object_registry.cc b/src/core/lib/channel/channel_trace_registry.cc similarity index 50% rename from src/core/lib/channel/object_registry.cc rename to src/core/lib/channel/channel_trace_registry.cc index 987c5366cad..6c824314676 100644 --- a/src/core/lib/channel/object_registry.cc +++ b/src/core/lib/channel/channel_trace_registry.cc @@ -19,7 +19,8 @@ #include #include "src/core/lib/avl/avl.h" -#include "src/core/lib/channel/object_registry.h" +#include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/gpr/useful.h" #include @@ -30,12 +31,7 @@ static gpr_mu g_mu; static grpc_avl g_avl; static gpr_atm g_uuid = 0; -typedef struct { - void* object; - grpc_object_registry_type type; -} object_tracker; - -// avl vtable for uuid (intptr_t) -> object_tracker +// avl vtable for uuid (intptr_t) -> ChannelTrace // this table is only looking, it does not own anything. static void destroy_intptr(void* not_used, void* user_data) {} static void* copy_intptr(void* key, void* user_data) { return key; } @@ -43,61 +39,42 @@ static long compare_intptr(void* key1, void* key2, void* user_data) { return GPR_ICMP(key1, key2); } -static void destroy_tracker(void* tracker, void* user_data) { - gpr_free((object_tracker*)tracker); -} - -static void* copy_tracker(void* value, void* user_data) { - object_tracker* old = static_cast(value); - object_tracker* new_obj = - static_cast(gpr_malloc(sizeof(object_tracker))); - new_obj->object = old->object; - new_obj->type = old->type; - return new_obj; -} +static void destroy_channel_trace(void* trace, void* user_data) {} +static void* copy_channel_trace(void* trace, void* user_data) { return trace; } static const grpc_avl_vtable avl_vtable = { - destroy_intptr, copy_intptr, compare_intptr, destroy_tracker, copy_tracker}; + destroy_intptr, copy_intptr, compare_intptr, destroy_channel_trace, + copy_channel_trace}; -void grpc_object_registry_init() { +void grpc_channel_trace_registry_init() { gpr_mu_init(&g_mu); g_avl = grpc_avl_create(&avl_vtable); } -void grpc_object_registry_shutdown() { +void grpc_channel_trace_registry_shutdown() { grpc_avl_unref(g_avl, nullptr); gpr_mu_destroy(&g_mu); } -intptr_t grpc_object_registry_register_object(void* object, - grpc_object_registry_type type) { - object_tracker* tracker = - static_cast(gpr_malloc(sizeof(object_tracker))); - tracker->object = object; - tracker->type = type; +intptr_t grpc_channel_trace_registry_register_channel_trace( + grpc_core::ChannelTrace* channel_trace) { intptr_t prior = gpr_atm_no_barrier_fetch_add(&g_uuid, 1); gpr_mu_lock(&g_mu); - g_avl = grpc_avl_add(g_avl, (void*)prior, tracker, nullptr); + g_avl = grpc_avl_add(g_avl, (void*)prior, channel_trace, nullptr); gpr_mu_unlock(&g_mu); return prior; } -void grpc_object_registry_unregister_object(intptr_t uuid) { +void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid) { gpr_mu_lock(&g_mu); g_avl = grpc_avl_remove(g_avl, (void*)uuid, nullptr); gpr_mu_unlock(&g_mu); } -grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, - void** object) { - GPR_ASSERT(object); +grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( + intptr_t uuid) { gpr_mu_lock(&g_mu); - object_tracker* tracker = - static_cast(grpc_avl_get(g_avl, (void*)uuid, nullptr)); + grpc_core::ChannelTrace* ret = static_cast( + grpc_avl_get(g_avl, (void*)uuid, nullptr)); gpr_mu_unlock(&g_mu); - if (tracker == nullptr) { - *object = nullptr; - return GRPC_OBJECT_REGISTRY_UNKNOWN; - } - *object = tracker->object; - return tracker->type; + return ret; } diff --git a/src/core/lib/channel/channel_trace_registry.h b/src/core/lib/channel/channel_trace_registry.h new file mode 100644 index 00000000000..391ecba7def --- /dev/null +++ b/src/core/lib/channel/channel_trace_registry.h @@ -0,0 +1,43 @@ +/* + * + * Copyright 2017 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. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H + +#include + +#include "src/core/lib/channel/channel_trace.h" + +#include + +// TODO(ncteisen): convert this file to C++ + +void grpc_channel_trace_registry_init(); +void grpc_channel_trace_registry_shutdown(); + +// globally registers a ChannelTrace. Returns its unique uuid +intptr_t grpc_channel_trace_registry_register_channel_trace( + grpc_core::ChannelTrace* channel_trace); +// globally unregisters the ChannelTrace that is associated to uuid. +void grpc_channel_trace_registry_unregister_channel_trace(intptr_t uuid); +// if object with uuid has previously been registered, returns the ChannelTrace +// associated with that uuid. Else returns nullptr. +grpc_core::ChannelTrace* grpc_channel_trace_registry_get_channel_trace( + intptr_t uuid); + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_TRACE_REGISTRY_H */ diff --git a/src/core/lib/channel/object_registry.h b/src/core/lib/channel/object_registry.h deleted file mode 100644 index 446d0cb41f8..00000000000 --- a/src/core/lib/channel/object_registry.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright 2017 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. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H -#define GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H - -#include - -#include - -// TODO(ncteisen): convert this file to C++ - -// Different types that may be stored in the general object registry. For now, -// the only use case is channel tracers, but the design has been left general. -typedef enum { - // Used to hold uuid -> ChannelTracer mappings to allow for the trace data - // to be looked up by uuid, rather then have to walk the entire tree of - // trace. - GRPC_OBJECT_REGISTRY_CHANNEL_TRACER, - // Usually represents an error has occurred in the object lookup. - GRPC_OBJECT_REGISTRY_UNKNOWN, -} grpc_object_registry_type; - -void grpc_object_registry_init(); -void grpc_object_registry_shutdown(); - -// globally registers the object. Returns its unique uuid -intptr_t grpc_object_registry_register_object(void* object, - grpc_object_registry_type type); -// globally unregisters the object that is associated to uuid. -void grpc_object_registry_unregister_object(intptr_t uuid); -// if object with uuid has previously been registered, stores it in *object. -// if not, returns GRPC_OBJECT_REGISTRY_UNKNOWN and sets *object unchanged. -grpc_object_registry_type grpc_object_registry_get_object(intptr_t uuid, - void** object); - -#endif /* GRPC_CORE_LIB_CHANNEL_OBJECT_REGISTRY_H */ diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index c470f6d0d8e..dca583abbe1 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,7 +32,6 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 2d4b3b55d46..bd436d68575 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -27,9 +27,9 @@ #include #include #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/channel/object_registry.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/fork.h" @@ -129,7 +129,7 @@ void grpc_init(void) { grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); - grpc_object_registry_init(); + grpc_channel_trace_registry_init(); grpc_security_pre_init(); grpc_core::ExecCtx::GlobalInit(); grpc_iomgr_init(); @@ -178,7 +178,7 @@ void grpc_shutdown(void) { grpc_mdctx_global_shutdown(); grpc_handshaker_factory_registry_shutdown(); grpc_slice_intern_shutdown(); - grpc_object_registry_shutdown(); + grpc_channel_trace_registry_shutdown(); grpc_stats_shutdown(); } grpc_core::ExecCtx::GlobalShutdown(); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 3c3c1d69439..bc9b5a3c736 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -61,11 +61,11 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', + 'src/core/lib/channel/channel_trace_registry.cc', 'src/core/lib/channel/connected_channel.cc', 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', - 'src/core/lib/channel/object_registry.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index c0cccb77acd..dcc3a347bfb 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -25,7 +25,7 @@ #include #include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/object_registry.h" +#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -43,8 +43,7 @@ static void add_simple_trace_event(RefCountedPtr tracer) { // checks for the existence of all the required members of the tracer. static void validate_trace(RefCountedPtr tracer, - size_t expected_num_event_logged, - size_t max_nodes) { + size_t expected_num_event_logged, size_t max_nodes) { if (!max_nodes) return; char* json_str = tracer->RenderTrace(); grpc_json* json = grpc_json_parse_string(json_str); @@ -59,12 +58,9 @@ static void validate_trace_data_matches_uuid_lookup( intptr_t uuid = tracer->GetUuid(); if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled char* tracer_json_str = tracer->RenderTrace(); - void* object; - grpc_object_registry_type type = - grpc_object_registry_get_object(uuid, &object); - GPR_ASSERT(type == GRPC_OBJECT_REGISTRY_CHANNEL_TRACER); - char* uuid_lookup_json_str = - static_cast(object)->RenderTrace(); + ChannelTrace* uuid_lookup = + grpc_channel_trace_registry_get_channel_trace(uuid); + char* uuid_lookup_json_str = uuid_lookup->RenderTrace(); GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); gpr_free(tracer_json_str); gpr_free(uuid_lookup_json_str); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 72fb62d1f2a..cae5cc5fa11 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1008,12 +1008,12 @@ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.h \ src/core/lib/channel/channel_trace.h \ +src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/object_registry.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index a64ff1eaf19..78805a0ad12 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1036,6 +1036,8 @@ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_stack_builder.h \ src/core/lib/channel/channel_trace.cc \ src/core/lib/channel/channel_trace.h \ +src/core/lib/channel/channel_trace_registry.cc \ +src/core/lib/channel/channel_trace_registry.h \ src/core/lib/channel/connected_channel.cc \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ @@ -1045,8 +1047,6 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/object_registry.cc \ -src/core/lib/channel/object_registry.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 1854b33ce1f..90ef05546f1 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8576,11 +8576,11 @@ "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", "src/core/lib/channel/channel_trace.cc", + "src/core/lib/channel/channel_trace_registry.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", - "src/core/lib/channel/object_registry.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/compression_internal.cc", "src/core/lib/compression/message_compress.cc", @@ -8735,12 +8735,12 @@ "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/object_registry.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -8881,12 +8881,12 @@ "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/object_registry.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", From e9587db8530446d894d5de470591201dabb3ac77 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 08:16:04 -0800 Subject: [PATCH 48/67] Move status util --- BUILD | 4 ++-- CMakeLists.txt | 14 +++++++------- Makefile | 16 ++++++++-------- build.yaml | 6 +++--- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 3 ++- gRPC-Core.podspec | 6 +++--- grpc.gemspec | 4 ++-- grpc.gyp | 8 ++++---- package.xml | 4 ++-- .../filters/client_channel/client_channel.cc | 2 +- .../filters/client_channel/method_params.cc | 2 +- .../ext/filters/client_channel/method_params.h | 2 +- src/core/lib/channel/channel_trace.cc | 2 +- .../channel}/status_util.cc | 2 +- .../channel}/status_util.h | 6 +++--- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/channel/BUILD | 18 +++++++++++++++--- .../status_util_test.cc | 2 +- test/core/client_channel/BUILD | 12 ------------ tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core.internal | 4 ++-- .../generated/sources_and_headers.json | 8 ++++---- 24 files changed, 67 insertions(+), 65 deletions(-) rename src/core/{ext/filters/client_channel => lib/channel}/status_util.cc (98%) rename src/core/{ext/filters/client_channel => lib/channel}/status_util.h (89%) rename test/core/{client_channel => channel}/status_util_test.cc (95%) diff --git a/BUILD b/BUILD index 0baf89ff576..40ba497a595 100644 --- a/BUILD +++ b/BUILD @@ -677,6 +677,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", "src/core/lib/channel/channel_tracer.cc", + "src/core/lib/channel/status_util.cc", "src/core/lib/channel/connected_channel.cc", "src/core/lib/channel/object_registry.cc", "src/core/lib/channel/handshaker.cc", @@ -814,6 +815,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/channel_tracer.h", + "src/core/lib/channel/status_util.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/object_registry.h", @@ -1006,7 +1008,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver.cc", "src/core/ext/filters/client_channel/resolver_registry.cc", "src/core/ext/filters/client_channel/retry_throttle.cc", - "src/core/ext/filters/client_channel/status_util.cc", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel_index.cc", "src/core/ext/filters/client_channel/uri_parser.cc", @@ -1029,7 +1030,6 @@ grpc_cc_library( "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c4d6a30700..088373f4700 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -806,6 +806,7 @@ add_library(grpc src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1010,7 +1011,6 @@ add_library(grpc src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1150,6 +1150,7 @@ add_library(grpc_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1325,7 +1326,6 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1481,6 +1481,7 @@ add_library(grpc_test_util src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1625,7 +1626,6 @@ add_library(grpc_test_util src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -1773,6 +1773,7 @@ add_library(grpc_test_util_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -1917,7 +1918,6 @@ add_library(grpc_test_util_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -2044,6 +2044,7 @@ add_library(grpc_unsecure src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2221,7 +2222,6 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -2849,6 +2849,7 @@ add_library(grpc++_cronet src/core/lib/channel/handshaker.cc src/core/lib/channel/handshaker_factory.cc src/core/lib/channel/handshaker_registry.cc + src/core/lib/channel/status_util.cc src/core/lib/compression/compression.cc src/core/lib/compression/compression_internal.cc src/core/lib/compression/message_compress.cc @@ -2998,7 +2999,6 @@ add_library(grpc++_cronet src/core/ext/filters/client_channel/resolver.cc src/core/ext/filters/client_channel/resolver_registry.cc src/core/ext/filters/client_channel/retry_throttle.cc - src/core/ext/filters/client_channel/status_util.cc src/core/ext/filters/client_channel/subchannel.cc src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/uri_parser.cc @@ -12402,7 +12402,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) add_executable(status_util_test - test/core/client_channel/status_util_test.cc + test/core/channel/status_util_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) diff --git a/Makefile b/Makefile index ed87a6a2c4f..6487050b63b 100644 --- a/Makefile +++ b/Makefile @@ -3046,6 +3046,7 @@ LIBGRPC_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3250,7 +3251,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3392,6 +3392,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3567,7 +3568,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -3724,6 +3724,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -3868,7 +3869,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4009,6 +4009,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4153,7 +4154,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -4260,6 +4260,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -4437,7 +4438,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -5064,6 +5064,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -5213,7 +5214,6 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ @@ -18213,7 +18213,7 @@ endif STATUS_UTIL_TEST_SRC = \ - test/core/client_channel/status_util_test.cc \ + test/core/channel/status_util_test.cc \ STATUS_UTIL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STATUS_UTIL_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -18244,7 +18244,7 @@ endif endif -$(OBJDIR)/$(CONFIG)/test/core/client_channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a +$(OBJDIR)/$(CONFIG)/test/core/channel/status_util_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a deps_status_util_test: $(STATUS_UTIL_TEST_OBJS:.o=.dep) diff --git a/build.yaml b/build.yaml index 85ea6e79936..d03aa62c276 100644 --- a/build.yaml +++ b/build.yaml @@ -160,6 +160,7 @@ filegroups: - src/core/lib/channel/handshaker.cc - src/core/lib/channel/handshaker_factory.cc - src/core/lib/channel/handshaker_registry.cc + - src/core/lib/channel/status_util.cc - src/core/lib/compression/compression.cc - src/core/lib/compression/compression_internal.cc - src/core/lib/compression/message_compress.cc @@ -319,6 +320,7 @@ filegroups: - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h + - src/core/lib/channel/status_util.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/compression_internal.h - src/core/lib/compression/message_compress.h @@ -460,7 +462,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver_factory.h - src/core/ext/filters/client_channel/resolver_registry.h - src/core/ext/filters/client_channel/retry_throttle.h - - src/core/ext/filters/client_channel/status_util.h - src/core/ext/filters/client_channel/subchannel.h - src/core/ext/filters/client_channel/subchannel_index.h - src/core/ext/filters/client_channel/uri_parser.h @@ -483,7 +484,6 @@ filegroups: - src/core/ext/filters/client_channel/resolver.cc - src/core/ext/filters/client_channel/resolver_registry.cc - src/core/ext/filters/client_channel/retry_throttle.cc - - src/core/ext/filters/client_channel/status_util.cc - src/core/ext/filters/client_channel/subchannel.cc - src/core/ext/filters/client_channel/subchannel_index.cc - src/core/ext/filters/client_channel/uri_parser.cc @@ -4909,7 +4909,7 @@ targets: build: test language: c++ src: - - test/core/client_channel/status_util_test.cc + - test/core/channel/status_util_test.cc deps: - grpc uses_polling: false diff --git a/config.m4 b/config.m4 index b46eb4078b3..b53f5f7f356 100644 --- a/config.m4 +++ b/config.m4 @@ -90,6 +90,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/handshaker.cc \ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_registry.cc \ + src/core/lib/channel/status_util.cc \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ src/core/lib/compression/message_compress.cc \ @@ -294,7 +295,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver.cc \ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/retry_throttle.cc \ - src/core/ext/filters/client_channel/status_util.cc \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/uri_parser.cc \ diff --git a/config.w32 b/config.w32 index ea90cb54245..eeb48951811 100644 --- a/config.w32 +++ b/config.w32 @@ -67,6 +67,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\channel\\handshaker.cc " + "src\\core\\lib\\channel\\handshaker_factory.cc " + "src\\core\\lib\\channel\\handshaker_registry.cc " + + "src\\core\\lib\\channel\\status_util.cc " + "src\\core\\lib\\compression\\compression.cc " + "src\\core\\lib\\compression\\compression_internal.cc " + "src\\core\\lib\\compression\\message_compress.cc " + @@ -271,7 +272,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver_registry.cc " + "src\\core\\ext\\filters\\client_channel\\retry_throttle.cc " + - "src\\core\\ext\\filters\\client_channel\\status_util.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " + "src\\core\\ext\\filters\\client_channel\\uri_parser.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index ae45fe12f32..9df76bcd498 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -304,7 +304,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -323,6 +322,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -504,6 +504,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cf26d7e73d0..a7f27aeb10c 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -315,7 +315,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -334,6 +333,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', @@ -479,6 +479,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -683,7 +684,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -813,7 +813,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver_factory.h', 'src/core/ext/filters/client_channel/resolver_registry.h', 'src/core/ext/filters/client_channel/retry_throttle.h', - 'src/core/ext/filters/client_channel/status_util.h', 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', @@ -832,6 +831,7 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', + 'src/core/lib/channel/status_util.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/compression_internal.h', 'src/core/lib/compression/message_compress.h', diff --git a/grpc.gemspec b/grpc.gemspec index a20d8efe148..2f4591a4ae3 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -241,7 +241,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver_factory.h ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.h ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.h ) - s.files += %w( src/core/ext/filters/client_channel/status_util.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.h ) @@ -260,6 +259,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) + s.files += %w( src/core/lib/channel/status_util.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/compression_internal.h ) s.files += %w( src/core/lib/compression/message_compress.h ) @@ -409,6 +409,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker.cc ) s.files += %w( src/core/lib/channel/handshaker_factory.cc ) s.files += %w( src/core/lib/channel/handshaker_registry.cc ) + s.files += %w( src/core/lib/channel/status_util.cc ) s.files += %w( src/core/lib/compression/compression.cc ) s.files += %w( src/core/lib/compression/compression_internal.cc ) s.files += %w( src/core/lib/compression/message_compress.cc ) @@ -613,7 +614,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver_registry.cc ) s.files += %w( src/core/ext/filters/client_channel/retry_throttle.cc ) - s.files += %w( src/core/ext/filters/client_channel/status_util.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.cc ) diff --git a/grpc.gyp b/grpc.gyp index 0b7b3b9dafb..092487d1a5a 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -231,6 +231,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -435,7 +436,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -533,6 +533,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -677,7 +678,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -753,6 +753,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -897,7 +898,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', @@ -951,6 +951,7 @@ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -1128,7 +1129,6 @@ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', diff --git a/package.xml b/package.xml index a2b59e73397..5e8356cb322 100644 --- a/package.xml +++ b/package.xml @@ -248,7 +248,6 @@ - @@ -267,6 +266,7 @@ + @@ -416,6 +416,7 @@ + @@ -620,7 +621,6 @@ - diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 90b93fbe236..09cc06e1692 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -38,12 +38,12 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/retry_throttle.h" -#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" diff --git a/src/core/ext/filters/client_channel/method_params.cc b/src/core/ext/filters/client_channel/method_params.cc index 374b87e170c..1f116bb67d1 100644 --- a/src/core/ext/filters/client_channel/method_params.cc +++ b/src/core/ext/filters/client_channel/method_params.cc @@ -26,7 +26,7 @@ #include #include "src/core/ext/filters/client_channel/method_params.h" -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/method_params.h b/src/core/ext/filters/client_channel/method_params.h index 48ece298676..099924edf36 100644 --- a/src/core/ext/filters/client_channel/method_params.h +++ b/src/core/ext/filters/client_channel/method_params.h @@ -21,7 +21,7 @@ #include -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 226ab0292d0..07c2c1fd977 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -27,8 +27,8 @@ #include #include -#include "src/core/ext/filters/client_channel/status_util.h" #include "src/core/lib/channel/channel_trace_registry.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" diff --git a/src/core/ext/filters/client_channel/status_util.cc b/src/core/lib/channel/status_util.cc similarity index 98% rename from src/core/ext/filters/client_channel/status_util.cc rename to src/core/lib/channel/status_util.cc index 11f732ab448..563db408464 100644 --- a/src/core/ext/filters/client_channel/status_util.cc +++ b/src/core/lib/channel/status_util.cc @@ -18,7 +18,7 @@ #include -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include "src/core/lib/gpr/useful.h" diff --git a/src/core/ext/filters/client_channel/status_util.h b/src/core/lib/channel/status_util.h similarity index 89% rename from src/core/ext/filters/client_channel/status_util.h rename to src/core/lib/channel/status_util.h index e018709730e..2c552fa20a6 100644 --- a/src/core/ext/filters/client_channel/status_util.h +++ b/src/core/lib/channel/status_util.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H +#ifndef GRPC_LIB_CHANNEL_STATUS_UTILS_H +#define GRPC_LIB_CHANNEL_STATUS_UTILS_H #include @@ -55,4 +55,4 @@ class StatusCodeSet { } // namespace internal } // namespace grpc_core -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_STATUS_UTIL_H */ +#endif /* GRPC_LIB_CHANNEL_STATUS_UTILS_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index bc9b5a3c736..49016bad554 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -66,6 +66,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/handshaker.cc', 'src/core/lib/channel/handshaker_factory.cc', 'src/core/lib/channel/handshaker_registry.cc', + 'src/core/lib/channel/status_util.cc', 'src/core/lib/compression/compression.cc', 'src/core/lib/compression/compression_internal.cc', 'src/core/lib/compression/message_compress.cc', @@ -270,7 +271,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver.cc', 'src/core/ext/filters/client_channel/resolver_registry.cc', 'src/core/ext/filters/client_channel/retry_throttle.cc', - 'src/core/ext/filters/client_channel/status_util.cc', 'src/core/ext/filters/client_channel/subchannel.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/uri_parser.cc', diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 633c424eae3..e1388c6e1ac 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -69,9 +69,6 @@ grpc_cc_test( grpc_cc_test( name = "channel_trace_test", srcs = ["channel_trace_test.cc"], - external_deps = [ - "gtest", - ], language = "C++", deps = [ "//:gpr", @@ -80,4 +77,19 @@ grpc_cc_test( "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], + external_deps = [ + "gtest", + ], +) + +grpc_cc_test( + name = "status_util_test", + srcs = ["status_util_test.cc"], + language = "C++", + deps = [ + "//:grpc", + ], + external_deps = [ + "gtest", + ], ) diff --git a/test/core/client_channel/status_util_test.cc b/test/core/channel/status_util_test.cc similarity index 95% rename from test/core/client_channel/status_util_test.cc rename to test/core/channel/status_util_test.cc index f944990ad28..1d64bf19957 100644 --- a/test/core/client_channel/status_util_test.cc +++ b/test/core/channel/status_util_test.cc @@ -16,7 +16,7 @@ * */ -#include "src/core/ext/filters/client_channel/status_util.h" +#include "src/core/lib/channel/status_util.h" #include diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD index d430b722df4..5148dc5f743 100644 --- a/test/core/client_channel/BUILD +++ b/test/core/client_channel/BUILD @@ -53,15 +53,3 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) - -grpc_cc_test( - name = "status_util_test", - srcs = ["status_util_test.cc"], - language = "C++", - deps = [ - "//:grpc", - ], - external_deps = [ - "gtest", - ], -) diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index cae5cc5fa11..30ee95d785f 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1014,6 +1014,7 @@ src/core/lib/channel/context.h \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression_internal.h \ src/core/lib/compression/message_compress.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 78805a0ad12..326ced6d700 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -929,8 +929,6 @@ src/core/ext/filters/client_channel/resolver_registry.cc \ src/core/ext/filters/client_channel/resolver_registry.h \ src/core/ext/filters/client_channel/retry_throttle.cc \ src/core/ext/filters/client_channel/retry_throttle.h \ -src/core/ext/filters/client_channel/status_util.cc \ -src/core/ext/filters/client_channel/status_util.h \ src/core/ext/filters/client_channel/subchannel.cc \ src/core/ext/filters/client_channel/subchannel.h \ src/core/ext/filters/client_channel/subchannel_index.cc \ @@ -1047,6 +1045,8 @@ src/core/lib/channel/handshaker_factory.cc \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.cc \ src/core/lib/channel/handshaker_registry.h \ +src/core/lib/channel/status_util.cc \ +src/core/lib/channel/status_util.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.cc \ src/core/lib/compression/compression_internal.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 90ef05546f1..706ec698451 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4265,7 +4265,7 @@ "language": "c++", "name": "status_util_test", "src": [ - "test/core/client_channel/status_util_test.cc" + "test/core/channel/status_util_test.cc" ], "third_party": false, "type": "target" @@ -8581,6 +8581,7 @@ "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", + "src/core/lib/channel/status_util.cc", "src/core/lib/compression/compression.cc", "src/core/lib/compression/compression_internal.cc", "src/core/lib/compression/message_compress.cc", @@ -8741,6 +8742,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -8887,6 +8889,7 @@ "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", + "src/core/lib/channel/status_util.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression_internal.h", "src/core/lib/compression/message_compress.h", @@ -9032,7 +9035,6 @@ "src/core/ext/filters/client_channel/resolver_factory.h", "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.h", "src/core/ext/filters/client_channel/uri_parser.h" @@ -9076,8 +9078,6 @@ "src/core/ext/filters/client_channel/resolver_registry.h", "src/core/ext/filters/client_channel/retry_throttle.cc", "src/core/ext/filters/client_channel/retry_throttle.h", - "src/core/ext/filters/client_channel/status_util.cc", - "src/core/ext/filters/client_channel/status_util.h", "src/core/ext/filters/client_channel/subchannel.cc", "src/core/ext/filters/client_channel/subchannel.h", "src/core/ext/filters/client_channel/subchannel_index.cc", From b50f74f5022a3060fac8ac1206750c539bd1cfc4 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 08:20:12 -0800 Subject: [PATCH 49/67] Reviewer comments --- test/core/channel/channel_trace_test.cc | 136 ++++++++++++------------ 1 file changed, 69 insertions(+), 67 deletions(-) diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index dcc3a347bfb..8c10de91032 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -34,16 +34,17 @@ namespace grpc_core { namespace testing { +namespace { -static void add_simple_trace_event(RefCountedPtr tracer) { +void AddSimpleTrace(RefCountedPtr tracer) { tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_CHANNEL_READY); } // checks for the existence of all the required members of the tracer. -static void validate_trace(RefCountedPtr tracer, - size_t expected_num_event_logged, size_t max_nodes) { +void ValidateChannelTrace(RefCountedPtr tracer, + size_t expected_num_event_logged, size_t max_nodes) { if (!max_nodes) return; char* json_str = tracer->RenderTrace(); grpc_json* json = grpc_json_parse_string(json_str); @@ -53,8 +54,7 @@ static void validate_trace(RefCountedPtr tracer, gpr_free(json_str); } -static void validate_trace_data_matches_uuid_lookup( - RefCountedPtr tracer) { +void ValidateTraceDataMatchedUuidLookup(RefCountedPtr tracer) { intptr_t uuid = tracer->GetUuid(); if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled char* tracer_json_str = tracer->RenderTrace(); @@ -68,12 +68,12 @@ static void validate_trace_data_matches_uuid_lookup( // Tests basic ChannelTrace functionality like construction, adding trace, and // lookups by uuid. -static void test_basic_channel_trace(size_t max_nodes) { +void TestBasicChannelTrace(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_trace_data_matches_uuid_lookup(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateTraceDataMatchedUuidLookup(tracer); tracer->AddTraceEvent( grpc_slice_from_static_string("trace three"), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), @@ -81,81 +81,83 @@ static void test_basic_channel_trace(size_t max_nodes) { GRPC_CHANNEL_IDLE); tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); - validate_trace(tracer, 4, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_trace(tracer, 6, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_trace(tracer, 10, max_nodes); - validate_trace_data_matches_uuid_lookup(tracer); + ValidateChannelTrace(tracer, 4, max_nodes); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 6, max_nodes); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 10, max_nodes); + ValidateTraceDataMatchedUuidLookup(tracer); tracer.reset(nullptr); } -// Calls basic test with various values for max_nodes (including 0, which turns -// the tracer off). -TEST(ChannelTracerTest, BasicTest) { - test_basic_channel_trace(0); - test_basic_channel_trace(1); - test_basic_channel_trace(2); - test_basic_channel_trace(6); - test_basic_channel_trace(10); - test_basic_channel_trace(15); -} - // Tests more complex functionality, like a parent channel tracking // subchannles. This exercises the ref/unref patterns since the parent tracer // and this function will both hold refs to the subchannel. -static void test_complex_channel_trace(size_t max_nodes) { +void TestComplexChannelTrace(size_t max_nodes) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(max_nodes); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_trace(tracer, 3, max_nodes); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - validate_trace(sc1, 3, max_nodes); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - add_simple_trace_event(sc1); - validate_trace(sc1, 6, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_trace(tracer, 5, max_nodes); - validate_trace_data_matches_uuid_lookup(tracer); + ValidateChannelTrace(tracer, 3, max_nodes); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + ValidateChannelTrace(sc1, 3, max_nodes); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + ValidateChannelTrace(sc1, 6, max_nodes); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 5, max_nodes); + ValidateTraceDataMatchedUuidLookup(tracer); RefCountedPtr sc2 = MakeRefCounted(max_nodes); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); tracer->AddTraceEvent( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - validate_trace(tracer, 7, max_nodes); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); - validate_trace_data_matches_uuid_lookup(tracer); + ValidateChannelTrace(tracer, 7, max_nodes); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + ValidateTraceDataMatchedUuidLookup(tracer); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr); } +} // anonymous namespace + +// Calls basic test with various values for max_nodes (including 0, which turns +// the tracer off). +TEST(ChannelTracerTest, BasicTest) { + TestBasicChannelTrace(0); + TestBasicChannelTrace(1); + TestBasicChannelTrace(2); + TestBasicChannelTrace(6); + TestBasicChannelTrace(10); + TestBasicChannelTrace(15); +} + // Calls the complex test with a sweep of sizes for max_nodes. TEST(ChannelTracerTest, ComplexTest) { - test_complex_channel_trace(0); - test_complex_channel_trace(1); - test_complex_channel_trace(2); - test_complex_channel_trace(6); - test_complex_channel_trace(10); - test_complex_channel_trace(15); + TestComplexChannelTrace(0); + TestComplexChannelTrace(1); + TestComplexChannelTrace(2); + TestComplexChannelTrace(6); + TestComplexChannelTrace(10); + TestComplexChannelTrace(15); } // Test a case in which the parent channel has subchannels and the subchannels @@ -164,19 +166,19 @@ TEST(ChannelTracerTest, ComplexTest) { TEST(ChannelTracerTest, TestNesting) { grpc_core::ExecCtx exec_ctx; RefCountedPtr tracer = MakeRefCounted(10); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - add_simple_trace_event(sc1); + AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(5); // nesting one level deeper. sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); - add_simple_trace_event(conn1); - add_simple_trace_event(tracer); - add_simple_trace_event(tracer); + AddSimpleTrace(conn1); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); RefCountedPtr sc2 = MakeRefCounted(5); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); @@ -185,7 +187,7 @@ TEST(ChannelTracerTest, TestNesting) { tracer->AddTraceEvent( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - add_simple_trace_event(tracer); + AddSimpleTrace(tracer); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr); From 9efb1777306c2d28ccc35ded2f8ff2c8af08941a Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 11:11:31 -0800 Subject: [PATCH 50/67] Review feedback, gTest --- BUILD | 8 +- CMakeLists.txt | 2 - Makefile | 2 - build.yaml | 2 - gRPC-Core.podspec | 2 - grpc.gyp | 2 - src/core/lib/channel/channel_trace.cc | 2 - test/core/channel/channel_trace_test.cc | 113 ++++++++++-------- test/core/util/BUILD | 2 - test/core/util/channel_tracing_utils.cc | 60 ---------- test/core/util/channel_tracing_utils.h | 29 ----- .../generated/sources_and_headers.json | 3 - 12 files changed, 70 insertions(+), 157 deletions(-) delete mode 100644 test/core/util/channel_tracing_utils.cc delete mode 100644 test/core/util/channel_tracing_utils.h diff --git a/BUILD b/BUILD index 40ba497a595..828fc802df5 100644 --- a/BUILD +++ b/BUILD @@ -676,10 +676,10 @@ grpc_cc_library( "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", - "src/core/lib/channel/channel_tracer.cc", + "src/core/lib/channel/channel_trace.cc", + "src/core/lib/channel/channel_trace_registry.cc", "src/core/lib/channel/status_util.cc", "src/core/lib/channel/connected_channel.cc", - "src/core/lib/channel/object_registry.cc", "src/core/lib/channel/handshaker.cc", "src/core/lib/channel/handshaker_factory.cc", "src/core/lib/channel/handshaker_registry.cc", @@ -814,11 +814,11 @@ grpc_cc_library( "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/channel_tracer.h", + "src/core/lib/channel/channel_trace.h", + "src/core/lib/channel/channel_trace_registry.h", "src/core/lib/channel/status_util.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", - "src/core/lib/channel/object_registry.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 088373f4700..34cf01a208d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1453,7 +1453,6 @@ add_library(grpc_test_util test/core/end2end/fixtures/http_proxy_fixture.cc test/core/end2end/fixtures/proxy.cc test/core/iomgr/endpoint_tests.cc - test/core/util/channel_tracing_utils.cc test/core/util/debugger_macros.cc test/core/util/grpc_profiler.cc test/core/util/histogram.cc @@ -1745,7 +1744,6 @@ add_library(grpc_test_util_unsecure test/core/end2end/fixtures/http_proxy_fixture.cc test/core/end2end/fixtures/proxy.cc test/core/iomgr/endpoint_tests.cc - test/core/util/channel_tracing_utils.cc test/core/util/debugger_macros.cc test/core/util/grpc_profiler.cc test/core/util/histogram.cc diff --git a/Makefile b/Makefile index 6487050b63b..26126a32c19 100644 --- a/Makefile +++ b/Makefile @@ -3696,7 +3696,6 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/end2end/fixtures/http_proxy_fixture.cc \ test/core/end2end/fixtures/proxy.cc \ test/core/iomgr/endpoint_tests.cc \ - test/core/util/channel_tracing_utils.cc \ test/core/util/debugger_macros.cc \ test/core/util/grpc_profiler.cc \ test/core/util/histogram.cc \ @@ -3981,7 +3980,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/end2end/fixtures/http_proxy_fixture.cc \ test/core/end2end/fixtures/proxy.cc \ test/core/iomgr/endpoint_tests.cc \ - test/core/util/channel_tracing_utils.cc \ test/core/util/debugger_macros.cc \ test/core/util/grpc_profiler.cc \ test/core/util/histogram.cc \ diff --git a/build.yaml b/build.yaml index d03aa62c276..c3511d33425 100644 --- a/build.yaml +++ b/build.yaml @@ -719,7 +719,6 @@ filegroups: - test/core/end2end/fixtures/http_proxy_fixture.h - test/core/end2end/fixtures/proxy.h - test/core/iomgr/endpoint_tests.h - - test/core/util/channel_tracing_utils.h - test/core/util/debugger_macros.h - test/core/util/grpc_profiler.h - test/core/util/histogram.h @@ -739,7 +738,6 @@ filegroups: - test/core/end2end/fixtures/http_proxy_fixture.cc - test/core/end2end/fixtures/proxy.cc - test/core/iomgr/endpoint_tests.cc - - test/core/util/channel_tracing_utils.cc - test/core/util/debugger_macros.cc - test/core/util/grpc_profiler.cc - test/core/util/histogram.cc diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index a7f27aeb10c..ebe91c023b1 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1002,7 +1002,6 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', - 'test/core/util/channel_tracing_utils.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -1025,7 +1024,6 @@ Pod::Spec.new do |s| 'test/core/end2end/fixtures/http_proxy_fixture.h', 'test/core/end2end/fixtures/proxy.h', 'test/core/iomgr/endpoint_tests.h', - 'test/core/util/channel_tracing_utils.h', 'test/core/util/debugger_macros.h', 'test/core/util/grpc_profiler.h', 'test/core/util/histogram.h', diff --git a/grpc.gyp b/grpc.gyp index 092487d1a5a..3036b462e0e 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -505,7 +505,6 @@ 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', - 'test/core/util/channel_tracing_utils.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', @@ -725,7 +724,6 @@ 'test/core/end2end/fixtures/http_proxy_fixture.cc', 'test/core/end2end/fixtures/proxy.cc', 'test/core/iomgr/endpoint_tests.cc', - 'test/core/util/channel_tracing_utils.cc', 'test/core/util/debugger_macros.cc', 'test/core/util/grpc_profiler.cc', 'test/core/util/histogram.cc', diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 07c2c1fd977..08f6f72d636 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -152,8 +152,6 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), GRPC_JSON_STRING, true); - // TODO(ncteisen): Either format this as google.rpc.Status here, or ensure - // it is done in the layers above core. if (error_ != GRPC_ERROR_NONE) { grpc_status_code code; grpc_slice message; diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 8c10de91032..f9bc6db82b3 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -19,23 +19,58 @@ #include #include +#include + #include #include -#include - #include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/json/json.h" -#include "test/core/util/channel_tracing_utils.h" #include "test/core/util/test_config.h" namespace grpc_core { namespace testing { namespace { +grpc_json* GetJsonChild(grpc_json* parent, const char* key) { + EXPECT_NE(parent, nullptr); + for (grpc_json* child = parent->child; child != nullptr; + child = child->next) { + if (child->key != nullptr && strcmp(child->key, key) == 0) return child; + } + return nullptr; +} + +void ValidateJsonArraySize(grpc_json* json, const char* key, + size_t expected_size) { + grpc_json* arr = GetJsonChild(json, key); + ASSERT_NE(arr, nullptr); + ASSERT_EQ(arr->type, GRPC_JSON_ARRAY); + size_t count = 0; + for (grpc_json* child = arr->child; child != nullptr; child = child->next) { + ++count; + } + ASSERT_EQ(count, expected_size); +} + +void ValidateChannelTraceData(grpc_json* json, + size_t num_events_logged_expected, + size_t actual_num_events_expected) { + ASSERT_NE(json, nullptr); + grpc_json* num_events_logged_json = GetJsonChild(json, "num_events_logged"); + ASSERT_NE(num_events_logged_json, nullptr); + grpc_json* start_time = GetJsonChild(json, "creation_time"); + ASSERT_NE(start_time, nullptr); + size_t num_events_logged = + (size_t)strtol(num_events_logged_json->value, nullptr, 0); + ASSERT_EQ(num_events_logged, num_events_logged_expected); + ValidateJsonArraySize(json, "events", actual_num_events_expected); +} + void AddSimpleTrace(RefCountedPtr tracer) { tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), @@ -48,7 +83,7 @@ void ValidateChannelTrace(RefCountedPtr tracer, if (!max_nodes) return; char* json_str = tracer->RenderTrace(); grpc_json* json = grpc_json_parse_string(json_str); - validate_channel_trace_data(json, expected_num_event_logged, + ValidateChannelTraceData(json, expected_num_event_logged, GPR_MIN(expected_num_event_logged, max_nodes)); grpc_json_destroy(json); gpr_free(json_str); @@ -61,16 +96,20 @@ void ValidateTraceDataMatchedUuidLookup(RefCountedPtr tracer) { ChannelTrace* uuid_lookup = grpc_channel_trace_registry_get_channel_trace(uuid); char* uuid_lookup_json_str = uuid_lookup->RenderTrace(); - GPR_ASSERT(strcmp(tracer_json_str, uuid_lookup_json_str) == 0); + EXPECT_EQ(strcmp(tracer_json_str, uuid_lookup_json_str), 0); gpr_free(tracer_json_str); gpr_free(uuid_lookup_json_str); } +} // anonymous namespace + +class ChannelTracerTest : public ::testing::TestWithParam {}; + // Tests basic ChannelTrace functionality like construction, adding trace, and // lookups by uuid. -void TestBasicChannelTrace(size_t max_nodes) { +TEST_P(ChannelTracerTest, BasicTest) { grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(max_nodes); + RefCountedPtr tracer = MakeRefCounted(GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); ValidateTraceDataMatchedUuidLookup(tracer); @@ -81,15 +120,15 @@ void TestBasicChannelTrace(size_t max_nodes) { GRPC_CHANNEL_IDLE); tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); - ValidateChannelTrace(tracer, 4, max_nodes); + ValidateChannelTrace(tracer, 4, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 6, max_nodes); + ValidateChannelTrace(tracer, 6, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); AddSimpleTrace(tracer); AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 10, max_nodes); + ValidateChannelTrace(tracer, 10, GetParam()); ValidateTraceDataMatchedUuidLookup(tracer); tracer.reset(nullptr); } @@ -97,34 +136,34 @@ void TestBasicChannelTrace(size_t max_nodes) { // Tests more complex functionality, like a parent channel tracking // subchannles. This exercises the ref/unref patterns since the parent tracer // and this function will both hold refs to the subchannel. -void TestComplexChannelTrace(size_t max_nodes) { +TEST_P(ChannelTracerTest, ComplexTest) { grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(max_nodes); + RefCountedPtr tracer = MakeRefCounted(GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); - RefCountedPtr sc1 = MakeRefCounted(max_nodes); + RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - ValidateChannelTrace(tracer, 3, max_nodes); + ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); AddSimpleTrace(sc1); AddSimpleTrace(sc1); - ValidateChannelTrace(sc1, 3, max_nodes); + ValidateChannelTrace(sc1, 3, GetParam()); AddSimpleTrace(sc1); AddSimpleTrace(sc1); AddSimpleTrace(sc1); - ValidateChannelTrace(sc1, 6, max_nodes); + ValidateChannelTrace(sc1, 6, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); - ValidateChannelTrace(tracer, 5, max_nodes); + ValidateChannelTrace(tracer, 5, GetParam()); ValidateTraceDataMatchedUuidLookup(tracer); - RefCountedPtr sc2 = MakeRefCounted(max_nodes); + RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); tracer->AddTraceEvent( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); - ValidateChannelTrace(tracer, 7, max_nodes); + ValidateChannelTrace(tracer, 7, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); AddSimpleTrace(tracer); @@ -137,49 +176,26 @@ void TestComplexChannelTrace(size_t max_nodes) { sc2.reset(nullptr); } -} // anonymous namespace - -// Calls basic test with various values for max_nodes (including 0, which turns -// the tracer off). -TEST(ChannelTracerTest, BasicTest) { - TestBasicChannelTrace(0); - TestBasicChannelTrace(1); - TestBasicChannelTrace(2); - TestBasicChannelTrace(6); - TestBasicChannelTrace(10); - TestBasicChannelTrace(15); -} - -// Calls the complex test with a sweep of sizes for max_nodes. -TEST(ChannelTracerTest, ComplexTest) { - TestComplexChannelTrace(0); - TestComplexChannelTrace(1); - TestComplexChannelTrace(2); - TestComplexChannelTrace(6); - TestComplexChannelTrace(10); - TestComplexChannelTrace(15); -} - // Test a case in which the parent channel has subchannels and the subchannels // have connections. Ensures that everything lives as long as it should then // gets deleted. -TEST(ChannelTracerTest, TestNesting) { +TEST_P(ChannelTracerTest, TestNesting) { grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(10); + RefCountedPtr tracer = MakeRefCounted(GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); - RefCountedPtr sc1 = MakeRefCounted(5); + RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); AddSimpleTrace(sc1); - RefCountedPtr conn1 = MakeRefCounted(5); + RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); - RefCountedPtr sc2 = MakeRefCounted(5); + RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); // this trace should not get added to the parents children since it is already @@ -194,6 +210,9 @@ TEST(ChannelTracerTest, TestNesting) { conn1.reset(nullptr); } +INSTANTIATE_TEST_CASE_P(ChannelTracerTestSweep, ChannelTracerTest, + ::testing::Values(0, 1, 2, 6, 10, 15)); + } // namespace testing } // namespace grpc_core diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 366cf05690b..c3458db45a5 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -51,7 +51,6 @@ grpc_cc_library( grpc_cc_library( name = "grpc_test_util_base", srcs = [ - "channel_tracing_utils.cc", "cmdline.cc", "grpc_profiler.cc", "histogram.cc", @@ -70,7 +69,6 @@ grpc_cc_library( "trickle_endpoint.cc", ], hdrs = [ - "channel_tracing_utils.h", "cmdline.h", "grpc_profiler.h", "histogram.h", diff --git a/test/core/util/channel_tracing_utils.cc b/test/core/util/channel_tracing_utils.cc deleted file mode 100644 index be37703ecc3..00000000000 --- a/test/core/util/channel_tracing_utils.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright 2017 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. - * - */ - -#include -#include - -#include -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/gpr/useful.h" -#include "src/core/lib/json/json.h" - -static grpc_json* get_json_child(grpc_json* parent, const char* key) { - GPR_ASSERT(parent != nullptr); - for (grpc_json* child = parent->child; child != nullptr; - child = child->next) { - if (child->key != nullptr && strcmp(child->key, key) == 0) return child; - } - return nullptr; -} - -void validate_json_array_size(grpc_json* json, const char* key, - size_t expected_size) { - grpc_json* arr = get_json_child(json, key); - GPR_ASSERT(arr); - GPR_ASSERT(arr->type == GRPC_JSON_ARRAY); - size_t count = 0; - for (grpc_json* child = arr->child; child != nullptr; child = child->next) { - ++count; - } - GPR_ASSERT(count == expected_size); -} - -void validate_channel_trace_data(grpc_json* json, - size_t num_events_logged_expected, - size_t actual_num_events_expected) { - GPR_ASSERT(json); - grpc_json* num_events_logged_json = get_json_child(json, "num_events_logged"); - GPR_ASSERT(num_events_logged_json); - grpc_json* start_time = get_json_child(json, "creation_time"); - GPR_ASSERT(start_time); - size_t num_events_logged = - (size_t)strtol(num_events_logged_json->value, nullptr, 0); - GPR_ASSERT(num_events_logged == num_events_logged_expected); - validate_json_array_size(json, "events", actual_num_events_expected); -} diff --git a/test/core/util/channel_tracing_utils.h b/test/core/util/channel_tracing_utils.h deleted file mode 100644 index 2038cd83aab..00000000000 --- a/test/core/util/channel_tracing_utils.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Copyright 2017 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. - * - */ - -#ifndef GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H -#define GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H - -void validate_json_array_size(grpc_json* json, const char* key, - size_t expected_size); - -void validate_channel_trace_data(grpc_json* json, - size_t num_events_logged_expected, - size_t actual_num_events_expected); - -#endif /* GRPC_TEST_CORE_UTIL_CHANNEL_TRACING_UTILS_H */ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 706ec698451..9d8c9778cff 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -9529,7 +9529,6 @@ "test/core/end2end/fixtures/http_proxy_fixture.h", "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.h", - "test/core/util/channel_tracing_utils.h", "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.h", "test/core/util/histogram.h", @@ -9558,8 +9557,6 @@ "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.cc", "test/core/iomgr/endpoint_tests.h", - "test/core/util/channel_tracing_utils.cc", - "test/core/util/channel_tracing_utils.h", "test/core/util/debugger_macros.cc", "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.cc", From 07ed0396a900d01dc2b2142892417254e52eca77 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 21:44:08 -0800 Subject: [PATCH 51/67] Add JsonProtoTest --- CMakeLists.txt | 53 +++ Makefile | 72 +++ build.yaml | 20 + src/proto/grpc/channelz/BUILD | 24 + src/proto/grpc/channelz/channelz.proto | 437 ++++++++++++++++++ test/core/channel/channel_trace_test.cc | 8 +- test/cpp/client/BUILD | 13 + .../client/channel_trace_proto_json_test.cc | 82 ++++ .../generated/sources_and_headers.json | 38 ++ tools/run_tests/generated/tests.json | 24 + 10 files changed, 767 insertions(+), 4 deletions(-) create mode 100644 src/proto/grpc/channelz/BUILD create mode 100644 src/proto/grpc/channelz/channelz.proto create mode 100644 test/cpp/client/channel_trace_proto_json_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 34cf01a208d..f6426932ec4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -517,6 +517,7 @@ add_dependencies(buildtests_cxx bm_pollset) endif() add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) +add_dependencies(buildtests_cxx channel_trace_proto_json_test) add_dependencies(buildtests_cxx channel_trace_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) add_dependencies(buildtests_cxx cli_call_test) @@ -9483,12 +9484,64 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(channel_trace_proto_json_test + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h + test/cpp/client/channel_trace_proto_json_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + +protobuf_generate_grpc_cpp( + src/proto/grpc/channelz/channelz.proto +) + +target_include_directories(channel_trace_proto_json_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${_gRPC_SSL_INCLUDE_DIR} + PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} + PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} + PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} + PRIVATE ${_gRPC_CARES_INCLUDE_DIR} + PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(channel_trace_proto_json_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_test_util + grpc_test_util + grpc++ + grpc + gpr_test_util + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(channel_trace_test test/core/channel/channel_trace_test.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) +protobuf_generate_grpc_cpp( + src/proto/grpc/channelz/channelz.proto +) target_include_directories(channel_trace_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Makefile b/Makefile index 26126a32c19..3dc9729752a 100644 --- a/Makefile +++ b/Makefile @@ -1114,6 +1114,7 @@ bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test +channel_trace_proto_json_test: $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test channel_trace_test: $(BINDIR)/$(CONFIG)/channel_trace_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test @@ -1583,6 +1584,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test \ $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ @@ -1732,6 +1734,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ + $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test \ $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ @@ -2129,6 +2132,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) + $(E) "[RUN] Testing channel_trace_proto_json_test" + $(Q) $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test || ( echo test channel_trace_proto_json_test failed ; exit 1 ) $(E) "[RUN] Testing channel_trace_test" $(Q) $(BINDIR)/$(CONFIG)/channel_trace_test || ( echo test channel_trace_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_settings_timeout_test" @@ -2363,6 +2368,22 @@ $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: $(Q) mkdir -p $(@D) $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@ +ifeq ($(NO_PROTOC),true) +$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: protoc_dep_error +else + +$(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc: src/proto/grpc/channelz/channelz.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[PROTOC] Generating protobuf CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< + +$(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc: src/proto/grpc/channelz/channelz.proto $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< +endif + ifeq ($(NO_PROTOC),true) $(GENDIR)/src/proto/grpc/core/stats.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/core/stats.grpc.pb.cc: protoc_dep_error @@ -15132,8 +15153,56 @@ endif endif +CHANNEL_TRACE_PROTO_JSON_TEST_SRC = \ + $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ + test/cpp/client/channel_trace_proto_json_test.cc \ + +CHANNEL_TRACE_PROTO_JSON_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_PROTO_JSON_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/channel_trace_proto_json_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/channel_trace_proto_json_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/channel_trace_proto_json_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +$(OBJDIR)/$(CONFIG)/test/cpp/client/channel_trace_proto_json_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_channel_trace_proto_json_test: $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS:.o=.dep) +endif +endif +$(OBJDIR)/$(CONFIG)/test/cpp/client/channel_trace_proto_json_test.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc + + CHANNEL_TRACE_TEST_SRC = \ test/core/channel/channel_trace_test.cc \ + $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ CHANNEL_TRACE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_TEST_SRC)))) ifeq ($(NO_SECURE),true) @@ -15166,6 +15235,8 @@ endif $(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + deps_channel_trace_test: $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) @@ -15173,6 +15244,7 @@ ifneq ($(NO_DEPS),true) -include $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) endif endif +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc CHTTP2_SETTINGS_TIMEOUT_TEST_SRC = \ diff --git a/build.yaml b/build.yaml index c3511d33425..08fb17e7e0e 100644 --- a/build.yaml +++ b/build.yaml @@ -974,6 +974,10 @@ filegroups: secure: true uses: - grpc_trace +- name: grpc++_channelz_proto + language: c++ + src: + - src/proto/grpc/channelz/channelz.proto - name: grpc++_codegen_base language: c++ public_headers: @@ -3883,6 +3887,20 @@ targets: - grpc - gpr uses_polling: false +- name: channel_trace_proto_json_test + gtest: true + build: test + language: c++ + src: + - src/proto/grpc/channelz/channelz.proto + - test/cpp/client/channel_trace_proto_json_test.cc + deps: + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr_test_util + - gpr - name: channel_trace_test gtest: true build: test @@ -3895,6 +3913,8 @@ targets: - grpc - gpr_test_util - gpr + filegroups: + - grpc++_channelz_proto uses: - grpc++_test uses_polling: false diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD new file mode 100644 index 00000000000..9318e5ccdec --- /dev/null +++ b/src/proto/grpc/channelz/BUILD @@ -0,0 +1,24 @@ +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_proto_library", "grpc_package") + +grpc_package(name = "channelz", visibility = "public") + +grpc_proto_library( + name = "channelz_proto", + srcs = ["channelz.proto"], +) diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto new file mode 100644 index 00000000000..532ec7978ff --- /dev/null +++ b/src/proto/grpc/channelz/channelz.proto @@ -0,0 +1,437 @@ +syntax = "proto3"; + +package grpc.channelz; + +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +// See go/grpc-channelz. + +// Channel is a logical grouping of channels, subchannels, and sockets. +message Channel { + // The identifier for this channel. + ChannelRef ref = 1; + // Data specific to this channel. + ChannelData data = 2; + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + + // There are no ordering guarantees on the order of channel refs. + // There may not be cycles in the ref graph. + // A channel ref may be present in more than one channel or subchannel. + repeated ChannelRef channel_ref = 3; + + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of subchannel refs. + // There may not be cycles in the ref graph. + // A sub channel ref may be present in more than one channel or subchannel. + repeated SubchannelRef subchannel_ref = 4; + + // There are no ordering guarantees on the order of sockets. + repeated SocketRef socket = 5; +} + +// Subchannel is a logical grouping of channels, subchannels, and sockets. +// A subchannel is load balanced over by it's ancestor +message Subchannel { + // The identifier for this channel. + SubchannelRef ref = 1; + // Data specific to this channel. + ChannelData data = 2; + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + + // There are no ordering guarantees on the order of channel refs. + // There may not be cycles in the ref graph. + // A channel ref may be present in more than one channel or subchannel. + repeated ChannelRef channel_ref = 3; + + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of subchannel refs. + // There may not be cycles in the ref graph. + // A sub channel ref may be present in more than one channel or subchannel. + repeated SubchannelRef subchannel_ref = 4; + + // There are no ordering guarantees on the order of sockets. + repeated SocketRef socket = 5; +} + +// These come from the specified states in this document: +// https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md +message ChannelConnectivityState { + enum State { + UNKNOWN = 0; + IDLE = 1; + CONNECTING = 2; + READY = 3; + TRANSIENT_FAILURE = 4; + SHUTDOWN = 5; + } + State state = 1; +} + +message ChannelData { + + ChannelConnectivityState state = 1; + + // The target this channel originally tried to connect to. May be absent + string target = 2; + + ChannelTrace trace = 3; + + // The number of calls started on the channel + int64 calls_started = 4; + // The number of calls that have completed with an OK status + int64 calls_succeeded = 5; + // The number of calls that have a completed with a non-OK status + int64 calls_failed = 6; + + // The last time a call was started on the channel. + google.protobuf.Timestamp last_call_started_timestamp = 7; +} + +// A trace event is an interesting thing that happened to a channel or +// subchannel, such as creation, address resolution, subchannel creation, etc. +message ChannelTraceEvent { + // High level description of the event. + string description = 1; + // the severity of the trace event. Options are INFO, WARNING, and ERROR, + // which are represented by the values 1, 2, and 3, respectively. Any other + // value will be treated as ERROR. + int32 trace_level = 2; + // When this event occurred. + google.protobuf.Timestamp timestamp = 3; + // ref of referenced channel or subchannel. + // Optional, only present if this event refers to a child object. For example, + // this field would be filled if this trace event was for a subchannel being + // created. + oneof child_ref { + ChannelRef channel_ref = 4; + SubchannelRef subchannel_ref = 5; + } +} + +message ChannelTrace { + // Number of events ever logged in this tracing object. This can differ from + // events.size() because events can be overwritten or garbage collected by + // implementations. + int64 num_events_logged = 1; + // Time that this channel was created. + google.protobuf.Timestamp creation_time = 2; + // List of events that have occurred on this channel. + repeated ChannelTraceEvent events = 3; +} + +message ChannelRef { + // The globally unique id for this channel. Must be a positive number. + int64 channel_id = 1; + // An optional name associated with the channel. + string name = 2; + // Intentionally don't use field numbers from other refs. + reserved 3, 4, 5, 6; +} + +message SubchannelRef { + // The globally unique id for this subchannel. Must be a positive number. + int64 subchannel_id = 7; + // An optional name associated with the subchannel. + string name = 8; + // Intentionally don't use field numbers from other refs. + reserved 1, 2, 3, 4, 5, 6; +} + +message SocketRef { + int64 socket_id = 3; + // An optional name associated with the socket. + string name = 4; + // Intentionally don't use field numbers from other refs. + reserved 1, 2, 5, 6, 7, 8; +} + +message ServerRef { + // A globally unique identifier for this server. Must be a positive number. + int64 server_id = 5; + // An optional name associated with the server. + string name = 6; + // Intentionally don't use field numbers from other refs. + reserved 1, 2, 3, 4, 7, 8; +} + +message Server { + ServerRef ref = 1; + ServerData data = 2; + + // The sockets that the server is listening on. There are no ordering + // guarantees. + repeated SocketRef listen_socket = 3; +} + +message ServerData { + ChannelTrace trace = 1; + + // The number of incoming calls started on the server + int64 calls_started = 2; + // The number of incoming calls that have completed with an OK status + int64 calls_succeeded = 3; + // The number of incoming calls that have a completed with a non-OK status + int64 calls_failed = 4; + + // The last time a call was started on the server. + google.protobuf.Timestamp last_call_started_timestamp = 5; +} + +// Information about an actual connection. Pronounced "sock-ay". +message Socket { + SocketRef ref = 1; + + SocketData data = 2; + // The locally bound address. + Address local = 3; + // The remote bound address. May be absent. + Address remote = 4; + Security security = 5; + + // Optional, represents the name of the remote endpoint, if different than + // the original target name. + string remote_name = 6; +} + +message SocketData { + // The number of streams that have been started. + int64 streams_started = 1; + // The number of streams that have ended successfully with the EoS bit set for + // both end points + int64 streams_succeeded = 2; + // The number of incoming streams that have a completed with a non-OK status + int64 streams_failed = 3; + + // The number of messages successfully sent on this socket. + int64 messages_sent = 4; + int64 messages_received = 5; + + // The number of keep alives sent. This is typically implemented with HTTP/2 + // ping messages. + int64 keep_alives_sent = 6; + + // The last time a stream was created by this endpoint. Usually unset for + // servers. + google.protobuf.Timestamp last_local_stream_created_timestamp = 7; + // The last time a stream was created by the remote endpoint. Usually unset + // for clients. + google.protobuf.Timestamp last_remote_stream_created_timestamp = 8; + + // The last time a message was sent by this endpoint. + google.protobuf.Timestamp last_message_sent_timestamp = 9; + // The last time a message was received by this endpoint. + google.protobuf.Timestamp last_message_received_timestamp = 10; + + // The amount of window, granted to the local endpoint by the remote endpoint. + // This may be slightly out of date due to network latency. This does NOT + // include stream level or TCP level flow control info. + google.protobuf.Int64Value local_flow_control_window = 11; + + // The amount of window, granted to the remote endpoint by the local endpoint. + // This may be slightly out of date due to network latency. This does NOT + // include stream level or TCP level flow control info. + google.protobuf.Int64Value remote_flow_control_window = 12; + + repeated SocketOption option = 13; +} + +message Address { + message TcpIpAddress { + // Either the IPv4 or IPv6 address in bytes. Will either be 4 bytes or 16 + // bytes in length. + bytes ip_address = 1; + // 0-64k, or -1 if not appropriate. + int32 port = 2; + } + // A Unix Domain Socket address. + message UdsAddress { + string filename = 1; + } + // An address type not included above. + message OtherAddress { + // The human readable version of the value. + string name = 1; + // The actual address message. + google.protobuf.Any value = 2; + } + + oneof address { + TcpIpAddress tcpip_address = 1; + UdsAddress uds_address = 2; + OtherAddress other_address = 3; + } +} + +message Security { + message Tls { + // The key exchange used. e.g. X25519 + string key_exchange = 1; + // The cipher used. e.g. AES_128_GCM. + string cipher = 2; + // the certificate used by this endpoint. + bytes local_certificate = 3; + // the certificate used by the remote endpoint. + bytes remote_certificate = 4; + } + message OtherSecurity { + // The human readable version of the value. + string name = 1; + // The actual security details message. + google.protobuf.Any value = 2; + } + oneof model { + Tls tls = 1; + OtherSecurity other = 2; + } +} + +message SocketOption { + string name = 1; + // The human readable value of this socket option. At least one of value or + // additional will be set. + string value = 2; + // Additional data associated with the socket option. At least one of value + // or additional will be set. + google.protobuf.Any additional = 3; +} + +// For use with SocketOption's additional field. This is primarily used for +// SO_RCVTIMEO and SO_SNDTIMEO +message SocketOptionTimeout { + google.protobuf.Duration duration = 1; +} + +message SocketOptionLinger { + bool active = 1; + google.protobuf.Duration duration = 2; +} + +// Tcp info for SOL_TCP, TCP_INFO +message SocketOptionTcpInfo { + uint32 tcpi_state = 1; + + uint32 tcpi_ca_state = 2; + uint32 tcpi_retransmits = 3; + uint32 tcpi_probes = 4; + uint32 tcpi_backoff = 5; + uint32 tcpi_options = 6; + uint32 tcpi_snd_wscale = 7; + uint32 tcpi_rcv_wscale = 8; + + uint32 tcpi_rto = 9; + uint32 tcpi_ato = 10; + uint32 tcpi_snd_mss = 11; + uint32 tcpi_rcv_mss = 12; + + uint32 tcpi_unacked = 13; + uint32 tcpi_sacked = 14; + uint32 tcpi_lost = 15; + uint32 tcpi_retrans = 16; + uint32 tcpi_fackets = 17; + + uint32 tcpi_last_data_sent = 18; + uint32 tcpi_last_ack_sent = 19; + uint32 tcpi_last_data_recv = 20; + uint32 tcpi_last_ack_recv = 21; + + uint32 tcpi_pmtu = 22; + uint32 tcpi_rcv_ssthresh = 23; + uint32 tcpi_rtt = 24; + uint32 tcpi_rttvar = 25; + uint32 tcpi_snd_ssthresh = 26; + uint32 tcpi_snd_cwnd = 27; + uint32 tcpi_advmss = 28; + uint32 tcpi_reordering = 29; +} + +service Channelz { + // Gets all root channels (e.g. channels the application has directly + // created). This does not include subchannels nor non-top level channels. + rpc GetTopChannels(GetTopChannelsRequest) returns (GetTopChannelsResponse); + // Gets all servers that exist in the process. + rpc GetServers(GetServersRequest) returns (GetServersResponse); + // Gets all server sockets that exist in the process. + rpc GetServerSockets(GetServerSocketsRequest) returns (GetServerSocketsResponse); + // Returns a single Channel, or else a NOT_FOUND code. + rpc GetChannel(GetChannelRequest) returns (GetChannelResponse); + // Returns a single Subchannel, or else a NOT_FOUND code. + rpc GetSubchannel(GetSubchannelRequest) returns (GetSubchannelResponse); + // Returns a single Socket or else a NOT_FOUND code. + rpc GetSocket(GetSocketRequest) returns (GetSocketResponse); +} + +message GetServersRequest { + // start_server_id indicates that only servers at or above this id should be + // included in the results. + int64 start_server_id = 1; +} + +message GetServersResponse { + // list of servers that the connection detail service knows about. Sorted in + // ascending server_id order. + repeated Server server = 1; + // If set, indicates that the list of servers is the final list. Requesting + // more servers will only return more if they are created after this RPC + // completes. + bool end = 2; +} + +message GetServerSocketsRequest { + int64 server_id = 1; + // start_socket_id indicates that only sockets at or above this id should be + // included in the results. + int64 start_socket_id = 2; +} + +message GetServerSocketsResponse { + // list of socket refs that the connection detail service knows about. Sorted in + // ascending socket_id order. + repeated SocketRef socket_ref = 1; + // If set, indicates that the list of sockets is the final list. Requesting + // more sockets will only return more if they are created after this RPC + // completes. + bool end = 2; +} + +message GetTopChannelsRequest { + // start_channel_id indicates that only channels at or above this id should be + // included in the results. + int64 start_channel_id = 1; +} + +message GetTopChannelsResponse { + // list of channels that the connection detail service knows about. Sorted in + // ascending channel_id order. + repeated Channel channel = 1; + // If set, indicates that the list of channels is the final list. Requesting + // more channels can only return more if they are created after this RPC + // completes. + bool end = 2; +} + +message GetChannelRequest { + int64 channel_id = 1; +} + +message GetChannelResponse { + Channel channel = 1; +} + +message GetSubchannelRequest { + int64 subchannel_id = 1; +} + +message GetSubchannelResponse { + Subchannel subchannel = 1; +} + +message GetSocketRequest { + int64 socket_id = 1; +} + +message GetSocketResponse { + Socket socket = 1; +} diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index f9bc6db82b3..ea0c6be912f 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -46,7 +46,7 @@ grpc_json* GetJsonChild(grpc_json* parent, const char* key) { } void ValidateJsonArraySize(grpc_json* json, const char* key, - size_t expected_size) { + size_t expected_size) { grpc_json* arr = GetJsonChild(json, key); ASSERT_NE(arr, nullptr); ASSERT_EQ(arr->type, GRPC_JSON_ARRAY); @@ -58,8 +58,8 @@ void ValidateJsonArraySize(grpc_json* json, const char* key, } void ValidateChannelTraceData(grpc_json* json, - size_t num_events_logged_expected, - size_t actual_num_events_expected) { + size_t num_events_logged_expected, + size_t actual_num_events_expected) { ASSERT_NE(json, nullptr); grpc_json* num_events_logged_json = GetJsonChild(json, "num_events_logged"); ASSERT_NE(num_events_logged_json, nullptr); @@ -84,7 +84,7 @@ void ValidateChannelTrace(RefCountedPtr tracer, char* json_str = tracer->RenderTrace(); grpc_json* json = grpc_json_parse_string(json_str); ValidateChannelTraceData(json, expected_num_event_logged, - GPR_MIN(expected_num_event_logged, max_nodes)); + GPR_MIN(expected_num_event_logged, max_nodes)); grpc_json_destroy(json); gpr_free(json_str); } diff --git a/test/cpp/client/BUILD b/test/cpp/client/BUILD index 12825e88c26..3cbd63a99e4 100644 --- a/test/cpp/client/BUILD +++ b/test/cpp/client/BUILD @@ -18,6 +18,19 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_p grpc_package(name = "test/cpp/client") +grpc_cc_test( + name = "channel_trace_proto_json_test", + srcs = ["channel_trace_proto_json_test.cc"], + external_deps = [ + "gtest", + ], + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + ], +) + grpc_cc_test( name = "credentials_test", srcs = ["credentials_test.cc"], diff --git a/test/cpp/client/channel_trace_proto_json_test.cc b/test/cpp/client/channel_trace_proto_json_test.cc new file mode 100644 index 00000000000..d68adb360fb --- /dev/null +++ b/test/cpp/client/channel_trace_proto_json_test.cc @@ -0,0 +1,82 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include + +#include +#include + +#include "src/core/lib/channel/channel_trace.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/proto/grpc/channelz/channelz.pb.h" + +namespace grpc { +namespace testing { + +using grpc_core::ChannelTrace; +using grpc_core::MakeRefCounted; +using grpc_core::RefCountedPtr; + +namespace { + +void AddSimpleTrace(RefCountedPtr tracer) { + tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_CHANNEL_READY); +} + +} // namespace + +TEST(ChannelTraceTest, ProtoJsonTest) { + grpc_core::ExecCtx exec_ctx; + RefCountedPtr tracer = MakeRefCounted(10); + AddSimpleTrace(tracer); + AddSimpleTrace(tracer); + tracer->AddTraceEvent( + grpc_slice_from_static_string("trace three"), + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), + GRPC_ERROR_INT_HTTP2_ERROR, 2), + GRPC_CHANNEL_IDLE); + tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), + GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); + std::string json_str = tracer->RenderTrace(); + gpr_log(GPR_ERROR, "%s", json_str.c_str()); + grpc::channelz::ChannelTrace channel_trace; + google::protobuf::util::JsonParseOptions options; + options.ignore_unknown_fields = true; + ASSERT_EQ(google::protobuf::util::JsonStringToMessage( + json_str, &channel_trace, options), + google::protobuf::util::Status::OK); + std::string str; + google::protobuf::TextFormat::PrintToString(channel_trace, &str); + gpr_log(GPR_ERROR, "%s", str.c_str()); +} + +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + grpc_shutdown(); + return ret; +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 9d8c9778cff..baf9be749b9 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2831,6 +2831,30 @@ "gpr_test_util", "grpc", "grpc++", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [ + "src/proto/grpc/channelz/channelz.grpc.pb.h", + "src/proto/grpc/channelz/channelz.pb.h", + "src/proto/grpc/channelz/channelz_mock.grpc.pb.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "channel_trace_proto_json_test", + "src": [ + "test/cpp/client/channel_trace_proto_json_test.cc" + ], + "third_party": false, + "type": "target" + }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc++", + "grpc++_channelz_proto", "grpc++_test", "grpc_test_util" ], @@ -10009,6 +10033,20 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [], + "headers": [ + "src/proto/grpc/channelz/channelz.grpc.pb.h", + "src/proto/grpc/channelz/channelz.pb.h", + "src/proto/grpc/channelz/channelz_mock.grpc.pb.h" + ], + "is_filegroup": true, + "language": "c++", + "name": "grpc++_channelz_proto", + "src": [], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "grpc_codegen" diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index cae60dd29a0..48ea61061f9 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3337,6 +3337,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "channel_trace_proto_json_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": true + }, { "args": [], "benchmark": false, From 503099b1ccced021a914b76a8eacf9375550e794 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 23:21:04 -0800 Subject: [PATCH 52/67] Redoing render, about to take things away --- src/core/lib/channel/channel_trace.cc | 39 +++++++++++++------ src/core/lib/channel/channel_trace.h | 19 ++++++--- test/core/channel/channel_trace_test.cc | 14 +++---- .../client/channel_trace_proto_json_test.cc | 34 +++++++++------- 4 files changed, 70 insertions(+), 36 deletions(-) diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 08f6f72d636..558c852c013 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -43,14 +43,15 @@ namespace grpc_core { ChannelTrace::TraceEvent::TraceEvent( grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) + RefCountedPtr referenced_tracer, ReferencedType type) : data_(data), error_(error), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), connectivity_state_(connectivity_state), next_(nullptr), - referenced_tracer_(std::move(referenced_tracer)) {} + referenced_tracer_(std::move(referenced_tracer)), + referenced_type_(type) {} ChannelTrace::TraceEvent::TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state) @@ -69,7 +70,6 @@ ChannelTrace::TraceEvent::~TraceEvent() { ChannelTrace::ChannelTrace(size_t max_events) : channel_uuid_(-1), num_events_logged_(0), - num_children_seen_(0), list_size_(0), max_list_size_(max_events), head_trace_(nullptr), @@ -116,15 +116,25 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { } } -void ChannelTrace::AddTraceEvent( +void ChannelTrace::AddTraceEventReferencingChannel( grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - ++num_children_seen_; // create and fill up the new event AddTraceEventHelper(New(data, error, connectivity_state, - std::move(referenced_tracer))); + std::move(referenced_tracer), Channel)); +} + +void ChannelTrace::AddTraceEventReferencingSubchannel( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer) { + if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 + // create and fill up the new event + AddTraceEventHelper(New(data, error, connectivity_state, + std::move(referenced_tracer), + Subchannel)); } void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, @@ -178,8 +188,15 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { if (referenced_tracer_ != nullptr) { char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); - json_iterator = grpc_json_create_child(json_iterator, json, "child_ref", - uuid_str, GRPC_JSON_NUMBER, true); + grpc_json* child_ref = grpc_json_create_child( + json_iterator, json, + (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", + nullptr, GRPC_JSON_OBJECT, false); + json_iterator = grpc_json_create_child( + nullptr, child_ref, + (referenced_type_ == Channel) ? "channelId" : "subchannelId", + uuid_str, GRPC_JSON_STRING, true); + json_iterator = child_ref; } } @@ -191,10 +208,10 @@ char* ChannelTrace::RenderTrace() const { gpr_asprintf(&num_events_logged_str, "%" PRId64, num_events_logged_); grpc_json* json_iterator = nullptr; json_iterator = - grpc_json_create_child(json_iterator, json, "num_events_logged", - num_events_logged_str, GRPC_JSON_NUMBER, true); + grpc_json_create_child(json_iterator, json, "numEventsLogged", + num_events_logged_str, GRPC_JSON_STRING, true); json_iterator = - grpc_json_create_child(json_iterator, json, "creation_time", + grpc_json_create_child(json_iterator, json, "creationTime", fmt_time(time_created_), GRPC_JSON_STRING, true); grpc_json* events = grpc_json_create_child(json_iterator, json, "events", nullptr, GRPC_JSON_ARRAY, false); diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index 536f51a1f6c..86270138d81 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -51,15 +51,21 @@ class ChannelTrace : public RefCounted { // TODO(ncteisen): Once channelz is implemented, the events should reference // the overall channelz object, not just the ChannelTrace object. - void AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + void AddTraceEventReferencingChannel( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer); + void AddTraceEventReferencingSubchannel( + grpc_slice data, grpc_error* error, + grpc_connectivity_state connectivity_state, + RefCountedPtr referenced_tracer); // Returns the tracing data rendered as a grpc json string. // The string is owned by the caller and must be freed. char* RenderTrace() const; private: + enum ReferencedType { Channel, Subchannel }; // Private class to encapsulate all the data and bookkeeping needed for a // a trace event. class TraceEvent { @@ -69,7 +75,8 @@ class ChannelTrace : public RefCounted { // overall channelz object, not just the ChannelTrace object TraceEvent(grpc_slice data, grpc_error* error, grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + RefCountedPtr referenced_tracer, + ReferencedType type); // Constructor for a TraceEvent that does not reverence a different // channel. @@ -94,6 +101,9 @@ class ChannelTrace : public RefCounted { TraceEvent* next_; // the tracer object for the (sub)channel that this trace event refers to. RefCountedPtr referenced_tracer_; + // the type that the referenced tracer points to. Unused if this trace + // does not point to any channel or subchannel + ReferencedType referenced_type_; }; // TraceEvent // Internal helper to add and link in a trace event @@ -102,7 +112,6 @@ class ChannelTrace : public RefCounted { gpr_mu tracer_mu_; intptr_t channel_uuid_; uint64_t num_events_logged_; - uint64_t num_children_seen_; size_t list_size_; size_t max_list_size_; TraceEvent* head_trace_; diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index ea0c6be912f..beb823eacf3 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -142,7 +142,7 @@ TEST_P(ChannelTracerTest, ComplexTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), + tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); @@ -158,9 +158,9 @@ TEST_P(ChannelTracerTest, ComplexTest) { ValidateChannelTrace(tracer, 5, GetParam()); ValidateTraceDataMatchedUuidLookup(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), + tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("LB channel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); - tracer->AddTraceEvent( + tracer->AddTraceEventReferencingSubchannel( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); ValidateChannelTrace(tracer, 7, GetParam()); @@ -185,22 +185,22 @@ TEST_P(ChannelTracerTest, TestNesting) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel one created"), + tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. - sc1->AddTraceEvent(grpc_slice_from_static_string("connection one created"), + sc1->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEvent(grpc_slice_from_static_string("subchannel two created"), + tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); // this trace should not get added to the parents children since it is already // present in the tracer. - tracer->AddTraceEvent( + tracer->AddTraceEventReferencingChannel( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); AddSimpleTrace(tracer); diff --git a/test/cpp/client/channel_trace_proto_json_test.cc b/test/cpp/client/channel_trace_proto_json_test.cc index d68adb360fb..98cf6762365 100644 --- a/test/cpp/client/channel_trace_proto_json_test.cc +++ b/test/cpp/client/channel_trace_proto_json_test.cc @@ -50,24 +50,32 @@ TEST(ChannelTraceTest, ProtoJsonTest) { RefCountedPtr tracer = MakeRefCounted(10); AddSimpleTrace(tracer); AddSimpleTrace(tracer); - tracer->AddTraceEvent( - grpc_slice_from_static_string("trace three"), - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_ERROR_INT_HTTP2_ERROR, 2), - GRPC_CHANNEL_IDLE); - tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), - GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); - std::string json_str = tracer->RenderTrace(); - gpr_log(GPR_ERROR, "%s", json_str.c_str()); + RefCountedPtr sc1 = MakeRefCounted(10); + tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel one created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + AddSimpleTrace(sc1); + RefCountedPtr sc2 = MakeRefCounted(10); + tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("LB channel two created"), + GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); + std::string tracer_json_str = tracer->RenderTrace(); + gpr_log(GPR_ERROR, "%s", tracer_json_str.c_str()); grpc::channelz::ChannelTrace channel_trace; google::protobuf::util::JsonParseOptions options; options.ignore_unknown_fields = true; ASSERT_EQ(google::protobuf::util::JsonStringToMessage( - json_str, &channel_trace, options), + tracer_json_str, &channel_trace, options), google::protobuf::util::Status::OK); - std::string str; - google::protobuf::TextFormat::PrintToString(channel_trace, &str); - gpr_log(GPR_ERROR, "%s", str.c_str()); + std::string proto_json_str; + ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, &proto_json_str), google::protobuf::util::Status::OK); + gpr_log(GPR_ERROR, "%s", proto_json_str.c_str()); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); } } // namespace testing From 568a95e0b45f31918bc5518ff847a5a456156765 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Tue, 6 Mar 2018 23:31:47 -0800 Subject: [PATCH 53/67] Make test work --- src/core/lib/channel/channel_trace.cc | 67 +++++-------------- src/core/lib/channel/channel_trace.h | 20 ++---- src/core/lib/surface/channel.cc | 3 +- test/core/channel/channel_trace_test.cc | 25 ++++--- .../client/channel_trace_proto_json_test.cc | 31 +++++---- 5 files changed, 55 insertions(+), 91 deletions(-) diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 558c852c013..bbbf59cdf9c 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -41,31 +41,22 @@ namespace grpc_core { ChannelTrace::TraceEvent::TraceEvent( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer, ReferencedType type) + grpc_slice data, RefCountedPtr referenced_tracer, + ReferencedType type) : data_(data), - error_(error), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), - connectivity_state_(connectivity_state), next_(nullptr), referenced_tracer_(std::move(referenced_tracer)), referenced_type_(type) {} -ChannelTrace::TraceEvent::TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) +ChannelTrace::TraceEvent::TraceEvent(grpc_slice data) : data_(data), - error_(error), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), - connectivity_state_(connectivity_state), next_(nullptr) {} -ChannelTrace::TraceEvent::~TraceEvent() { - GRPC_ERROR_UNREF(error_); - grpc_slice_unref_internal(data_); -} +ChannelTrace::TraceEvent::~TraceEvent() { grpc_slice_unref_internal(data_); } ChannelTrace::ChannelTrace(size_t max_events) : channel_uuid_(-1), @@ -117,30 +108,24 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { } void ChannelTrace::AddTraceEventReferencingChannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { + grpc_slice data, RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 // create and fill up the new event - AddTraceEventHelper(New(data, error, connectivity_state, - std::move(referenced_tracer), Channel)); + AddTraceEventHelper( + New(data, std::move(referenced_tracer), Channel)); } void ChannelTrace::AddTraceEventReferencingSubchannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer) { + grpc_slice data, RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 // create and fill up the new event - AddTraceEventHelper(New(data, error, connectivity_state, - std::move(referenced_tracer), - Subchannel)); + AddTraceEventHelper( + New(data, std::move(referenced_tracer), Subchannel)); } -void ChannelTrace::AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state) { +void ChannelTrace::AddTraceEvent(grpc_slice data) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - AddTraceEventHelper(New(data, error, connectivity_state)); + AddTraceEventHelper(New(data)); } namespace { @@ -162,40 +147,20 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), GRPC_JSON_STRING, true); - if (error_ != GRPC_ERROR_NONE) { - grpc_status_code code; - grpc_slice message; - grpc_error_get_status(error_, GRPC_MILLIS_INF_FUTURE, &code, &message, - nullptr, nullptr); - grpc_json* status = grpc_json_create_child( - json_iterator, json, "status", nullptr, GRPC_JSON_OBJECT, false); - json_iterator = grpc_json_create_child(nullptr, status, "code", - grpc_status_code_to_string(code), - GRPC_JSON_STRING, false); - grpc_json_create_child(json_iterator, status, "message", - grpc_slice_to_c_string(message), GRPC_JSON_STRING, - true); - grpc_slice_unref_internal(message); - json_iterator = status; - } json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", fmt_time(timestamp_), GRPC_JSON_STRING, true); - json_iterator = - grpc_json_create_child(json_iterator, json, "state", - grpc_connectivity_state_name(connectivity_state_), - GRPC_JSON_STRING, false); if (referenced_tracer_ != nullptr) { char* uuid_str; gpr_asprintf(&uuid_str, "%" PRIdPTR, referenced_tracer_->channel_uuid_); grpc_json* child_ref = grpc_json_create_child( json_iterator, json, - (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", - nullptr, GRPC_JSON_OBJECT, false); + (referenced_type_ == Channel) ? "channelRef" : "subchannelRef", nullptr, + GRPC_JSON_OBJECT, false); json_iterator = grpc_json_create_child( nullptr, child_ref, - (referenced_type_ == Channel) ? "channelId" : "subchannelId", - uuid_str, GRPC_JSON_STRING, true); + (referenced_type_ == Channel) ? "channelId" : "subchannelId", uuid_str, + GRPC_JSON_STRING, true); json_iterator = child_ref; } } diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index 86270138d81..0c46ede600f 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -41,8 +41,7 @@ class ChannelTrace : public RefCounted { intptr_t GetUuid() const; // Adds a new trace event to the tracing object - void AddTraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); + void AddTraceEvent(grpc_slice data); // Adds a new trace event to the tracing object. This trace event refers to a // an event on a child of the channel. For example, if this channel has @@ -52,13 +51,9 @@ class ChannelTrace : public RefCounted { // TODO(ncteisen): Once channelz is implemented, the events should reference // the overall channelz object, not just the ChannelTrace object. void AddTraceEventReferencingChannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + grpc_slice data, RefCountedPtr referenced_tracer); void AddTraceEventReferencingSubchannel( - grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer); + grpc_slice data, RefCountedPtr referenced_tracer); // Returns the tracing data rendered as a grpc json string. // The string is owned by the caller and must be freed. @@ -73,15 +68,12 @@ class ChannelTrace : public RefCounted { // Constructor for a TraceEvent that references a different channel. // TODO(ncteisen): once channelz is implemented, this should reference the // overall channelz object, not just the ChannelTrace object - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state, - RefCountedPtr referenced_tracer, + TraceEvent(grpc_slice data, RefCountedPtr referenced_tracer, ReferencedType type); // Constructor for a TraceEvent that does not reverence a different // channel. - TraceEvent(grpc_slice data, grpc_error* error, - grpc_connectivity_state connectivity_state); + TraceEvent(grpc_slice data); ~TraceEvent(); @@ -95,9 +87,7 @@ class ChannelTrace : public RefCounted { private: grpc_slice data_; - grpc_error* error_; gpr_timespec timestamp_; - grpc_connectivity_state connectivity_state_; TraceEvent* next_; // the tracer object for the (sub)channel that this trace event refers to. RefCountedPtr referenced_tracer_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index dca583abbe1..463e6121d0d 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -184,8 +184,7 @@ grpc_channel* grpc_channel_create_with_builder( channel->tracer = grpc_core::MakeRefCounted( channel_tracer_max_nodes); channel->tracer->AddTraceEvent( - grpc_slice_from_static_string("Channel created"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE); + grpc_slice_from_static_string("Channel created")); return channel; } diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index beb823eacf3..c85fb1cdba6 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -142,8 +142,9 @@ TEST_P(ChannelTracerTest, ComplexTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + tracer->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); AddSimpleTrace(sc1); @@ -158,8 +159,9 @@ TEST_P(ChannelTracerTest, ComplexTest) { ValidateChannelTrace(tracer, 5, GetParam()); ValidateTraceDataMatchedUuidLookup(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("LB channel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEventReferencingChannel( + grpc_slice_from_static_string("LB channel two created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc2); tracer->AddTraceEventReferencingSubchannel( grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); @@ -185,19 +187,22 @@ TEST_P(ChannelTracerTest, TestNesting) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + tracer->AddTraceEventReferencingChannel( + grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc1); AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. - sc1->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("connection one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, conn1); + sc1->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, conn1); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); - tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, + GRPC_CHANNEL_IDLE, sc2); // this trace should not get added to the parents children since it is already // present in the tracer. tracer->AddTraceEventReferencingChannel( diff --git a/test/cpp/client/channel_trace_proto_json_test.cc b/test/cpp/client/channel_trace_proto_json_test.cc index 98cf6762365..9fbd7b1bf30 100644 --- a/test/cpp/client/channel_trace_proto_json_test.cc +++ b/test/cpp/client/channel_trace_proto_json_test.cc @@ -38,9 +38,7 @@ using grpc_core::RefCountedPtr; namespace { void AddSimpleTrace(RefCountedPtr tracer) { - tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY); + tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace")); } } // namespace @@ -51,28 +49,35 @@ TEST(ChannelTraceTest, ProtoJsonTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(10); - tracer->AddTraceEventReferencingSubchannel(grpc_slice_from_static_string("subchannel one created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); + tracer->AddTraceEventReferencingSubchannel( + grpc_slice_from_static_string("subchannel one created"), sc1); AddSimpleTrace(sc1); AddSimpleTrace(sc1); AddSimpleTrace(sc1); RefCountedPtr sc2 = MakeRefCounted(10); - tracer->AddTraceEventReferencingChannel(grpc_slice_from_static_string("LB channel two created"), - GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc2); + tracer->AddTraceEventReferencingChannel( + grpc_slice_from_static_string("LB channel two created"), sc2); tracer->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); + grpc_slice_from_static_string("subchannel one inactive"), sc1); std::string tracer_json_str = tracer->RenderTrace(); - gpr_log(GPR_ERROR, "%s", tracer_json_str.c_str()); grpc::channelz::ChannelTrace channel_trace; google::protobuf::util::JsonParseOptions options; - options.ignore_unknown_fields = true; + // If the following line is failing, then uncomment the last line of the + // comment, and uncomment the lines that print the two strings. You can + // then compare the output, and determine what fields are missing. + // + // options.ignore_unknown_fields = true; ASSERT_EQ(google::protobuf::util::JsonStringToMessage( tracer_json_str, &channel_trace, options), google::protobuf::util::Status::OK); std::string proto_json_str; - ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, &proto_json_str), google::protobuf::util::Status::OK); - gpr_log(GPR_ERROR, "%s", proto_json_str.c_str()); + ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, + &proto_json_str), + google::protobuf::util::Status::OK); + // uncomment these to compare the the json strings. + // gpr_log(GPR_ERROR, "tracer json: %s", tracer_json_str.c_str()); + // gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str()); + ASSERT_EQ(tracer_json_str, proto_json_str); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr); From 97a3dbeb36c0f444b2e0d510bf43551bb546e1b6 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 7 Mar 2018 00:00:14 -0800 Subject: [PATCH 54/67] Move C++ to util, call it from core test --- CMakeLists.txt | 48 +------------- Makefile | 63 +++---------------- build.yaml | 17 +---- grpc.gyp | 1 + src/proto/grpc/channelz/BUILD | 2 + test/core/channel/BUILD | 1 + test/core/channel/channel_trace_test.cc | 40 +++++------- test/cpp/client/BUILD | 13 ---- test/cpp/util/BUILD | 18 ++++++ .../channel_trace_proto_helper.cc} | 46 +------------- test/cpp/util/channel_trace_proto_helper.h | 30 +++++++++ .../generated/sources_and_headers.json | 27 ++------ tools/run_tests/generated/tests.json | 24 ------- 13 files changed, 85 insertions(+), 245 deletions(-) rename test/cpp/{client/channel_trace_proto_json_test.cc => util/channel_trace_proto_helper.cc} (57%) create mode 100644 test/cpp/util/channel_trace_proto_helper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f6426932ec4..6f822475d67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -517,7 +517,6 @@ add_dependencies(buildtests_cxx bm_pollset) endif() add_dependencies(buildtests_cxx channel_arguments_test) add_dependencies(buildtests_cxx channel_filter_test) -add_dependencies(buildtests_cxx channel_trace_proto_json_test) add_dependencies(buildtests_cxx channel_trace_test) add_dependencies(buildtests_cxx chttp2_settings_timeout_test) add_dependencies(buildtests_cxx cli_call_test) @@ -3521,6 +3520,7 @@ add_library(grpc++_test_util ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h test/cpp/end2end/test_service_impl.cc test/cpp/util/byte_buffer_proto_helper.cc + test/cpp/util/channel_trace_proto_helper.cc test/cpp/util/create_test_channel.cc test/cpp/util/string_ref_helper.cc test/cpp/util/subprocess.cc @@ -9484,51 +9484,6 @@ target_link_libraries(channel_filter_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(channel_trace_proto_json_test - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h - test/cpp/client/channel_trace_proto_json_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - -protobuf_generate_grpc_cpp( - src/proto/grpc/channelz/channelz.proto -) - -target_include_directories(channel_trace_proto_json_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(channel_trace_proto_json_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_test_util - grpc_test_util - grpc++ - grpc - gpr_test_util - gpr - ${_gRPC_GFLAGS_LIBRARIES} -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(channel_trace_test test/core/channel/channel_trace_test.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc @@ -9563,6 +9518,7 @@ target_link_libraries(channel_trace_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_test_util + grpc++_test_util grpc++ grpc gpr_test_util diff --git a/Makefile b/Makefile index 3dc9729752a..7b73a301311 100644 --- a/Makefile +++ b/Makefile @@ -1114,7 +1114,6 @@ bm_metadata: $(BINDIR)/$(CONFIG)/bm_metadata bm_pollset: $(BINDIR)/$(CONFIG)/bm_pollset channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test channel_filter_test: $(BINDIR)/$(CONFIG)/channel_filter_test -channel_trace_proto_json_test: $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test channel_trace_test: $(BINDIR)/$(CONFIG)/channel_trace_test chttp2_settings_timeout_test: $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test @@ -1584,7 +1583,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test \ $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ @@ -1734,7 +1732,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/bm_pollset \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/channel_filter_test \ - $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test \ $(BINDIR)/$(CONFIG)/channel_trace_test \ $(BINDIR)/$(CONFIG)/chttp2_settings_timeout_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ @@ -2132,8 +2129,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing channel_filter_test" $(Q) $(BINDIR)/$(CONFIG)/channel_filter_test || ( echo test channel_filter_test failed ; exit 1 ) - $(E) "[RUN] Testing channel_trace_proto_json_test" - $(Q) $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test || ( echo test channel_trace_proto_json_test failed ; exit 1 ) $(E) "[RUN] Testing channel_trace_test" $(Q) $(BINDIR)/$(CONFIG)/channel_trace_test || ( echo test channel_trace_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_settings_timeout_test" @@ -5766,6 +5761,7 @@ LIBGRPC++_TEST_UTIL_SRC = \ $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc \ test/cpp/end2end/test_service_impl.cc \ test/cpp/util/byte_buffer_proto_helper.cc \ + test/cpp/util/channel_trace_proto_helper.cc \ test/cpp/util/create_test_channel.cc \ test/cpp/util/string_ref_helper.cc \ test/cpp/util/subprocess.cc \ @@ -5903,6 +5899,7 @@ endif endif $(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/channel_trace_proto_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc @@ -15153,53 +15150,6 @@ endif endif -CHANNEL_TRACE_PROTO_JSON_TEST_SRC = \ - $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ - test/cpp/client/channel_trace_proto_json_test.cc \ - -CHANNEL_TRACE_PROTO_JSON_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CHANNEL_TRACE_PROTO_JSON_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/channel_trace_proto_json_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. - -$(BINDIR)/$(CONFIG)/channel_trace_proto_json_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/channel_trace_proto_json_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_proto_json_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -$(OBJDIR)/$(CONFIG)/test/cpp/client/channel_trace_proto_json_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_channel_trace_proto_json_test: $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(CHANNEL_TRACE_PROTO_JSON_TEST_OBJS:.o=.dep) -endif -endif -$(OBJDIR)/$(CONFIG)/test/cpp/client/channel_trace_proto_json_test.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc - - CHANNEL_TRACE_TEST_SRC = \ test/core/channel/channel_trace_test.cc \ $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ @@ -15224,18 +15174,18 @@ $(BINDIR)/$(CONFIG)/channel_trace_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/channel_trace_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/channel_trace_test: $(PROTOBUF_DEP) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_test + $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_TRACE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/channel_trace_test endif endif -$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/core/channel/channel_trace_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a -$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/src/proto/grpc/channelz/channelz.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_channel_trace_test: $(CHANNEL_TRACE_TEST_OBJS:.o=.dep) @@ -22608,6 +22558,7 @@ test/cpp/qps/server_async.cc: $(OPENSSL_DEP) test/cpp/qps/server_sync.cc: $(OPENSSL_DEP) test/cpp/qps/usage_timer.cc: $(OPENSSL_DEP) test/cpp/util/byte_buffer_proto_helper.cc: $(OPENSSL_DEP) +test/cpp/util/channel_trace_proto_helper.cc: $(OPENSSL_DEP) test/cpp/util/cli_call.cc: $(OPENSSL_DEP) test/cpp/util/cli_credentials.cc: $(OPENSSL_DEP) test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index 08fb17e7e0e..ea0f97f31a2 100644 --- a/build.yaml +++ b/build.yaml @@ -1514,6 +1514,7 @@ libs: headers: - test/cpp/end2end/test_service_impl.h - test/cpp/util/byte_buffer_proto_helper.h + - test/cpp/util/channel_trace_proto_helper.h - test/cpp/util/create_test_channel.h - test/cpp/util/string_ref_helper.h - test/cpp/util/subprocess.h @@ -1525,6 +1526,7 @@ libs: - src/proto/grpc/testing/duplicate/echo_duplicate.proto - test/cpp/end2end/test_service_impl.cc - test/cpp/util/byte_buffer_proto_helper.cc + - test/cpp/util/channel_trace_proto_helper.cc - test/cpp/util/create_test_channel.cc - test/cpp/util/string_ref_helper.cc - test/cpp/util/subprocess.cc @@ -3887,20 +3889,6 @@ targets: - grpc - gpr uses_polling: false -- name: channel_trace_proto_json_test - gtest: true - build: test - language: c++ - src: - - src/proto/grpc/channelz/channelz.proto - - test/cpp/client/channel_trace_proto_json_test.cc - deps: - - grpc++_test_util - - grpc_test_util - - grpc++ - - grpc - - gpr_test_util - - gpr - name: channel_trace_test gtest: true build: test @@ -3909,6 +3897,7 @@ targets: - test/core/channel/channel_trace_test.cc deps: - grpc_test_util + - grpc++_test_util - grpc++ - grpc - gpr_test_util diff --git a/grpc.gyp b/grpc.gyp index 3036b462e0e..16dd3b0be8d 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1313,6 +1313,7 @@ 'src/proto/grpc/testing/duplicate/echo_duplicate.proto', 'test/cpp/end2end/test_service_impl.cc', 'test/cpp/util/byte_buffer_proto_helper.cc', + 'test/cpp/util/channel_trace_proto_helper.cc', 'test/cpp/util/create_test_channel.cc', 'test/cpp/util/string_ref_helper.cc', 'test/cpp/util/subprocess.cc', diff --git a/src/proto/grpc/channelz/BUILD b/src/proto/grpc/channelz/BUILD index 9318e5ccdec..bdb03d5e2d0 100644 --- a/src/proto/grpc/channelz/BUILD +++ b/src/proto/grpc/channelz/BUILD @@ -21,4 +21,6 @@ grpc_package(name = "channelz", visibility = "public") grpc_proto_library( name = "channelz_proto", srcs = ["channelz.proto"], + has_services = True, + well_known_protos = True, ) diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index e1388c6e1ac..6bf4fcdbb8e 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -76,6 +76,7 @@ grpc_cc_test( "//:grpc++", "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", + "//test/cpp/util:channel_trace_proto_helper", ], external_deps = [ "gtest", diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index c85fb1cdba6..0c858005ca1 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -31,6 +31,7 @@ #include "src/core/lib/json/json.h" #include "test/core/util/test_config.h" +#include "test/cpp/util/channel_trace_proto_helper.h" namespace grpc_core { namespace testing { @@ -61,9 +62,9 @@ void ValidateChannelTraceData(grpc_json* json, size_t num_events_logged_expected, size_t actual_num_events_expected) { ASSERT_NE(json, nullptr); - grpc_json* num_events_logged_json = GetJsonChild(json, "num_events_logged"); + grpc_json* num_events_logged_json = GetJsonChild(json, "numEventsLogged"); ASSERT_NE(num_events_logged_json, nullptr); - grpc_json* start_time = GetJsonChild(json, "creation_time"); + grpc_json* start_time = GetJsonChild(json, "creationTime"); ASSERT_NE(start_time, nullptr); size_t num_events_logged = (size_t)strtol(num_events_logged_json->value, nullptr, 0); @@ -72,9 +73,7 @@ void ValidateChannelTraceData(grpc_json* json, } void AddSimpleTrace(RefCountedPtr tracer) { - tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace"), - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_CHANNEL_READY); + tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace")); } // checks for the existence of all the required members of the tracer. @@ -82,6 +81,7 @@ void ValidateChannelTrace(RefCountedPtr tracer, size_t expected_num_event_logged, size_t max_nodes) { if (!max_nodes) return; char* json_str = tracer->RenderTrace(); + grpc::testing::ValidateChannelTraceProtoJsonTranslation(json_str); grpc_json* json = grpc_json_parse_string(json_str); ValidateChannelTraceData(json, expected_num_event_logged, GPR_MIN(expected_num_event_logged, max_nodes)); @@ -113,13 +113,8 @@ TEST_P(ChannelTracerTest, BasicTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); ValidateTraceDataMatchedUuidLookup(tracer); - tracer->AddTraceEvent( - grpc_slice_from_static_string("trace three"), - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), - GRPC_ERROR_INT_HTTP2_ERROR, 2), - GRPC_CHANNEL_IDLE); - tracer->AddTraceEvent(grpc_slice_from_static_string("trace four"), - GRPC_ERROR_NONE, GRPC_CHANNEL_SHUTDOWN); + tracer->AddTraceEvent(grpc_slice_from_static_string("trace three")); + tracer->AddTraceEvent(grpc_slice_from_static_string("trace four")); ValidateChannelTrace(tracer, 4, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); @@ -143,8 +138,7 @@ TEST_P(ChannelTracerTest, ComplexTest) { AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); + grpc_slice_from_static_string("subchannel one created"), sc1); ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); AddSimpleTrace(sc1); @@ -160,11 +154,9 @@ TEST_P(ChannelTracerTest, ComplexTest) { ValidateTraceDataMatchedUuidLookup(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingChannel( - grpc_slice_from_static_string("LB channel two created"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc2); + grpc_slice_from_static_string("LB channel two created"), sc2); tracer->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); + grpc_slice_from_static_string("subchannel one inactive"), sc1); ValidateChannelTrace(tracer, 7, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); @@ -188,26 +180,22 @@ TEST_P(ChannelTracerTest, TestNesting) { AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingChannel( - grpc_slice_from_static_string("subchannel one created"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); + grpc_slice_from_static_string("subchannel one created"), sc1); AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. sc1->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("connection one created"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, conn1); + grpc_slice_from_static_string("connection one created"), conn1); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("subchannel two created"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc2); + grpc_slice_from_static_string("subchannel two created"), sc2); // this trace should not get added to the parents children since it is already // present in the tracer. tracer->AddTraceEventReferencingChannel( - grpc_slice_from_static_string("subchannel one inactive"), GRPC_ERROR_NONE, - GRPC_CHANNEL_IDLE, sc1); + grpc_slice_from_static_string("subchannel one inactive"), sc1); AddSimpleTrace(tracer); tracer.reset(nullptr); sc1.reset(nullptr); diff --git a/test/cpp/client/BUILD b/test/cpp/client/BUILD index 3cbd63a99e4..12825e88c26 100644 --- a/test/cpp/client/BUILD +++ b/test/cpp/client/BUILD @@ -18,19 +18,6 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_p grpc_package(name = "test/cpp/client") -grpc_cc_test( - name = "channel_trace_proto_json_test", - srcs = ["channel_trace_proto_json_test.cc"], - external_deps = [ - "gtest", - ], - deps = [ - "//:gpr", - "//:grpc", - "//:grpc++", - ], -) - grpc_cc_test( name = "credentials_test", srcs = ["credentials_test.cc"], diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index d092ba348ef..c6a0ea2580b 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -81,6 +81,24 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "channel_trace_proto_helper", + srcs = [ + "channel_trace_proto_helper.cc", + ], + hdrs = [ + "channel_trace_proto_helper.h", + ], + deps = [ + "//:grpc++", + "//src/proto/grpc/channelz:channelz_proto", + ], + external_deps = [ + "gtest", + "protobuf", + ], +) + grpc_cc_library( name = "test_util_unsecure", srcs = GRPCXX_TESTUTIL_SRCS, diff --git a/test/cpp/client/channel_trace_proto_json_test.cc b/test/cpp/util/channel_trace_proto_helper.cc similarity index 57% rename from test/cpp/client/channel_trace_proto_json_test.cc rename to test/cpp/util/channel_trace_proto_helper.cc index 9fbd7b1bf30..be00dd1424f 100644 --- a/test/cpp/client/channel_trace_proto_json_test.cc +++ b/test/cpp/util/channel_trace_proto_helper.cc @@ -16,7 +16,7 @@ * */ -#include +#include "test/cpp/util/channel_trace_proto_helper.h" #include #include @@ -24,42 +24,13 @@ #include #include -#include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/proto/grpc/channelz/channelz.pb.h" namespace grpc { namespace testing { -using grpc_core::ChannelTrace; -using grpc_core::MakeRefCounted; -using grpc_core::RefCountedPtr; - -namespace { - -void AddSimpleTrace(RefCountedPtr tracer) { - tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace")); -} - -} // namespace - -TEST(ChannelTraceTest, ProtoJsonTest) { - grpc_core::ExecCtx exec_ctx; - RefCountedPtr tracer = MakeRefCounted(10); - AddSimpleTrace(tracer); - AddSimpleTrace(tracer); - RefCountedPtr sc1 = MakeRefCounted(10); - tracer->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("subchannel one created"), sc1); - AddSimpleTrace(sc1); - AddSimpleTrace(sc1); - AddSimpleTrace(sc1); - RefCountedPtr sc2 = MakeRefCounted(10); - tracer->AddTraceEventReferencingChannel( - grpc_slice_from_static_string("LB channel two created"), sc2); - tracer->AddTraceEventReferencingSubchannel( - grpc_slice_from_static_string("subchannel one inactive"), sc1); - std::string tracer_json_str = tracer->RenderTrace(); +void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str) { + std::string tracer_json_str(tracer_json_c_str); grpc::channelz::ChannelTrace channel_trace; google::protobuf::util::JsonParseOptions options; // If the following line is failing, then uncomment the last line of the @@ -78,18 +49,7 @@ TEST(ChannelTraceTest, ProtoJsonTest) { // gpr_log(GPR_ERROR, "tracer json: %s", tracer_json_str.c_str()); // gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str()); ASSERT_EQ(tracer_json_str, proto_json_str); - tracer.reset(nullptr); - sc1.reset(nullptr); - sc2.reset(nullptr); } } // namespace testing } // namespace grpc - -int main(int argc, char** argv) { - grpc_init(); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - grpc_shutdown(); - return ret; -} diff --git a/test/cpp/util/channel_trace_proto_helper.h b/test/cpp/util/channel_trace_proto_helper.h new file mode 100644 index 00000000000..d7043d9f063 --- /dev/null +++ b/test/cpp/util/channel_trace_proto_helper.h @@ -0,0 +1,30 @@ +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H +#define GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H + +namespace grpc { +namespace testing { + +void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str); + +} // namespace testing +} // namespace grpc + +#endif // GRPC_TEST_CPP_UTIL_CHANNEL_TRACE_PROTO_HELPER_H diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index baf9be749b9..10e51c7d89f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -2825,29 +2825,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc", - "grpc++", - "grpc++_test_util", - "grpc_test_util" - ], - "headers": [ - "src/proto/grpc/channelz/channelz.grpc.pb.h", - "src/proto/grpc/channelz/channelz.pb.h", - "src/proto/grpc/channelz/channelz_mock.grpc.pb.h" - ], - "is_filegroup": false, - "language": "c++", - "name": "channel_trace_proto_json_test", - "src": [ - "test/cpp/client/channel_trace_proto_json_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -2856,6 +2833,7 @@ "grpc++", "grpc++_channelz_proto", "grpc++_test", + "grpc++_test_util", "grpc_test_util" ], "headers": [], @@ -6730,6 +6708,7 @@ "src/proto/grpc/testing/echo_mock.grpc.pb.h", "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.h", + "test/cpp/util/channel_trace_proto_helper.h", "test/cpp/util/create_test_channel.h", "test/cpp/util/string_ref_helper.h", "test/cpp/util/subprocess.h", @@ -6743,6 +6722,8 @@ "test/cpp/end2end/test_service_impl.h", "test/cpp/util/byte_buffer_proto_helper.cc", "test/cpp/util/byte_buffer_proto_helper.h", + "test/cpp/util/channel_trace_proto_helper.cc", + "test/cpp/util/channel_trace_proto_helper.h", "test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.h", "test/cpp/util/string_ref_helper.cc", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 48ea61061f9..cae60dd29a0 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3337,30 +3337,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": true, - "language": "c++", - "name": "channel_trace_proto_json_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": true - }, { "args": [], "benchmark": false, From bec1a61c26625364825dae396cc02a49926668c7 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 7 Mar 2018 00:04:21 -0800 Subject: [PATCH 55/67] Reviewer feedback --- src/core/ext/filters/client_channel/subchannel.cc | 3 --- test/core/util/BUILD | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 4802110e5a2..8be89806619 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -37,7 +37,6 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_trace.h" -#include "src/core/lib/channel/channel_trace_registry.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" @@ -135,8 +134,6 @@ struct grpc_subchannel { bool backoff_begun; /** our alarm */ grpc_timer alarm; - - grpc_core::RefCountedPtr tracer; }; struct grpc_subchannel_call { diff --git a/test/core/util/BUILD b/test/core/util/BUILD index c3458db45a5..886cfddf865 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -103,8 +103,6 @@ grpc_cc_library( ], ) - - grpc_cc_library( name = "grpc_test_util_unsecure", srcs = [], From 09703ea30089464820dd56a07711f81a2d1e0f3c Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 7 Mar 2018 00:34:37 -0800 Subject: [PATCH 56/67] Add severity --- src/core/lib/channel/channel_trace.cc | 38 +++++++++++++-------- src/core/lib/channel/channel_trace.h | 22 +++++++++--- src/core/lib/surface/channel.cc | 1 + src/proto/grpc/channelz/channelz.proto | 2 +- test/core/channel/channel_trace_test.cc | 16 +++++++-- test/cpp/util/channel_trace_proto_helper.cc | 5 +-- 6 files changed, 58 insertions(+), 26 deletions(-) diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index bbbf59cdf9c..e0f495284f5 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -41,17 +41,19 @@ namespace grpc_core { ChannelTrace::TraceEvent::TraceEvent( - grpc_slice data, RefCountedPtr referenced_tracer, - ReferencedType type) - : data_(data), + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer, ReferencedType type) + : severity_(severity), + data_(data), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), next_(nullptr), referenced_tracer_(std::move(referenced_tracer)), referenced_type_(type) {} -ChannelTrace::TraceEvent::TraceEvent(grpc_slice data) - : data_(data), +ChannelTrace::TraceEvent::TraceEvent(Severity severity, grpc_slice data) + : severity_(severity), + data_(data), timestamp_(grpc_millis_to_timespec(grpc_core::ExecCtx::Get()->Now(), GPR_CLOCK_REALTIME)), next_(nullptr) {} @@ -107,25 +109,27 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { } } -void ChannelTrace::AddTraceEventReferencingChannel( - grpc_slice data, RefCountedPtr referenced_tracer) { +void ChannelTrace::AddTraceEvent(Severity severity, grpc_slice data) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - // create and fill up the new event - AddTraceEventHelper( - New(data, std::move(referenced_tracer), Channel)); + AddTraceEventHelper(New(severity, data)); } -void ChannelTrace::AddTraceEventReferencingSubchannel( - grpc_slice data, RefCountedPtr referenced_tracer) { +void ChannelTrace::AddTraceEventReferencingChannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 // create and fill up the new event AddTraceEventHelper( - New(data, std::move(referenced_tracer), Subchannel)); + New(severity, data, std::move(referenced_tracer), Channel)); } -void ChannelTrace::AddTraceEvent(grpc_slice data) { +void ChannelTrace::AddTraceEventReferencingSubchannel( + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer) { if (max_list_size_ == 0) return; // tracing is disabled if max_events == 0 - AddTraceEventHelper(New(data)); + // create and fill up the new event + AddTraceEventHelper(New( + severity, data, std::move(referenced_tracer), Subchannel)); } namespace { @@ -147,6 +151,10 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), GRPC_JSON_STRING, true); + char* trace_level_str; + gpr_asprintf(&trace_level_str, "%d", static_cast(severity_)); + json_iterator = grpc_json_create_child( + json_iterator, json, "severity", trace_level_str, GRPC_JSON_NUMBER, true); json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", fmt_time(timestamp_), GRPC_JSON_STRING, true); diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index 0c46ede600f..7243096617e 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -40,8 +40,15 @@ class ChannelTrace : public RefCounted { // returns the tracer's uuid intptr_t GetUuid() const; + enum Severity { + Unset = 0, // never to be used + Info, // we start at 1 to avoid using proto default values + Warning, + Error + }; + // Adds a new trace event to the tracing object - void AddTraceEvent(grpc_slice data); + void AddTraceEvent(Severity severity, grpc_slice data); // Adds a new trace event to the tracing object. This trace event refers to a // an event on a child of the channel. For example, if this channel has @@ -51,15 +58,18 @@ class ChannelTrace : public RefCounted { // TODO(ncteisen): Once channelz is implemented, the events should reference // the overall channelz object, not just the ChannelTrace object. void AddTraceEventReferencingChannel( - grpc_slice data, RefCountedPtr referenced_tracer); + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer); void AddTraceEventReferencingSubchannel( - grpc_slice data, RefCountedPtr referenced_tracer); + Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer); // Returns the tracing data rendered as a grpc json string. // The string is owned by the caller and must be freed. char* RenderTrace() const; private: + // Types of objects that can be references by trace events. enum ReferencedType { Channel, Subchannel }; // Private class to encapsulate all the data and bookkeeping needed for a // a trace event. @@ -68,12 +78,13 @@ class ChannelTrace : public RefCounted { // Constructor for a TraceEvent that references a different channel. // TODO(ncteisen): once channelz is implemented, this should reference the // overall channelz object, not just the ChannelTrace object - TraceEvent(grpc_slice data, RefCountedPtr referenced_tracer, + TraceEvent(Severity severity, grpc_slice data, + RefCountedPtr referenced_tracer, ReferencedType type); // Constructor for a TraceEvent that does not reverence a different // channel. - TraceEvent(grpc_slice data); + TraceEvent(Severity severity, grpc_slice data); ~TraceEvent(); @@ -86,6 +97,7 @@ class ChannelTrace : public RefCounted { void set_next(TraceEvent* next) { next_ = next; } private: + Severity severity_; grpc_slice data_; gpr_timespec timestamp_; TraceEvent* next_; diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 463e6121d0d..cecc15b2dfe 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -184,6 +184,7 @@ grpc_channel* grpc_channel_create_with_builder( channel->tracer = grpc_core::MakeRefCounted( channel_tracer_max_nodes); channel->tracer->AddTraceEvent( + grpc_core::ChannelTrace::Severity::Info, grpc_slice_from_static_string("Channel created")); return channel; } diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto index 532ec7978ff..851f301536b 100644 --- a/src/proto/grpc/channelz/channelz.proto +++ b/src/proto/grpc/channelz/channelz.proto @@ -98,7 +98,7 @@ message ChannelTraceEvent { // the severity of the trace event. Options are INFO, WARNING, and ERROR, // which are represented by the values 1, 2, and 3, respectively. Any other // value will be treated as ERROR. - int32 trace_level = 2; + int32 severity = 2; // When this event occurred. google.protobuf.Timestamp timestamp = 3; // ref of referenced channel or subchannel. diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 0c858005ca1..471ebd6b580 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -73,7 +73,8 @@ void ValidateChannelTraceData(grpc_json* json, } void AddSimpleTrace(RefCountedPtr tracer) { - tracer->AddTraceEvent(grpc_slice_from_static_string("simple trace")); + tracer->AddTraceEvent(ChannelTrace::Severity::Info, + grpc_slice_from_static_string("simple trace")); } // checks for the existence of all the required members of the tracer. @@ -113,8 +114,10 @@ TEST_P(ChannelTracerTest, BasicTest) { AddSimpleTrace(tracer); AddSimpleTrace(tracer); ValidateTraceDataMatchedUuidLookup(tracer); - tracer->AddTraceEvent(grpc_slice_from_static_string("trace three")); - tracer->AddTraceEvent(grpc_slice_from_static_string("trace four")); + tracer->AddTraceEvent(ChannelTrace::Severity::Info, + grpc_slice_from_static_string("trace three")); + tracer->AddTraceEvent(ChannelTrace::Severity::Error, + grpc_slice_from_static_string("trace four error")); ValidateChannelTrace(tracer, 4, GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); @@ -138,6 +141,7 @@ TEST_P(ChannelTracerTest, ComplexTest) { AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel one created"), sc1); ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); @@ -154,8 +158,10 @@ TEST_P(ChannelTracerTest, ComplexTest) { ValidateTraceDataMatchedUuidLookup(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("LB channel two created"), sc2); tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Warning, grpc_slice_from_static_string("subchannel one inactive"), sc1); ValidateChannelTrace(tracer, 7, GetParam()); AddSimpleTrace(tracer); @@ -180,21 +186,25 @@ TEST_P(ChannelTracerTest, TestNesting) { AddSimpleTrace(tracer); RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel one created"), sc1); AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. sc1->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("connection one created"), conn1); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingSubchannel( + ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel two created"), sc2); // this trace should not get added to the parents children since it is already // present in the tracer. tracer->AddTraceEventReferencingChannel( + ChannelTrace::Severity::Warning, grpc_slice_from_static_string("subchannel one inactive"), sc1); AddSimpleTrace(tracer); tracer.reset(nullptr); diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc index be00dd1424f..fbc9f1501c4 100644 --- a/test/cpp/util/channel_trace_proto_helper.cc +++ b/test/cpp/util/channel_trace_proto_helper.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include "src/proto/grpc/channelz/channelz.pb.h" @@ -32,14 +33,14 @@ namespace testing { void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str) { std::string tracer_json_str(tracer_json_c_str); grpc::channelz::ChannelTrace channel_trace; - google::protobuf::util::JsonParseOptions options; + google::protobuf::util::JsonParseOptions parse_options; // If the following line is failing, then uncomment the last line of the // comment, and uncomment the lines that print the two strings. You can // then compare the output, and determine what fields are missing. // // options.ignore_unknown_fields = true; ASSERT_EQ(google::protobuf::util::JsonStringToMessage( - tracer_json_str, &channel_trace, options), + tracer_json_str, &channel_trace, parse_options), google::protobuf::util::Status::OK); std::string proto_json_str; ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace, From 36e02bff2b5287e65ce92a8fd0d9a2b818462f5b Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 7 Mar 2018 00:37:36 -0800 Subject: [PATCH 57/67] Fix sanity --- CMakeLists.txt | 7 +++++++ Makefile | 17 +++++++++-------- build.yaml | 1 + grpc.gyp | 1 + src/core/lib/channel/status_util.h | 6 +++--- src/proto/grpc/channelz/channelz.proto | 14 ++++++++++++++ .../generated/sources_and_headers.json | 3 +++ 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f822475d67..f1701972a16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3501,6 +3501,10 @@ if (gRPC_BUILD_TESTS) if (gRPC_BUILD_CODEGEN) add_library(grpc++_test_util + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/health/v1/health.pb.h @@ -3539,6 +3543,9 @@ if(WIN32 AND MSVC) endif() endif() +protobuf_generate_grpc_cpp( + src/proto/grpc/channelz/channelz.proto +) protobuf_generate_grpc_cpp( src/proto/grpc/health/v1/health.proto ) diff --git a/Makefile b/Makefile index 7b73a301311..94da367e09e 100644 --- a/Makefile +++ b/Makefile @@ -5755,6 +5755,7 @@ endif LIBGRPC++_TEST_UTIL_SRC = \ + $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc \ @@ -5897,14 +5898,14 @@ ifneq ($(NO_DEPS),true) -include $(LIBGRPC++_TEST_UTIL_OBJS:.o=.dep) endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/channel_trace_proto_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/byte_buffer_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/channel_trace_proto_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/create_test_channel.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/string_ref_helper.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/subprocess.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/test_credentials_provider.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/src/cpp/codegen/codegen_init.o: $(GENDIR)/src/proto/grpc/channelz/channelz.pb.cc $(GENDIR)/src/proto/grpc/channelz/channelz.grpc.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc LIBGRPC++_TEST_UTIL_UNSECURE_SRC = \ diff --git a/build.yaml b/build.yaml index ea0f97f31a2..25f706475e9 100644 --- a/build.yaml +++ b/build.yaml @@ -1520,6 +1520,7 @@ libs: - test/cpp/util/subprocess.h - test/cpp/util/test_credentials_provider.h src: + - src/proto/grpc/channelz/channelz.proto - src/proto/grpc/health/v1/health.proto - src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/echo.proto diff --git a/grpc.gyp b/grpc.gyp index 16dd3b0be8d..708c2a5294c 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1307,6 +1307,7 @@ 'grpc', ], 'sources': [ + 'src/proto/grpc/channelz/channelz.proto', 'src/proto/grpc/health/v1/health.proto', 'src/proto/grpc/testing/echo_messages.proto', 'src/proto/grpc/testing/echo.proto', diff --git a/src/core/lib/channel/status_util.h b/src/core/lib/channel/status_util.h index 2c552fa20a6..5409de6b3c9 100644 --- a/src/core/lib/channel/status_util.h +++ b/src/core/lib/channel/status_util.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_LIB_CHANNEL_STATUS_UTILS_H -#define GRPC_LIB_CHANNEL_STATUS_UTILS_H +#ifndef GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H +#define GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H #include @@ -55,4 +55,4 @@ class StatusCodeSet { } // namespace internal } // namespace grpc_core -#endif /* GRPC_LIB_CHANNEL_STATUS_UTILS_H */ +#endif /* GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H */ diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto index 851f301536b..f0f17e39e45 100644 --- a/src/proto/grpc/channelz/channelz.proto +++ b/src/proto/grpc/channelz/channelz.proto @@ -1,3 +1,17 @@ +// Copyright 2018 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + syntax = "proto3"; package grpc.channelz; diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 10e51c7d89f..6292b609f62 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -6694,6 +6694,9 @@ "grpc_test_util" ], "headers": [ + "src/proto/grpc/channelz/channelz.grpc.pb.h", + "src/proto/grpc/channelz/channelz.pb.h", + "src/proto/grpc/channelz/channelz_mock.grpc.pb.h", "src/proto/grpc/health/v1/health.grpc.pb.h", "src/proto/grpc/health/v1/health.pb.h", "src/proto/grpc/health/v1/health_mock.grpc.pb.h", From d2365d615aa0b8c18d88997ff26ae145844a4d4e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 7 Mar 2018 10:14:22 -0800 Subject: [PATCH 58/67] Reviewer comments --- .../ext/filters/client_channel/subchannel.cc | 2 - src/core/lib/channel/channel_trace.cc | 50 ++++++++++++++++--- src/proto/grpc/channelz/channelz.proto | 13 +++-- test/core/channel/channel_trace_test.cc | 5 ++ 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 8be89806619..4c77c8602a1 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -35,8 +35,6 @@ #include "src/core/ext/filters/client_channel/subchannel_index.h" #include "src/core/ext/filters/client_channel/uri_parser.h" #include "src/core/lib/backoff/backoff.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_trace.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index e0f495284f5..6d85db936d1 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -134,16 +134,51 @@ void ChannelTrace::AddTraceEventReferencingSubchannel( namespace { -// returns an allocated string that represents tm according to RFC-3339. +// returns an allocated string that represents tm according to RFC-3339, and, +// more specifically, follows: +// https://developers.google.com/protocol-buffers/docs/proto3#json +// +// "Uses RFC 3339, where generated output will always be Z-normalized and uses +// 0, 3, 6 or 9 fractional digits." char* fmt_time(gpr_timespec tm) { - char buffer[35]; + char time_buffer[35]; + char ns_buffer[11]; // '.' + 9 digits of precision struct tm* tm_info = localtime((const time_t*)&tm.tv_sec); - strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S", tm_info); + strftime(time_buffer, sizeof(time_buffer), "%Y-%m-%dT%H:%M:%S", tm_info); + snprintf(ns_buffer, 11, ".%09d", tm.tv_nsec); + // This loop trims off trailing zeros by inserting a null character that the + // right point. We iterate in chunks of three because we want 0, 3, 6, or 9 + // fractional digits. + for (int i = 7; i >= 1; i -= 3) { + if (ns_buffer[i] == '0' && ns_buffer[i + 1] == '0' && + ns_buffer[i + 2] == '0') { + ns_buffer[i] = 0; + // Specially case in which all fractional digits were 0. + if (i == 1) { + ns_buffer[0] = 0; + } + } else { + break; + } + } char* full_time_str; - gpr_asprintf(&full_time_str, "%s.%09dZ", buffer, tm.tv_nsec); + gpr_asprintf(&full_time_str, "%s%sZ", time_buffer, ns_buffer); return full_time_str; } +const char* severity_string(ChannelTrace::Severity severity) { + switch (severity) { + case ChannelTrace::Severity::Info: + return "INFO"; + case ChannelTrace::Severity::Warning: + return "WARNING"; + case ChannelTrace::Severity::Error: + return "ERROR"; + default: + GPR_UNREACHABLE_CODE(return "UNKNOWN"); + } +} + } // anonymous namespace void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { @@ -151,10 +186,9 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const { json_iterator = grpc_json_create_child(json_iterator, json, "description", grpc_slice_to_c_string(data_), GRPC_JSON_STRING, true); - char* trace_level_str; - gpr_asprintf(&trace_level_str, "%d", static_cast(severity_)); - json_iterator = grpc_json_create_child( - json_iterator, json, "severity", trace_level_str, GRPC_JSON_NUMBER, true); + json_iterator = grpc_json_create_child(json_iterator, json, "severity", + severity_string(severity_), + GRPC_JSON_STRING, false); json_iterator = grpc_json_create_child(json_iterator, json, "timestamp", fmt_time(timestamp_), GRPC_JSON_STRING, true); diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto index f0f17e39e45..ea9636905df 100644 --- a/src/proto/grpc/channelz/channelz.proto +++ b/src/proto/grpc/channelz/channelz.proto @@ -109,10 +109,15 @@ message ChannelData { message ChannelTraceEvent { // High level description of the event. string description = 1; - // the severity of the trace event. Options are INFO, WARNING, and ERROR, - // which are represented by the values 1, 2, and 3, respectively. Any other - // value will be treated as ERROR. - int32 severity = 2; + // The supported severity levels of trace events. + enum Severity { + UNKNOWN = 0; + INFO = 1; + WARNING = 2; + ERROR = 3; + } + // the severity of the trace event + Severity severity = 2; // When this event occurred. google.protobuf.Timestamp timestamp = 3; // ref of referenced channel or subchannel. diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 471ebd6b580..0ba13ff1367 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -33,6 +33,11 @@ #include "test/core/util/test_config.h" #include "test/cpp/util/channel_trace_proto_helper.h" +// remove me +#include +#include +#include + namespace grpc_core { namespace testing { namespace { From c0cd82faedfdfc4af4931d008b07094c8911dfe5 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 14 Mar 2018 15:33:57 -0700 Subject: [PATCH 59/67] Remove unnecessary includes of exec_ctx.h --- src/core/ext/filters/client_channel/backup_poller.h | 1 - src/core/ext/filters/client_channel/lb_policy_factory.h | 1 - src/core/ext/filters/client_channel/lb_policy_registry.h | 1 - .../client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h | 1 - .../client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h | 1 - src/core/ext/filters/client_channel/uri_parser.h | 1 - src/core/ext/filters/deadline/deadline_filter.cc | 1 - .../transport/chttp2/client/insecure/channel_create_posix.cc | 1 - src/core/ext/transport/chttp2/server/chttp2_server.h | 2 +- src/core/ext/transport/chttp2/transport/frame_data.h | 1 - src/core/ext/transport/chttp2/transport/frame_goaway.h | 1 - src/core/ext/transport/chttp2/transport/frame_ping.h | 1 - src/core/ext/transport/chttp2/transport/frame_rst_stream.h | 1 - src/core/ext/transport/chttp2/transport/frame_settings.h | 1 - src/core/ext/transport/chttp2/transport/frame_window_update.h | 1 - src/core/ext/transport/chttp2/transport/hpack_parser.h | 1 - src/core/lib/channel/handshaker_factory.h | 1 - src/core/lib/channel/handshaker_registry.h | 1 - src/core/lib/compression/stream_compression_identity.cc | 1 - src/core/lib/iomgr/call_combiner.h | 1 - src/core/lib/iomgr/lockfree_event.h | 2 +- src/core/lib/iomgr/resolve_address.h | 1 - src/core/lib/iomgr/resource_quota.h | 2 +- src/core/lib/iomgr/socket_windows.h | 1 - src/core/lib/iomgr/timer_uv.h | 2 -- src/core/lib/security/transport/security_handshaker.h | 1 - src/core/lib/slice/slice_buffer.cc | 1 + src/core/lib/slice/slice_internal.h | 2 -- src/core/lib/surface/byte_buffer.cc | 1 + src/core/lib/surface/byte_buffer_reader.cc | 1 + src/core/lib/transport/byte_stream.h | 2 +- src/core/lib/transport/connectivity_state.h | 2 +- src/core/lib/transport/metadata.h | 2 +- src/core/lib/transport/metadata_batch.h | 1 + src/core/lib/transport/status_conversion.h | 1 + .../alts_grpc_record_protocol_common.cc | 1 + .../zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc | 1 + test/core/compression/algorithm_test.cc | 1 + test/core/end2end/connection_refused_test.cc | 1 + test/core/end2end/tests/cancel_after_accept.cc | 1 + test/core/end2end/tests/cancel_after_round_trip.cc | 1 + test/core/end2end/tests/max_message_length.cc | 1 + test/core/iomgr/resource_quota_test.cc | 1 + test/core/slice/slice_hash_table_test.cc | 1 + test/core/slice/slice_test.cc | 3 +++ test/core/slice/slice_weak_hash_table_test.cc | 1 + test/core/transport/byte_stream_test.cc | 1 + test/core/transport/chttp2/bin_decoder_test.cc | 1 + test/core/transport/chttp2/hpack_parser_fuzzer_test.cc | 1 + test/core/transport/chttp2/hpack_parser_test.cc | 2 ++ test/core/transport/chttp2/hpack_table_test.cc | 1 + test/core/transport/connectivity_state_test.cc | 1 + test/core/transport/metadata_test.cc | 1 + .../alts_grpc_record_protocol_test.cc | 1 + .../alts_zero_copy_grpc_protector_test.cc | 1 + 55 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h index 7285b9b93e7..8f132f968ce 100644 --- a/src/core/ext/filters/client_channel/backup_poller.h +++ b/src/core/ext/filters/client_channel/backup_poller.h @@ -23,7 +23,6 @@ #include #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/iomgr/exec_ctx.h" /* Start polling \a interested_parties periodically in the timer thread */ void grpc_client_channel_start_backup_polling( diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h index b8bbd320721..64402581589 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.h +++ b/src/core/ext/filters/client_channel/lb_policy_factory.h @@ -21,7 +21,6 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/ext/filters/client_channel/client_channel_factory.h" diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.h b/src/core/ext/filters/client_channel/lb_policy_registry.h index 2283d848bdd..2e9bb061ed6 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.h +++ b/src/core/ext/filters/client_channel/lb_policy_registry.h @@ -24,7 +24,6 @@ #include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/orphanable.h" -#include "src/core/lib/iomgr/exec_ctx.h" namespace grpc_core { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h index 0bc13e35f48..62395495342 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -22,7 +22,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset_set.h" typedef struct grpc_ares_ev_driver grpc_ares_ev_driver; diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index bda9cd17295..3e8ea01e120 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -22,7 +22,6 @@ #include #include "src/core/ext/filters/client_channel/lb_policy_factory.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/src/core/ext/filters/client_channel/uri_parser.h b/src/core/ext/filters/client_channel/uri_parser.h index 1966da932b0..d749f233083 100644 --- a/src/core/ext/filters/client_channel/uri_parser.h +++ b/src/core/ext/filters/client_channel/uri_parser.h @@ -22,7 +22,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" typedef struct { char* scheme; diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index dda3b61108b..27d3eac8d61 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -27,7 +27,6 @@ #include #include "src/core/lib/channel/channel_stack_builder.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/channel_init.h" diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc index 479f0da5726..b95c9dae532 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc @@ -29,7 +29,6 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/tcp_client_posix.h" #include "src/core/lib/iomgr/tcp_posix.h" #include "src/core/lib/surface/api_trace.h" diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index 7b419721606..6e51001b53b 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -23,7 +23,7 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/error.h" /// Adds a port to \a server. Sets \a port_num to the port number. /// Takes ownership of \a args. diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h index 4b0f8736448..e5d01f764e7 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/src/core/ext/transport/chttp2/transport/frame_data.h @@ -26,7 +26,6 @@ #include #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/transport.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h index e17ed8d5638..66c7a68befe 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -24,7 +24,6 @@ #include #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef enum { GRPC_CHTTP2_GOAWAY_LSI0, diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h index 8718d6a0978..55a4499ad59 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -23,7 +23,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef struct { uint8_t byte; diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index bb2d34f9183..6bcf9c44797 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -23,7 +23,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/transport.h" typedef struct { diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h index df196271941..8d8d9b1a914 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -24,7 +24,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef enum { GRPC_CHTTP2_SPS_ID0, diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h index 30667c77e17..3d2391f637d 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -23,7 +23,6 @@ #include #include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/transport.h" typedef struct { diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index b3b8018b987..3e05de4b925 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -25,7 +25,6 @@ #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/hpack_table.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/metadata.h" typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser; diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h index 9e36443958d..3e45fcf20e6 100644 --- a/src/core/lib/channel/handshaker_factory.h +++ b/src/core/lib/channel/handshaker_factory.h @@ -24,7 +24,6 @@ #include #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/iomgr/exec_ctx.h" // A handshaker factory is used to create handshakers. diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h index b42d61ff43b..82ad9c5b9af 100644 --- a/src/core/lib/channel/handshaker_registry.h +++ b/src/core/lib/channel/handshaker_registry.h @@ -24,7 +24,6 @@ #include #include "src/core/lib/channel/handshaker_factory.h" -#include "src/core/lib/iomgr/exec_ctx.h" typedef enum { HANDSHAKER_CLIENT = 0, diff --git a/src/core/lib/compression/stream_compression_identity.cc b/src/core/lib/compression/stream_compression_identity.cc index 52a6236621c..b7981394d5e 100644 --- a/src/core/lib/compression/stream_compression_identity.cc +++ b/src/core/lib/compression/stream_compression_identity.cc @@ -22,7 +22,6 @@ #include #include "src/core/lib/compression/stream_compression_identity.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #define OUTPUT_BLOCK_SIZE (1024) diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index 16829e57071..0ccd08ea577 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -27,7 +27,6 @@ #include "src/core/lib/gpr/mpscq.h" #include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/exec_ctx.h" // A simple, lock-free mechanism for serializing activity related to a // single call. This is similar to a combiner but is more lightweight. diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h index 83de656f5fc..b507b94648c 100644 --- a/src/core/lib/iomgr/lockfree_event.h +++ b/src/core/lib/iomgr/lockfree_event.h @@ -25,7 +25,7 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" namespace grpc_core { diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h index 10a78226548..c6624067535 100644 --- a/src/core/lib/iomgr/resolve_address.h +++ b/src/core/lib/iomgr/resolve_address.h @@ -22,7 +22,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset_set.h" #define GRPC_MAX_SOCKADDR_SIZE 128 diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h index 4e1c651278d..f939cfd4493 100644 --- a/src/core/lib/iomgr/resource_quota.h +++ b/src/core/lib/iomgr/resource_quota.h @@ -24,7 +24,7 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" /** \file Tracks resource usage against a pool. diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index 3ff2c307e2a..df02c0fc591 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -29,7 +29,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/iomgr_internal.h" /* This holds the data for an outstanding read or write on a socket. diff --git a/src/core/lib/iomgr/timer_uv.h b/src/core/lib/iomgr/timer_uv.h index 093b2d085db..10dc46e0c9a 100644 --- a/src/core/lib/iomgr/timer_uv.h +++ b/src/core/lib/iomgr/timer_uv.h @@ -21,8 +21,6 @@ #include -#include "src/core/lib/iomgr/exec_ctx.h" - struct grpc_timer { grpc_closure* closure; /* This is actually a uv_timer_t*, but we want to keep platform-specific diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h index ecf59ec5c54..88483b02e74 100644 --- a/src/core/lib/security/transport/security_handshaker.h +++ b/src/core/lib/security/transport/security_handshaker.h @@ -22,7 +22,6 @@ #include #include "src/core/lib/channel/handshaker.h" -#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/security/security_connector/security_connector.h" /// Creates a security handshaker using \a handshaker. diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index e418ab10ef0..58ca4955170 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -26,6 +26,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" /* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */ diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 065c25c90c9..5d3d26b67b3 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -24,8 +24,6 @@ #include #include -#include "src/core/lib/iomgr/exec_ctx.h" - grpc_slice grpc_slice_ref_internal(grpc_slice slice); void grpc_slice_unref_internal(grpc_slice slice); void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb); diff --git a/src/core/lib/surface/byte_buffer.cc b/src/core/lib/surface/byte_buffer.cc index fce87dc6110..6246796e46c 100644 --- a/src/core/lib/surface/byte_buffer.cc +++ b/src/core/lib/surface/byte_buffer.cc @@ -22,6 +22,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slices, diff --git a/src/core/lib/surface/byte_buffer_reader.cc b/src/core/lib/surface/byte_buffer_reader.cc index a10f1a39330..1debc98ea0c 100644 --- a/src/core/lib/surface/byte_buffer_reader.cc +++ b/src/core/lib/surface/byte_buffer_reader.cc @@ -29,6 +29,7 @@ #include #include "src/core/lib/compression/message_compress.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" static int is_compressed(grpc_byte_buffer* buffer) { diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index 95a756a5e44..eff832515da 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -24,7 +24,7 @@ #include #include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/orphanable.h" -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" /** Internal bit flag for grpc_begin_message's \a flags signaling the use of * compression for the message */ diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index 421db5aa393..ecb083cfc2f 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -23,7 +23,7 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/closure.h" typedef struct grpc_connectivity_state_watcher { /** we keep watchers in a linked list */ diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 5e0ecbdb962..78df4bc3a31 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -24,8 +24,8 @@ #include #include +#include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/iomgr/exec_ctx.h" extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata; diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index 3876063b52a..7068750b6f2 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -26,6 +26,7 @@ #include #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h index 9f14e9bee03..487f00c08b1 100644 --- a/src/core/lib/transport/status_conversion.h +++ b/src/core/lib/transport/status_conversion.h @@ -22,6 +22,7 @@ #include #include + #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc index ff91aea3508..1048b600f0b 100644 --- a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc @@ -26,6 +26,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" const size_t kInitialIovecBufferSize = 8; diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc index 8c764961b37..608213745e0 100644 --- a/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc @@ -26,6 +26,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h" diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc index 3dcddf3e670..8989a419897 100644 --- a/test/core/compression/algorithm_test.cc +++ b/test/core/compression/algorithm_test.cc @@ -24,6 +24,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index ff830b47cdf..33812ec8e5e 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -25,6 +25,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc index ee1a0bbccc7..e94ea51a75d 100644 --- a/test/core/end2end/tests/cancel_after_accept.cc +++ b/test/core/end2end/tests/cancel_after_accept.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc index bf3be1c8b71..4890b3013f3 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.cc +++ b/test/core/end2end/tests/cancel_after_round_trip.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc index 3dd1737793b..fa5b3b6e9b4 100644 --- a/test/core/end2end/tests/max_message_length.cc +++ b/test/core/end2end/tests/max_message_length.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc index 921a24ebf28..059ff7b5f8b 100644 --- a/test/core/iomgr/resource_quota_test.cc +++ b/test/core/iomgr/resource_quota_test.cc @@ -21,6 +21,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/slice/slice_hash_table_test.cc b/test/core/slice/slice_hash_table_test.cc index 279b543098f..43ddfe9bf2c 100644 --- a/test/core/slice/slice_hash_table_test.cc +++ b/test/core/slice/slice_hash_table_test.cc @@ -28,6 +28,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc index 5a49793a9e5..e683c41f312 100644 --- a/test/core/slice/slice_test.cc +++ b/test/core/slice/slice_test.cc @@ -16,8 +16,11 @@ * */ +#include + #include +#include #include #include diff --git a/test/core/slice/slice_weak_hash_table_test.cc b/test/core/slice/slice_weak_hash_table_test.cc index 4711d2fd26e..b0a243d572e 100644 --- a/test/core/slice/slice_weak_hash_table_test.cc +++ b/test/core/slice/slice_weak_hash_table_test.cc @@ -28,6 +28,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc index 80692ec2da0..df096372498 100644 --- a/test/core/transport/byte_stream_test.cc +++ b/test/core/transport/byte_stream_test.cc @@ -23,6 +23,7 @@ #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/bin_decoder_test.cc b/test/core/transport/chttp2/bin_decoder_test.cc index 751dd90c8c4..b4b07986a3e 100644 --- a/test/core/transport/chttp2/bin_decoder_test.cc +++ b/test/core/transport/chttp2/bin_decoder_test.cc @@ -25,6 +25,7 @@ #include #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index 9a195daee0a..a8eec1eefd6 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -24,6 +24,7 @@ #include #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" bool squelch = true; diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 9d3456a873a..43b6c79e8a9 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -24,6 +24,8 @@ #include #include #include + +#include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/parse_hexstring.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/hpack_table_test.cc b/test/core/transport/chttp2/hpack_table_test.cc index e316cf63a07..3ab463b6312 100644 --- a/test/core/transport/chttp2/hpack_table_test.cc +++ b/test/core/transport/chttp2/hpack_table_test.cc @@ -27,6 +27,7 @@ #include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/test_config.h" #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc index f5894599e52..cbd6318f528 100644 --- a/test/core/transport/connectivity_state_test.cc +++ b/test/core/transport/connectivity_state_test.cc @@ -22,6 +22,7 @@ #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/test_config.h" #include "test/core/util/tracer_util.h" diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc index 786df972856..4be34f72d9b 100644 --- a/test/core/transport/metadata_test.cc +++ b/test/core/transport/metadata_test.cc @@ -28,6 +28,7 @@ #include "src/core/ext/transport/chttp2/transport/bin_encoder.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc index fbbea71cb73..b763f19d50f 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc @@ -19,6 +19,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h" diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc index 2388be95cdb..32159e22f24 100644 --- a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc +++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc @@ -20,6 +20,7 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/tsi/alts/crypt/gsec.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h" From 711e32d584d5e90d961126f830ef057f7d7cb885 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Wed, 14 Mar 2018 16:34:55 -0700 Subject: [PATCH 60/67] Add header files for exec_ctx and closure in windows iomgr header files --- src/core/lib/iomgr/iocp_windows.h | 1 + src/core/lib/iomgr/socket_windows.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/core/lib/iomgr/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h index 5079ea5d84d..68d9de61582 100644 --- a/src/core/lib/iomgr/iocp_windows.h +++ b/src/core/lib/iomgr/iocp_windows.h @@ -27,6 +27,7 @@ #ifdef GRPC_WINSOCK_SOCKET +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_windows.h" typedef enum { diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index df02c0fc591..7bd01eded5a 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -29,6 +29,7 @@ #include #include +#include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/iomgr_internal.h" /* This holds the data for an outstanding read or write on a socket. From 5848893d65b8f6afd38fa8cbc3b5afcb933e698a Mon Sep 17 00:00:00 2001 From: Yihua Zhang Date: Thu, 15 Mar 2018 11:06:25 -0700 Subject: [PATCH 61/67] build nanopb one-off target --- bazel/grpc_build_system.bzl | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 9194f37a170..571b29cc09b 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -37,7 +37,7 @@ def _get_external_deps(external_deps): ret = [] for dep in external_deps: if dep == "nanopb": - ret += ["//third_party/nanopb"] + ret += ["grpc_nanopb"] elif dep == "cares": ret += select({"//:grpc_no_ares": [], "//conditions:default": ["//external:cares"],}) @@ -57,12 +57,6 @@ def _maybe_update_cc_library_hdrs(hdrs): ret.append(h) return ret -def _maybe_update_cc_library_defines(name): - ret = [] - if name == "alts_proto": - ret += ["PB_FIELD_16BIT=1"] - return ret - def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++", testonly = False, visibility = None, @@ -70,11 +64,10 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], copts = [] if language.upper() == "C": copts = if_not_windows(["-std=c99"]) - defines = _maybe_update_cc_library_defines(name) native.cc_library( name = name, srcs = srcs, - defines = defines + select({"//:grpc_no_ares": ["GRPC_ARES=0"], + defines = select({"//:grpc_no_ares": ["GRPC_ARES=0"], "//conditions:default": [],}) + select({"//:remote_execution": ["GRPC_PORT_ISOLATED_RUNTIME=1"], "//conditions:default": [],}) + @@ -162,7 +155,23 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da ) def grpc_generate_one_off_targets(): - pass + native.cc_library( + name = "grpc_nanopb", + hdrs = [ + "//third_party/nanopb:pb.h", + "//third_party/nanopb:pb_common.h", + "//third_party/nanopb:pb_decode.h", + "//third_party/nanopb:pb_encode.h", + ], + srcs = [ + "//third_party/nanopb:pb_common.c", + "//third_party/nanopb:pb_decode.c", + "//third_party/nanopb:pb_encode.c", + ], + defines = [ + "PB_FIELD_16BIT=1", + ], + ) def grpc_sh_test(name, srcs, args = [], data = []): native.sh_test( From b1c9b5f10fa60bd0cee93cfaa1c575bbd75d7784 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Tue, 6 Mar 2018 16:45:11 -0800 Subject: [PATCH 62/67] Replace old server_host with the new one via command line. --- .../run_interop_matrix_tests.py | 21 ++++++++++- tools/interop_matrix/testcases/csharp__master | 36 +++++++++---------- tools/interop_matrix/testcases/csharp__v1.1.4 | 36 +++++++++---------- tools/interop_matrix/testcases/csharp__v1.2.5 | 36 +++++++++---------- .../testcases/csharpcoreclr__master | 36 +++++++++---------- tools/interop_matrix/testcases/cxx__master | 36 +++++++++---------- tools/interop_matrix/testcases/go__master | 36 +++++++++---------- tools/interop_matrix/testcases/java__master | 36 +++++++++---------- tools/interop_matrix/testcases/node__master | 36 +++++++++---------- tools/interop_matrix/testcases/node__v1.0.1 | 36 +++++++++---------- tools/interop_matrix/testcases/php__master | 36 +++++++++---------- tools/interop_matrix/testcases/python__master | 36 +++++++++---------- tools/interop_matrix/testcases/ruby__master | 36 +++++++++---------- tools/interop_matrix/testcases/ruby__v1.0.1 | 36 +++++++++---------- 14 files changed, 254 insertions(+), 235 deletions(-) diff --git a/tools/interop_matrix/run_interop_matrix_tests.py b/tools/interop_matrix/run_interop_matrix_tests.py index 3391ef51ccb..eb1e0213651 100755 --- a/tools/interop_matrix/run_interop_matrix_tests.py +++ b/tools/interop_matrix/run_interop_matrix_tests.py @@ -59,7 +59,6 @@ argp.add_argument( choices=['all', 'master'] + _RELEASES, help='Release tags to test. When testing all ' 'releases defined in client_matrix.py, use "all".') - argp.add_argument( '-l', '--language', @@ -89,6 +88,12 @@ argp.add_argument( type=str, nargs='?', help='Upload test results to a specified BQ table.') +argp.add_argument( + '--server_host', + default='74.125.206.210', + type=str, + nargs='?', + help='The gateway to backend services.') args = argp.parse_args() @@ -166,6 +171,20 @@ def find_test_cases(lang, runtime, release, suite_name): '--server_host_override=(.*).sandbox.googleapis.com', line) server = m.group(1) if m else 'unknown_server' + + # If server_host arg is not None, replace the original + # server_host with the one provided or append to the end of + # the command if server_host does not appear originally. + if args.server_host: + if line.find('--server_host=') > -1: + line = re.sub('--server_host=[^ ]*', + '--server_host=%s' % args.server_host, + line) + else: + line = '%s --server_host=%s"' % (line[:-1], + args.server_host) + print(line) + spec = jobset.JobSpec( cmdline=line, shortname='%s:%s:%s:%s' % (suite_name, lang, server, diff --git a/tools/interop_matrix/testcases/csharp__master b/tools/interop_matrix/testcases/csharp__master index 32f6b380418..c3cd6a48f88 100644 --- a/tools/interop_matrix/testcases/csharp__master +++ b/tools/interop_matrix/testcases/csharp__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_csharp:a95229ca-d387-4127-ad48-69a7464e23b8}" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/csharp__v1.1.4 b/tools/interop_matrix/testcases/csharp__v1.1.4 index 19da788c128..f4a6fb12411 100644 --- a/tools/interop_matrix/testcases/csharp__v1.1.4 +++ b/tools/interop_matrix/testcases/csharp__v1.1.4 @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_csharp:a95229ca-d387-4127-ad48-69a7464e23b8}" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/csharp__v1.2.5 b/tools/interop_matrix/testcases/csharp__v1.2.5 index 19da788c128..f4a6fb12411 100644 --- a/tools/interop_matrix/testcases/csharp__v1.2.5 +++ b/tools/interop_matrix/testcases/csharp__v1.2.5 @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_csharp:a95229ca-d387-4127-ad48-69a7464e23b8}" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug --net=host $docker_image bash -c "mono Grpc.IntegrationTesting.Client.exe --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/csharpcoreclr__master b/tools/interop_matrix/testcases/csharpcoreclr__master index 37e45989b2e..aa8b9dd86d1 100644 --- a/tools/interop_matrix/testcases/csharpcoreclr__master +++ b/tools/interop_matrix/testcases/csharpcoreclr__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_csharpcoreclr:c7fbed09-e4c1-4aab-8dd9-1285b2c9598e}" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0 --net=host $docker_image bash -c "dotnet exec Grpc.IntegrationTesting.Client.dll --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/cxx__master b/tools/interop_matrix/testcases/cxx__master index e0fed53f088..629da1afd0d 100755 --- a/tools/interop_matrix/testcases/cxx__master +++ b/tools/interop_matrix/testcases/cxx__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_cxx:78de6f80-524d-4bc9-bfb2-f00c24ceafed}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/go__master b/tools/interop_matrix/testcases/go__master index 33b25d6a16b..a7f83ae1693 100755 --- a/tools/interop_matrix/testcases/go__master +++ b/tools/interop_matrix/testcases/go__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_go:dd8fbf3a-4964-4387-9997-5dadeea09835}" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/java__master b/tools/interop_matrix/testcases/java__master index dbd87279a6d..95a9c2834f4 100755 --- a/tools/interop_matrix/testcases/java__master +++ b/tools/interop_matrix/testcases/java__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_java:a764b50c-1788-4387-9b9e-5cfa93927006}" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/node__master b/tools/interop_matrix/testcases/node__master index 99ea2f0bc47..9e31fbf97dc 100755 --- a/tools/interop_matrix/testcases/node__master +++ b/tools/interop_matrix/testcases/node__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_node:1415ecbf-5d0f-423e-8c2c-e0cb6d154e73}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_nvm.sh node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/node__v1.0.1 b/tools/interop_matrix/testcases/node__v1.0.1 index 6faf3213917..fca98215442 100644 --- a/tools/interop_matrix/testcases/node__v1.0.1 +++ b/tools/interop_matrix/testcases/node__v1.0.1 @@ -1,21 +1,21 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_node:a53aa5e3-b548-4566-b5a8-6d15c1315b32}" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_00c688f2-57da-4023-89f3-46b1f7b5869f $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_d86705d8-14ea-4024-90b6-de74d6e8d19c $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_ebaafacd-1d82-4a75-bea1-a5c64e01fcaf $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_5125241a-fbf6-4c1c-895b-026a5a41f02f $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_3d5e5b82-7205-4eba-b775-8122f05a4760 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_16fa0b49-2083-4932-8f26-79cfdffec940 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_23cee670-2d8d-4f5c-8893-c3c43da8b03a $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_7b6a9454-e3b6-4993-b542-468e268930aa $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_5a7109ed-c065-4b62-98f4-b3ed8f385762 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_1e0ba8dd-4dc1-431b-b202-529e7ace5d1d $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_649de56a-e722-4a59-b265-e9c0e871f068 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_8be512a2-5e1c-4858-8cfc-82f99b678b76 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_d19b6333-e528-48b5-8421-2ae3f7ce9dab $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_4749c80a-21c5-4d81-9df5-3c46ba6480cd $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_b7bee545-4857-4269-a1f2-9553dfc7e4b8 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_4e96db87-6f48-426d-a7f0-97f3a5b6b3f4 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_31a1d58c-f8bf-460a-af60-28969ecaaf80 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_ce64b147-bcfa-44b2-a2f7-4a485380ce30 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_00c688f2-57da-4023-89f3-46b1f7b5869f $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_d86705d8-14ea-4024-90b6-de74d6e8d19c $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_ebaafacd-1d82-4a75-bea1-a5c64e01fcaf $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_5125241a-fbf6-4c1c-895b-026a5a41f02f $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_3d5e5b82-7205-4eba-b775-8122f05a4760 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_16fa0b49-2083-4932-8f26-79cfdffec940 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_23cee670-2d8d-4f5c-8893-c3c43da8b03a $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_7b6a9454-e3b6-4993-b542-468e268930aa $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_5a7109ed-c065-4b62-98f4-b3ed8f385762 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_1e0ba8dd-4dc1-431b-b202-529e7ace5d1d $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_649de56a-e722-4a59-b265-e9c0e871f068 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_8be512a2-5e1c-4858-8cfc-82f99b678b76 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_d19b6333-e528-48b5-8421-2ae3f7ce9dab $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_4749c80a-21c5-4d81-9df5-3c46ba6480cd $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_b7bee545-4857-4269-a1f2-9553dfc7e4b8 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_4e96db87-6f48-426d-a7f0-97f3a5b6b3f4 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_31a1d58c-f8bf-460a-af60-28969ecaaf80 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host --name interop_client_node_ce64b147-bcfa-44b2-a2f7-4a485380ce30 $docker_image bash -l -c "node src/node/interop/interop_client.js --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/php__master b/tools/interop_matrix/testcases/php__master index bce1d305504..f99cb176212 100755 --- a/tools/interop_matrix/testcases/php__master +++ b/tools/interop_matrix/testcases/php__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_php:b290f404-9940-4968-8fc2-19f5291c8eb7}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "src/php/bin/interop_client.sh --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/python__master b/tools/interop_matrix/testcases/python__master index 4a63eae89d8..71ba75e5d1f 100755 --- a/tools/interop_matrix/testcases/python__master +++ b/tools/interop_matrix/testcases/python__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_python:797ca293-94e8-48d4-92e9-a4d52fcfcca9}" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response\"" -docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response\"" +docker run -i --rm=true -e PYTHONPATH=/var/local/git/grpc/src/python/gens -e LD_LIBRARY_PATH=/var/local/git/grpc/libs/opt -w /var/local/git/grpc --net=host $docker_image bash -c "py27/bin/python src/python/grpcio_tests/setup.py run_interop --client --args=\"--server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server\"" diff --git a/tools/interop_matrix/testcases/ruby__master b/tools/interop_matrix/testcases/ruby__master index 07bfd058666..784ba689f6f 100755 --- a/tools/interop_matrix/testcases/ruby__master +++ b/tools/interop_matrix/testcases/ruby__master @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_ruby:6bd1f0eb-51a4-4ad8-861c-1cbd7a929f33}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "tools/run_tests/interop/with_rvm.sh ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/ruby__v1.0.1 b/tools/interop_matrix/testcases/ruby__v1.0.1 index effbef1d18b..99665297f00 100755 --- a/tools/interop_matrix/testcases/ruby__v1.0.1 +++ b/tools/interop_matrix/testcases/ruby__v1.0.1 @@ -1,20 +1,20 @@ #!/bin/bash echo "Testing ${docker_image:=grpc_interop_ruby:6bd1f0eb-51a4-4ad8-861c-1cbd7a929f33}" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test.sandbox.googleapis.com --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "source /usr/local/rvm/scripts/rvm && ruby src/ruby/pb/test/client.rb --server_host=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" From ba46afe3e2b4e8dc00fec8347979f2ad9c1427dd Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 15 Mar 2018 11:16:58 -0700 Subject: [PATCH 63/67] Delete status_test that has no coverage; replace with static_asserts --- CMakeLists.txt | 38 ------- Makefile | 48 -------- build.yaml | 12 -- include/grpcpp/impl/codegen/status.h | 56 +++++++++- test/cpp/util/BUILD | 104 ++++++++---------- test/cpp/util/status_test.cc | 62 ----------- .../generated/sources_and_headers.json | 18 --- tools/run_tests/generated/tests.json | 24 ---- 8 files changed, 102 insertions(+), 260 deletions(-) delete mode 100644 test/cpp/util/status_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e58593fb19..77e84a0df80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -620,7 +620,6 @@ add_dependencies(buildtests_cxx slice_hash_table_test) add_dependencies(buildtests_cxx slice_weak_hash_table_test) add_dependencies(buildtests_cxx stats_test) add_dependencies(buildtests_cxx status_metadata_test) -add_dependencies(buildtests_cxx status_test) add_dependencies(buildtests_cxx status_util_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx streaming_throughput_test) @@ -13073,43 +13072,6 @@ target_link_libraries(status_metadata_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(status_test - test/cpp/util/status_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - - -target_include_directories(status_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(status_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc++ - grpc - gpr_test_util - gpr - ${_gRPC_GFLAGS_LIBRARIES} -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(status_util_test test/core/client_channel/status_util_test.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index 625248ea301..3fa0f6617b3 100644 --- a/Makefile +++ b/Makefile @@ -1202,7 +1202,6 @@ slice_hash_table_test: $(BINDIR)/$(CONFIG)/slice_hash_table_test slice_weak_hash_table_test: $(BINDIR)/$(CONFIG)/slice_weak_hash_table_test stats_test: $(BINDIR)/$(CONFIG)/stats_test status_metadata_test: $(BINDIR)/$(CONFIG)/status_metadata_test -status_test: $(BINDIR)/$(CONFIG)/status_test status_util_test: $(BINDIR)/$(CONFIG)/status_util_test streaming_throughput_test: $(BINDIR)/$(CONFIG)/streaming_throughput_test stress_test: $(BINDIR)/$(CONFIG)/stress_test @@ -1681,7 +1680,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/slice_weak_hash_table_test \ $(BINDIR)/$(CONFIG)/stats_test \ $(BINDIR)/$(CONFIG)/status_metadata_test \ - $(BINDIR)/$(CONFIG)/status_test \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ @@ -1848,7 +1846,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/slice_weak_hash_table_test \ $(BINDIR)/$(CONFIG)/stats_test \ $(BINDIR)/$(CONFIG)/status_metadata_test \ - $(BINDIR)/$(CONFIG)/status_test \ $(BINDIR)/$(CONFIG)/status_util_test \ $(BINDIR)/$(CONFIG)/streaming_throughput_test \ $(BINDIR)/$(CONFIG)/stress_test \ @@ -2312,8 +2309,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/stats_test || ( echo test stats_test failed ; exit 1 ) $(E) "[RUN] Testing status_metadata_test" $(Q) $(BINDIR)/$(CONFIG)/status_metadata_test || ( echo test status_metadata_test failed ; exit 1 ) - $(E) "[RUN] Testing status_test" - $(Q) $(BINDIR)/$(CONFIG)/status_test || ( echo test status_test failed ; exit 1 ) $(E) "[RUN] Testing status_util_test" $(Q) $(BINDIR)/$(CONFIG)/status_util_test || ( echo test status_util_test failed ; exit 1 ) $(E) "[RUN] Testing streaming_throughput_test" @@ -19115,49 +19110,6 @@ endif endif -STATUS_TEST_SRC = \ - test/cpp/util/status_test.cc \ - -STATUS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(STATUS_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/status_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. - -$(BINDIR)/$(CONFIG)/status_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/status_test: $(PROTOBUF_DEP) $(STATUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(STATUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/status_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/cpp/util/status_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_status_test: $(STATUS_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(STATUS_TEST_OBJS:.o=.dep) -endif -endif - - STATUS_UTIL_TEST_SRC = \ test/core/client_channel/status_util_test.cc \ diff --git a/build.yaml b/build.yaml index 02a1e6186e8..a4875df9e53 100644 --- a/build.yaml +++ b/build.yaml @@ -5122,18 +5122,6 @@ targets: deps: - grpc uses_polling: false -- name: status_test - build: test - language: c++ - src: - - test/cpp/util/status_test.cc - deps: - - grpc_test_util - - grpc++ - - grpc - - gpr_test_util - - gpr - uses_polling: false - name: status_util_test gtest: true cpu_cost: 0.1 diff --git a/include/grpcpp/impl/codegen/status.h b/include/grpcpp/impl/codegen/status.h index 9f409eb9bd8..e625a76b15d 100644 --- a/include/grpcpp/impl/codegen/status.h +++ b/include/grpcpp/impl/codegen/status.h @@ -19,6 +19,7 @@ #ifndef GRPCPP_IMPL_CODEGEN_STATUS_H #define GRPCPP_IMPL_CODEGEN_STATUS_H +#include #include #include @@ -30,7 +31,60 @@ namespace grpc { class Status { public: /// Construct an OK instance. - Status() : code_(StatusCode::OK) {} + Status() : code_(StatusCode::OK) { + // Static assertions to make sure that the C++ API value correctly + // maps to the core surface API value + static_assert(StatusCode::OK == static_cast(GRPC_STATUS_OK), + "Mismatched status code"); + static_assert( + StatusCode::CANCELLED == static_cast(GRPC_STATUS_CANCELLED), + "Mismatched status code"); + static_assert( + StatusCode::UNKNOWN == static_cast(GRPC_STATUS_UNKNOWN), + "Mismatched status code"); + static_assert(StatusCode::INVALID_ARGUMENT == + static_cast(GRPC_STATUS_INVALID_ARGUMENT), + "Mismatched status code"); + static_assert(StatusCode::DEADLINE_EXCEEDED == + static_cast(GRPC_STATUS_DEADLINE_EXCEEDED), + "Mismatched status code"); + static_assert( + StatusCode::NOT_FOUND == static_cast(GRPC_STATUS_NOT_FOUND), + "Mismatched status code"); + static_assert(StatusCode::ALREADY_EXISTS == + static_cast(GRPC_STATUS_ALREADY_EXISTS), + "Mismatched status code"); + static_assert(StatusCode::PERMISSION_DENIED == + static_cast(GRPC_STATUS_PERMISSION_DENIED), + "Mismatched status code"); + static_assert(StatusCode::UNAUTHENTICATED == + static_cast(GRPC_STATUS_UNAUTHENTICATED), + "Mismatched status code"); + static_assert(StatusCode::RESOURCE_EXHAUSTED == + static_cast(GRPC_STATUS_RESOURCE_EXHAUSTED), + "Mismatched status code"); + static_assert(StatusCode::FAILED_PRECONDITION == + static_cast(GRPC_STATUS_FAILED_PRECONDITION), + "Mismatched status code"); + static_assert( + StatusCode::ABORTED == static_cast(GRPC_STATUS_ABORTED), + "Mismatched status code"); + static_assert(StatusCode::OUT_OF_RANGE == + static_cast(GRPC_STATUS_OUT_OF_RANGE), + "Mismatched status code"); + static_assert(StatusCode::UNIMPLEMENTED == + static_cast(GRPC_STATUS_UNIMPLEMENTED), + "Mismatched status code"); + static_assert( + StatusCode::INTERNAL == static_cast(GRPC_STATUS_INTERNAL), + "Mismatched status code"); + static_assert(StatusCode::UNAVAILABLE == + static_cast(GRPC_STATUS_UNAVAILABLE), + "Mismatched status code"); + static_assert( + StatusCode::DATA_LOSS == static_cast(GRPC_STATUS_DATA_LOSS), + "Mismatched status code"); + } /// Construct an instance with associated \a code and \a error_message. /// It is an error to construct an OK status with non-empty \a error_message. diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index d092ba348ef..4f84c738203 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -16,7 +16,10 @@ licenses(["notice"]) # Apache v2 load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_binary", "grpc_cc_test", "grpc_package") -grpc_package(name = "test/cpp/util", visibility = "public") +grpc_package( + name = "test/cpp/util", + visibility = "public", +) grpc_cc_library( name = "test_config", @@ -49,7 +52,7 @@ grpc_cc_library( ], ) -GRPCXX_TESTUTIL_SRCS = [ +GRPCXX_TESTUTIL_SRCS = [ "byte_buffer_proto_helper.cc", "string_ref_helper.cc", "subprocess.cc", @@ -71,27 +74,27 @@ grpc_cc_library( "create_test_channel.h", "test_credentials_provider.h", ], + external_deps = [ + "protobuf", + ], deps = [ "//:grpc++", "//test/core/end2end:ssl_test_data", "//test/core/util:grpc_test_util", ], - external_deps = [ - "protobuf", - ], ) grpc_cc_library( name = "test_util_unsecure", srcs = GRPCXX_TESTUTIL_SRCS, hdrs = GRPCXX_TESTUTIL_HDRS, + external_deps = [ + "protobuf", + ], deps = [ "//:grpc++_unsecure", "//test/core/util:grpc_test_util", ], - external_deps = [ - "protobuf", - ], ) grpc_cc_library( @@ -111,16 +114,16 @@ grpc_cc_library( "proto_file_parser.h", "service_describer.h", ], - deps = [ - "//:grpc++", - "//src/proto/grpc/reflection/v1alpha:reflection_proto", - ":grpc++_proto_reflection_desc_db", - ], external_deps = [ "gflags", "protobuf", "protobuf_clib", ], + deps = [ + ":grpc++_proto_reflection_desc_db", + "//:grpc++", + "//src/proto/grpc/reflection/v1alpha:reflection_proto", + ], ) grpc_cc_library( @@ -132,8 +135,8 @@ grpc_cc_library( "metrics_server.h", ], deps = [ - "//src/proto/grpc/testing:metrics_proto", "//:grpc++", + "//src/proto/grpc/testing:metrics_proto", ], ) @@ -144,19 +147,19 @@ grpc_cc_test( ], data = [ "//src/proto/grpc/testing:echo.proto", - "//src/proto/grpc/testing:echo_messages.proto" - ], - deps = [ - ":grpc_cli_libs", - ":test_util", - "//:grpc++_reflection", - "//src/proto/grpc/testing:echo_proto", - "//src/proto/grpc/testing:echo_messages_proto", - "//test/core/util:grpc_test_util", + "//src/proto/grpc/testing:echo_messages.proto", ], external_deps = [ "gtest", ], + deps = [ + ":grpc_cli_libs", + ":test_util", + "//:grpc++_reflection", + "//src/proto/grpc/testing:echo_messages_proto", + "//src/proto/grpc/testing:echo_proto", + "//test/core/util:grpc_test_util", + ], ) grpc_cc_test( @@ -164,12 +167,12 @@ grpc_cc_test( srcs = [ "byte_buffer_test.cc", ], - deps = [ - ":test_util", - ], external_deps = [ "gtest", ], + deps = [ + ":test_util", + ], ) grpc_cc_test( @@ -177,12 +180,12 @@ grpc_cc_test( srcs = [ "slice_test.cc", ], - deps = [ - ":test_util", - ], external_deps = [ "gtest", ], + deps = [ + ":test_util", + ], ) grpc_cc_test( @@ -190,12 +193,12 @@ grpc_cc_test( srcs = [ "string_ref_test.cc", ], - deps = [ - "//:grpc++", - ], external_deps = [ "gtest", ], + deps = [ + "//:grpc++", + ], ) grpc_cc_test( @@ -203,24 +206,11 @@ grpc_cc_test( srcs = [ "time_test.cc", ], - deps = [ - ":test_util", - ], external_deps = [ "gtest", ], -) - -grpc_cc_test( - name = "status_test", - srcs = [ - "status_test.cc", - ], deps = [ - ":test_util", - ], - external_deps = [ - "gtest", + ":test_util", ], ) @@ -229,14 +219,14 @@ grpc_cc_test( srcs = [ "cli_call_test.cc", ], + external_deps = [ + "gtest", + ], deps = [ ":grpc_cli_libs", - ":test_util", + ":test_util", "//src/proto/grpc/testing:echo_proto", - "//test/core/util:grpc_test_util", - ], - external_deps = [ - "gtest", + "//test/core/util:grpc_test_util", ], ) @@ -245,13 +235,13 @@ grpc_cc_test( srcs = [ "error_details_test.cc", ], + external_deps = [ + "gtest", + ], deps = [ "//:grpc++_error_details", "//src/proto/grpc/testing:echo_messages_proto", ], - external_deps = [ - "gtest", - ], ) grpc_cc_binary( @@ -274,11 +264,11 @@ grpc_cc_binary( "test_config.h", "test_config_cc.cc", ], + external_deps = [ + "gflags", + ], deps = [ "//:grpc++", "//src/proto/grpc/reflection/v1alpha:reflection_proto", ], - external_deps = [ - "gflags", - ], ) diff --git a/test/cpp/util/status_test.cc b/test/cpp/util/status_test.cc deleted file mode 100644 index 2188723db80..00000000000 --- a/test/cpp/util/status_test.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * Copyright 2015 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. - * - */ - -#include - -#include -#include - -// Make sure the existing grpc_status_code match with grpc::Code. -int main(int argc, char** argv) { - GPR_ASSERT(grpc::StatusCode::OK == - static_cast(GRPC_STATUS_OK)); - GPR_ASSERT(grpc::StatusCode::CANCELLED == - static_cast(GRPC_STATUS_CANCELLED)); - GPR_ASSERT(grpc::StatusCode::UNKNOWN == - static_cast(GRPC_STATUS_UNKNOWN)); - GPR_ASSERT(grpc::StatusCode::INVALID_ARGUMENT == - static_cast(GRPC_STATUS_INVALID_ARGUMENT)); - GPR_ASSERT(grpc::StatusCode::DEADLINE_EXCEEDED == - static_cast(GRPC_STATUS_DEADLINE_EXCEEDED)); - GPR_ASSERT(grpc::StatusCode::NOT_FOUND == - static_cast(GRPC_STATUS_NOT_FOUND)); - GPR_ASSERT(grpc::StatusCode::ALREADY_EXISTS == - static_cast(GRPC_STATUS_ALREADY_EXISTS)); - GPR_ASSERT(grpc::StatusCode::PERMISSION_DENIED == - static_cast(GRPC_STATUS_PERMISSION_DENIED)); - GPR_ASSERT(grpc::StatusCode::UNAUTHENTICATED == - static_cast(GRPC_STATUS_UNAUTHENTICATED)); - GPR_ASSERT(grpc::StatusCode::RESOURCE_EXHAUSTED == - static_cast(GRPC_STATUS_RESOURCE_EXHAUSTED)); - GPR_ASSERT(grpc::StatusCode::FAILED_PRECONDITION == - static_cast(GRPC_STATUS_FAILED_PRECONDITION)); - GPR_ASSERT(grpc::StatusCode::ABORTED == - static_cast(GRPC_STATUS_ABORTED)); - GPR_ASSERT(grpc::StatusCode::OUT_OF_RANGE == - static_cast(GRPC_STATUS_OUT_OF_RANGE)); - GPR_ASSERT(grpc::StatusCode::UNIMPLEMENTED == - static_cast(GRPC_STATUS_UNIMPLEMENTED)); - GPR_ASSERT(grpc::StatusCode::INTERNAL == - static_cast(GRPC_STATUS_INTERNAL)); - GPR_ASSERT(grpc::StatusCode::UNAVAILABLE == - static_cast(GRPC_STATUS_UNAVAILABLE)); - GPR_ASSERT(grpc::StatusCode::DATA_LOSS == - static_cast(GRPC_STATUS_DATA_LOSS)); - - return 0; -} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index d754c5d6fc1..f80cd9f2b5c 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -4473,24 +4473,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc", - "grpc++", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c++", - "name": "status_test", - "src": [ - "test/cpp/util/status_test.cc" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "grpc" diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 1e320fc15dc..3d6b6caa2ad 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4914,30 +4914,6 @@ ], "uses_polling": false }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c++", - "name": "status_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false, From 78e532a6e584b4b45cd229526d60482f1fa73a06 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Thu, 15 Mar 2018 13:54:04 -1000 Subject: [PATCH 64/67] Reviewer comments --- src/core/ext/filters/client_channel/subchannel.cc | 1 + src/core/lib/channel/channel_trace.cc | 6 +++--- src/core/lib/channel/channel_trace.h | 9 ++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 4c77c8602a1..d7815fb7e14 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -35,6 +35,7 @@ #include "src/core/ext/filters/client_channel/subchannel_index.h" #include "src/core/ext/filters/client_channel/uri_parser.h" #include "src/core/lib/backoff/backoff.h" +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/debug_location.h" diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 6d85db936d1..3c374719e90 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -152,10 +152,10 @@ char* fmt_time(gpr_timespec tm) { for (int i = 7; i >= 1; i -= 3) { if (ns_buffer[i] == '0' && ns_buffer[i + 1] == '0' && ns_buffer[i + 2] == '0') { - ns_buffer[i] = 0; - // Specially case in which all fractional digits were 0. + ns_buffer[i] = '\0'; + // Edge case in which all fractional digits were 0. if (i == 1) { - ns_buffer[0] = 0; + ns_buffer[0] = '\0'; } } else { break; diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index 7243096617e..1df1e585f25 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -48,15 +48,22 @@ class ChannelTrace : public RefCounted { }; // Adds a new trace event to the tracing object + // + // TODO(ncteisen): as this call is used more and more throughout the gRPC + // stack, determine if it makes more sense to accept a char* instead of a + // slice. void AddTraceEvent(Severity severity, grpc_slice data); // Adds a new trace event to the tracing object. This trace event refers to a // an event on a child of the channel. For example, if this channel has // created a new subchannel, then it would record that with a TraceEvent // referencing the new subchannel. - + // // TODO(ncteisen): Once channelz is implemented, the events should reference // the overall channelz object, not just the ChannelTrace object. + // TODO(ncteisen): as this call is used more and more throughout the gRPC + // stack, determine if it makes more sense to accept a char* instead of a + // slice. void AddTraceEventReferencingChannel( Severity severity, grpc_slice data, RefCountedPtr referenced_tracer); From 81a3376d7dd49505e592ecd1afcdbf11cff49d24 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 15 Mar 2018 18:28:11 -0700 Subject: [PATCH 65/67] Zero out resolved address before calling accept --- src/core/lib/iomgr/tcp_server_posix.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index aba5d6cdb05..1d9276a5608 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -213,6 +213,7 @@ static void on_read(void* arg, grpc_error* err) { grpc_resolved_address addr; char* addr_str; char* name; + memset(&addr, 0, sizeof(addr)); addr.len = sizeof(struct sockaddr_storage); /* Note: If we ever decide to return this address to the user, remember to strip off the ::ffff:0.0.0.0/96 prefix first. */ From 2352380262692c9a418112bea615fd51934e2635 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 16 Mar 2018 08:39:40 -0700 Subject: [PATCH 66/67] Update proto name to fix Windows portability build --- src/core/lib/channel/channel_trace.cc | 8 ++++---- src/proto/grpc/channelz/channelz.proto | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index 3c374719e90..67d5fd364bd 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -169,13 +169,13 @@ char* fmt_time(gpr_timespec tm) { const char* severity_string(ChannelTrace::Severity severity) { switch (severity) { case ChannelTrace::Severity::Info: - return "INFO"; + return "CT_INFO"; case ChannelTrace::Severity::Warning: - return "WARNING"; + return "CT_WARNING"; case ChannelTrace::Severity::Error: - return "ERROR"; + return "CT_ERROR"; default: - GPR_UNREACHABLE_CODE(return "UNKNOWN"); + GPR_UNREACHABLE_CODE(return "CT_UNKNOWN"); } } diff --git a/src/proto/grpc/channelz/channelz.proto b/src/proto/grpc/channelz/channelz.proto index ea9636905df..14db66a654b 100644 --- a/src/proto/grpc/channelz/channelz.proto +++ b/src/proto/grpc/channelz/channelz.proto @@ -111,10 +111,10 @@ message ChannelTraceEvent { string description = 1; // The supported severity levels of trace events. enum Severity { - UNKNOWN = 0; - INFO = 1; - WARNING = 2; - ERROR = 3; + CT_UNKNOWN = 0; + CT_INFO = 1; + CT_WARNING = 2; + CT_ERROR = 3; } // the severity of the trace event Severity severity = 2; From 613d6327efeced1bea3baba1c19b2f287d4cb53e Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 16 Mar 2018 08:42:08 -0700 Subject: [PATCH 67/67] Add more validation tests to channel_trace_test --- test/core/channel/channel_trace_test.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 0ba13ff1367..3c73e336120 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -189,19 +189,24 @@ TEST_P(ChannelTracerTest, TestNesting) { RefCountedPtr tracer = MakeRefCounted(GetParam()); AddSimpleTrace(tracer); AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 2, GetParam()); RefCountedPtr sc1 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingChannel( ChannelTrace::Severity::Info, grpc_slice_from_static_string("subchannel one created"), sc1); + ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(sc1); RefCountedPtr conn1 = MakeRefCounted(GetParam()); // nesting one level deeper. sc1->AddTraceEventReferencingSubchannel( ChannelTrace::Severity::Info, grpc_slice_from_static_string("connection one created"), conn1); + ValidateChannelTrace(tracer, 3, GetParam()); AddSimpleTrace(conn1); AddSimpleTrace(tracer); AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 5, GetParam()); + ValidateChannelTrace(conn1, 1, GetParam()); RefCountedPtr sc2 = MakeRefCounted(GetParam()); tracer->AddTraceEventReferencingSubchannel( ChannelTrace::Severity::Info, @@ -212,6 +217,7 @@ TEST_P(ChannelTracerTest, TestNesting) { ChannelTrace::Severity::Warning, grpc_slice_from_static_string("subchannel one inactive"), sc1); AddSimpleTrace(tracer); + ValidateChannelTrace(tracer, 8, GetParam()); tracer.reset(nullptr); sc1.reset(nullptr); sc2.reset(nullptr);