aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2018-03-06 21:44:08 -0800
committerGravatar ncteisen <ncteisen@gmail.com>2018-03-06 21:44:08 -0800
commit07ed0396a900d01dc2b2142892417254e52eca77 (patch)
tree6d048db28a0a169902bf41138bbeb52fd547d814
parent9efb1777306c2d28ccc35ded2f8ff2c8af08941a (diff)
Add JsonProtoTest
-rw-r--r--CMakeLists.txt53
-rw-r--r--Makefile72
-rw-r--r--build.yaml20
-rw-r--r--src/proto/grpc/channelz/BUILD24
-rw-r--r--src/proto/grpc/channelz/channelz.proto437
-rw-r--r--test/core/channel/channel_trace_test.cc8
-rw-r--r--test/cpp/client/BUILD13
-rw-r--r--test/cpp/client/channel_trace_proto_json_test.cc82
-rw-r--r--tools/run_tests/generated/sources_and_headers.json38
-rw-r--r--tools/run_tests/generated/tests.json24
10 files changed, 767 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34cf01a208..f6426932ec 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 26126a32c1..3dc9729752 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"
@@ -2364,6 +2369,22 @@ $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
$(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
else
@@ -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 c3511d3342..08fb17e7e0 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 0000000000..9318e5ccde
--- /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 0000000000..532ec7978f
--- /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 f9bc6db82b..ea0c6be912 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<ChannelTrace> 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 12825e88c2..3cbd63a99e 100644
--- a/test/cpp/client/BUILD
+++ b/test/cpp/client/BUILD
@@ -19,6 +19,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"],
external_deps = [
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 0000000000..d68adb360f
--- /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 <memory>
+
+#include <google/protobuf/text_format.h>
+#include <google/protobuf/util/json_util.h>
+
+#include <grpc/grpc.h>
+#include <gtest/gtest.h>
+
+#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<ChannelTrace> 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<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(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 9d8c9778cf..baf9be749b 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"
],
@@ -10010,6 +10034,20 @@
"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 cae60dd29a..48ea61061f 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -3352,6 +3352,30 @@
"flaky": false,
"gtest": true,
"language": "c++",
+ "name": "channel_trace_proto_json_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": true
+ },
+ {
+ "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_test",
"platforms": [
"linux",