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 */