test(batch16): resolve route slow-consumer recover status with evidence

This commit is contained in:
Joseph Doherty
2026-02-28 19:01:57 -05:00
parent a0b0b45f5e
commit 1849780369
3 changed files with 30 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
using System.IO;
using Shouldly;
using ZB.MOM.NatsNet.Server;
using ZB.MOM.NatsNet.Server.Internal;
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
@@ -74,4 +76,27 @@ public sealed partial class RouteHandlerTests
errors.ShouldBeEmpty();
options.Cluster.Compression.Mode.ShouldBe(CompressionModes.Off);
}
[Fact] // T:2859
public void RouteSlowConsumerRecover_ShouldSucceed()
{
var (server, err) = NatsServer.NewServer(new ServerOptions());
err.ShouldBeNull();
using var outStream = new MemoryStream();
var route = new ClientConnection(ClientKind.Router, server, outStream)
{
OutWtp = WriteTimeoutPolicy.Retry,
OutMp = 1024 * 1024,
};
// Detect slow consumer state from write-timeout path.
route.HandleWriteTimeout(written: 1, attempted: 1024, numChunks: 2).ShouldBeFalse();
route.Flags.IsSet(ClientFlags.IsSlowConsumer).ShouldBeTrue();
// A successful flush should clear slow-consumer marker (recovered).
route.QueueOutbound("MSG test 1 5\r\nhello\r\n"u8.ToArray());
route.FlushOutbound().ShouldBeTrue();
route.Flags.IsSet(ClientFlags.IsSlowConsumer).ShouldBeFalse();
}
}