feat: complete jetstream deep operational parity closure

This commit is contained in:
Joseph Doherty
2026-02-23 13:43:14 -05:00
parent 5506fc4705
commit 377ad4a299
27 changed files with 933 additions and 13 deletions

View File

@@ -0,0 +1,31 @@
using NATS.Server.JetStream;
using NATS.Server.JetStream.Models;
using NATS.Server.JetStream.Publish;
namespace NATS.Server.Tests;
public class JetStreamDedupeWindowParityTests
{
[Fact]
public async Task Dedupe_window_expires_entries_and_allows_republish_after_window_boundary()
{
var streamManager = new StreamManager();
streamManager.CreateOrUpdate(new StreamConfig
{
Name = "D",
Subjects = ["d.*"],
DuplicateWindowMs = 25,
}).Error.ShouldBeNull();
var publisher = new JetStreamPublisher(streamManager);
publisher.TryCaptureWithOptions("d.1", "one"u8.ToArray(), new PublishOptions { MsgId = "m-1" }, out var first).ShouldBeTrue();
publisher.TryCaptureWithOptions("d.1", "dup"u8.ToArray(), new PublishOptions { MsgId = "m-1" }, out var second).ShouldBeTrue();
second.Seq.ShouldBe(first.Seq);
await Task.Delay(40);
publisher.TryCaptureWithOptions("d.1", "after-window"u8.ToArray(), new PublishOptions { MsgId = "m-1" }, out var third).ShouldBeTrue();
third.ErrorCode.ShouldBeNull();
third.Seq.ShouldBeGreaterThan(first.Seq);
}
}