From cac1f2727e6975d6bb7426898c97916faa91bdaa Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 16 May 2024 13:10:49 -0700 Subject: [PATCH] [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 94586faced27ac4e0af8fda685cd154afeae1ba7 PiperOrigin-RevId: 634505085 --- test/core/channelz/channel_trace_test.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/core/channelz/channel_trace_test.cc b/test/core/channelz/channel_trace_test.cc index 59adb4fefda..6f99e22b38c 100644 --- a/test/core/channelz/channel_trace_test.cc +++ b/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> 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,