[channel trace test] fix Windows portability tests (#36643)

This fixes breakage triggered by #36434.

Changing the order of the data members in `TraceEvent` caused the total size of the structure to be different, which meant that the long string we were adding was enough to cause 3 events to be evicted instead of 2.

b/339066599

Closes #36643

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36643 from markdroth:channel_trace_test_fix 94586faced
PiperOrigin-RevId: 634505085
pull/36642/head
Mark D. Roth 7 months ago committed by Copybara-Service
parent 271b2f17e2
commit cac1f2727e
  1. 12
      test/core/channelz/channel_trace_test.cc

@ -321,7 +321,7 @@ TEST(ChannelTracerTest, TestEviction) {
TEST(ChannelTracerTest, TestMultipleEviction) {
ExecCtx exec_ctx;
const int kTraceEventSize = GetSizeofTraceEvent();
const size_t kTraceEventSize = GetSizeofTraceEvent();
const int kNumEvents = 5;
ChannelTrace tracer(kTraceEventSize * kNumEvents);
std::list<::testing::Matcher<Json>> matchers;
@ -337,14 +337,12 @@ TEST(ChannelTracerTest, TestMultipleEviction) {
// At this point the list is full, and each subsequent enntry will cause an
// eviction. We will now add in a trace event that has a copied string. This
// uses more memory, so it will cause a double eviciction.
tracer.AddTraceEvent(
ChannelTrace::Severity::Info,
grpc_slice_from_copied_string(
"long enough string to trigger a multiple eviction"));
std::string msg(GRPC_SLICE_INLINED_SIZE + 1, 'x');
tracer.AddTraceEvent(ChannelTrace::Severity::Info,
grpc_slice_from_cpp_string(msg));
matchers.pop_front();
matchers.pop_front();
matchers.push_back(IsTraceEvent(
"long enough string to trigger a multiple eviction", "CT_INFO"));
matchers.push_back(IsTraceEvent(msg, "CT_INFO"));
Json json = tracer.RenderJson();
ValidateJsonProtoTranslation(json);
EXPECT_THAT(json, IsChannelTrace(kNumEvents + 1,

Loading…
Cancel
Save