feat: complete remaining jetstream parity implementation plan

This commit is contained in:
Joseph Doherty
2026-02-23 10:16:16 -05:00
parent c7bbf45c8f
commit f46b331921
59 changed files with 1734 additions and 54 deletions

View File

@@ -0,0 +1,50 @@
namespace NATS.Server.Tests;
internal static class JetStreamIntegrationMatrix
{
public static async Task<(bool Success, string Details)> RunScenarioAsync(string scenario)
{
try
{
return scenario switch
{
"stream-msg-delete-roundtrip" => await StreamMsgDeleteRoundtripAsync(),
"consumer-msg-next-no-wait" => await ConsumerNextNoWaitAsync(),
"direct-get-by-sequence" => await DirectGetBySequenceAsync(),
_ => (false, $"unknown scenario: {scenario}"),
};
}
catch (Exception ex)
{
return (false, ex.Message);
}
}
private static async Task<(bool Success, string Details)> StreamMsgDeleteRoundtripAsync()
{
await using var fx = await JetStreamApiFixture.StartWithStreamAsync("ORDERS", "orders.*");
var ack = await fx.PublishAndGetAckAsync("orders.created", "1");
var del = await fx.RequestLocalAsync("$JS.API.STREAM.MSG.DELETE.ORDERS", $"{{\"seq\":{ack.Seq}}}");
if (!del.Success)
return (false, "stream msg delete did not return success");
var get = await fx.RequestLocalAsync("$JS.API.STREAM.MSG.GET.ORDERS", $"{{\"seq\":{ack.Seq}}}");
return (get.Error != null, get.Error == null ? "deleted message was still retrievable" : string.Empty);
}
private static async Task<(bool Success, string Details)> ConsumerNextNoWaitAsync()
{
await using var fx = await JetStreamApiFixture.StartWithPullConsumerAsync();
var batch = await fx.FetchWithNoWaitAsync("ORDERS", "PULL", 1);
return (batch.Messages.Count == 0 && !batch.TimedOut, batch.Messages.Count == 0 ? "batch timed out unexpectedly" : "expected empty pull batch");
}
private static async Task<(bool Success, string Details)> DirectGetBySequenceAsync()
{
await using var fx = await JetStreamApiFixture.StartWithStreamAsync("ORDERS", "orders.*");
var ack = await fx.PublishAndGetAckAsync("orders.created", "1");
var direct = await fx.RequestLocalAsync("$JS.API.DIRECT.GET.ORDERS", $"{{\"seq\":{ack.Seq}}}");
return (direct.DirectMessage?.Payload == "1", direct.DirectMessage == null ? "direct message payload missing" : "unexpected direct message payload");
}
}