feat(batch24): complete leaf nodes implementation and verification
This commit is contained in:
@@ -171,4 +171,22 @@ public sealed partial class LeafNodeHandlerTests
|
||||
((INatsAccount)account).RemoveClient(leaf);
|
||||
account.NumLocalLeafNodes().ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact] // T:1966
|
||||
public void LeafNodeRoutedSubKeyDifferentBetweenLeafSubAndRoutedSub_ShouldSucceed()
|
||||
{
|
||||
var plain = new Subscription { Subject = "foo"u8.ToArray() };
|
||||
var queue = new Subscription { Subject = "XYZ"u8.ToArray(), Queue = "foo"u8.ToArray() };
|
||||
|
||||
var routedPlain = LeafNodeHandler.KeyFromSubWithOrigin(plain);
|
||||
var routedQueue = LeafNodeHandler.KeyFromSubWithOrigin(queue);
|
||||
var leafPlain = LeafNodeHandler.KeyFromSubWithOrigin(plain, "XYZ");
|
||||
var leafQueue = LeafNodeHandler.KeyFromSubWithOrigin(queue, "XYZ");
|
||||
|
||||
routedPlain.ShouldNotBe(routedQueue);
|
||||
routedQueue.ShouldNotBe(leafPlain);
|
||||
leafPlain.ShouldNotBe(leafQueue);
|
||||
routedPlain.ShouldNotBe(leafPlain);
|
||||
routedQueue.ShouldNotBe(leafQueue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,4 +204,31 @@ public sealed partial class RouteHandlerTests
|
||||
public Task<string[]> LookupHostAsync(string host, CancellationToken ct = default)
|
||||
=> Task.FromResult(hosts);
|
||||
}
|
||||
|
||||
[Fact] // T:2825
|
||||
public void ClusterQueueGroupWeightTrackingLeak_ShouldSucceed()
|
||||
{
|
||||
var account = Account.NewAccount("$G");
|
||||
var queueSub = new Subscription
|
||||
{
|
||||
Subject = "foo"u8.ToArray(),
|
||||
Queue = "bar"u8.ToArray(),
|
||||
Qw = 1,
|
||||
};
|
||||
|
||||
account.UpdateLeafNodes(queueSub, 1);
|
||||
|
||||
var lqwsField = typeof(Account).GetField("_lqws", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
|
||||
lqwsField.ShouldNotBeNull();
|
||||
|
||||
var lqws = (Dictionary<string, int>?)lqwsField!.GetValue(account);
|
||||
lqws.ShouldNotBeNull();
|
||||
lqws!.TryGetValue("foo bar", out var initialWeight).ShouldBeTrue();
|
||||
initialWeight.ShouldBe(1);
|
||||
|
||||
account.UpdateLeafNodes(queueSub, -1);
|
||||
|
||||
lqws = (Dictionary<string, int>?)lqwsField.GetValue(account);
|
||||
(lqws?.ContainsKey("foo bar") ?? false).ShouldBeFalse();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user