feat(batch14): complete filestore write lifecycle features and tests

This commit is contained in:
Joseph Doherty
2026-02-28 16:41:31 -05:00
parent 045faf7423
commit 5367c3f34d
9 changed files with 1596 additions and 39 deletions

View File

@@ -0,0 +1,74 @@
using Shouldly;
using ZB.MOM.NatsNet.Server;
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
public sealed partial class LeafNodeHandlerTests
{
[Fact] // T:1984
public void LeafNodeCompressionAuto_ShouldSucceed()
{
var options = new ServerOptions();
var errors = new List<Exception>();
var warnings = new List<Exception>();
var parseError = ServerOptions.ParseLeafNodes(
new Dictionary<string, object?>
{
["remotes"] = new List<object?>
{
new Dictionary<string, object?>
{
["url"] = "nats://127.0.0.1:7422",
["compression"] = new Dictionary<string, object?>
{
["mode"] = CompressionModes.S2Auto,
["rtt_thresholds"] = new List<object?> { "10ms", "20ms", "30ms" },
},
},
},
},
options,
errors,
warnings);
parseError.ShouldBeNull();
errors.ShouldBeEmpty();
options.LeafNode.Remotes.Count.ShouldBe(1);
options.LeafNode.Remotes[0].Compression.Mode.ShouldBe(CompressionModes.S2Auto);
options.LeafNode.Remotes[0].Compression.RttThresholds.Count.ShouldBe(3);
options.LeafNode.Remotes[0].Compression.RttThresholds[0].ShouldBe(TimeSpan.FromMilliseconds(10));
options.LeafNode.Remotes[0].Compression.RttThresholds[1].ShouldBe(TimeSpan.FromMilliseconds(20));
options.LeafNode.Remotes[0].Compression.RttThresholds[2].ShouldBe(TimeSpan.FromMilliseconds(30));
}
[Fact] // T:2001
public void LeafNodeConnectionSucceedsEvenWithDelayedFirstINFO_ShouldSucceed()
{
var errors = new List<Exception>();
var warnings = new List<Exception>();
var remotes = ServerOptions.ParseRemoteLeafNodes(
new List<object?>
{
new Dictionary<string, object?>
{
["url"] = "nats://127.0.0.1:7422",
["first_info_timeout"] = "3s",
},
new Dictionary<string, object?>
{
["url"] = "ws://127.0.0.1:7423",
["first_info_timeout"] = "3s",
},
},
errors,
warnings);
errors.ShouldBeEmpty();
remotes.Count.ShouldBe(2);
remotes[0].FirstInfoTimeout.ShouldBe(TimeSpan.FromSeconds(3));
remotes[1].FirstInfoTimeout.ShouldBe(TimeSpan.FromSeconds(3));
remotes[1].Urls[0].Scheme.ShouldBe("ws");
}
}