Move C++ to util, call it from core test

reviewable/pr13883/r12
ncteisen 7 years ago
parent 568a95e0b4
commit 97a3dbeb36
  1. 48
      CMakeLists.txt
  2. 63
      Makefile
  3. 17
      build.yaml
  4. 1
      grpc.gyp
  5. 2
      src/proto/grpc/channelz/BUILD
  6. 1
      test/core/channel/BUILD
  7. 40
      test/core/channel/channel_trace_test.cc
  8. 13
      test/cpp/client/BUILD
  9. 18
      test/cpp/util/BUILD
  10. 46
      test/cpp/util/channel_trace_proto_helper.cc
  11. 30
      test/cpp/util/channel_trace_proto_helper.h
  12. 27
      tools/run_tests/generated/sources_and_headers.json
  13. 24
      tools/run_tests/generated/tests.json

@ -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

@ -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)

@ -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

@ -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',

@ -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,
)

@ -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",

@ -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<ChannelTrace> 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<ChannelTrace> 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<ChannelTrace> sc1 = MakeRefCounted<ChannelTrace>(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<ChannelTrace> sc2 = MakeRefCounted<ChannelTrace>(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<ChannelTrace> sc1 = MakeRefCounted<ChannelTrace>(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<ChannelTrace> conn1 = MakeRefCounted<ChannelTrace>(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<ChannelTrace> sc2 = MakeRefCounted<ChannelTrace>(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);

@ -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"],

@ -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,

@ -16,7 +16,7 @@
*
*/
#include <memory>
#include "test/cpp/util/channel_trace_proto_helper.h"
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/json_util.h>
@ -24,42 +24,13 @@
#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"));
}
} // namespace
TEST(ChannelTraceTest, ProtoJsonTest) {
grpc_core::ExecCtx exec_ctx;
RefCountedPtr<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(10);
AddSimpleTrace(tracer);
AddSimpleTrace(tracer);
RefCountedPtr<ChannelTrace> sc1 = MakeRefCounted<ChannelTrace>(10);
tracer->AddTraceEventReferencingSubchannel(
grpc_slice_from_static_string("subchannel one created"), sc1);
AddSimpleTrace(sc1);
AddSimpleTrace(sc1);
AddSimpleTrace(sc1);
RefCountedPtr<ChannelTrace> sc2 = MakeRefCounted<ChannelTrace>(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;
}

@ -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

@ -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",

@ -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,

Loading…
Cancel
Save