From 7c2eaf09e2d5117b94089b8d92314b1e0f9bbad2 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 7 Aug 2026 06:25:15 -0400 Subject: [PATCH] test(WRK-21): size the byte-heavy drain fixture for the pipe harness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PipePair has no continuous read pump — the test thread drains the pipe only while it sits in ReadUntilAsync — so multi-megabyte DrainEvents frames interleaved with the heartbeat loop wedge both ends inside FlushFileBuffers, each waiting for the other to read. Negotiate a 128 KiB frame maximum instead: the 10,000 byte-heavy events still overflow it many times over, so every assertion (bounded reply, reported truncation, no event loss across repeated drains, surviving session) is unchanged. --- .../Ipc/WorkerPipeSessionTests.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ZB.MOM.WW.MxGateway.Worker.Tests/Ipc/WorkerPipeSessionTests.cs b/src/ZB.MOM.WW.MxGateway.Worker.Tests/Ipc/WorkerPipeSessionTests.cs index 65e8468..56fe252 100644 --- a/src/ZB.MOM.WW.MxGateway.Worker.Tests/Ipc/WorkerPipeSessionTests.cs +++ b/src/ZB.MOM.WW.MxGateway.Worker.Tests/Ipc/WorkerPipeSessionTests.cs @@ -20,12 +20,17 @@ public sealed class WorkerPipeSessionTests private const string Nonce = "nonce-secret"; // Byte-heavy drain fixture (WRK-21). 10,000 events at ~1.7 KiB each is ~17 MB of queue — far - // more than one frame — so DrainEvents must split across replies. The negotiated frame maximum - // is deliberately smaller than the compile-time default so the split happens in a handful of - // multi-MB frames instead of moving 17 MB through the test pipe. + // more than one frame — so DrainEvents must split across replies. + // + // The negotiated frame maximum is deliberately small. What is under test is the byte cap, and + // it behaves identically at any frame size, but this harness is not the production gateway: + // PipePair has no continuous read pump, so the test thread only drains the pipe while it sits + // in ReadUntilAsync. Multi-megabyte frames interleaved with the heartbeat loop can therefore + // wedge both ends inside FlushFileBuffers, each waiting for the other to read. A frame maximum + // well under the pipe buffer keeps the harness honest without weakening a single assertion. private const int ByteHeavyEventCount = 10_000; private const int ByteHeavyEventPayloadBytes = 1_800; - private const uint NegotiatedMaxFrameBytes = 2 * 1024 * 1024; + private const uint NegotiatedMaxFrameBytes = 128 * 1024; /// Verifies that valid gateway hello triggers worker hello and ready responses. /// A task that represents the asynchronous operation. @@ -611,7 +616,7 @@ public sealed class WorkerPipeSessionTests recovered.Add(drained.WorkerSequence); } - Assert.True(replyCount < 100, "DrainEvents made no progress across 100 replies."); + Assert.True(replyCount < 1_000, "DrainEvents made no progress across 1,000 replies."); } // More than one reply proves the drain really split; every event came back exactly once, in