refactor: rename remaining tests to NATS.Server.Core.Tests
- Rename tests/NATS.Server.Tests -> tests/NATS.Server.Core.Tests - Update solution file, InternalsVisibleTo, and csproj references - Remove JETSTREAM_INTEGRATION_MATRIX and NATS.NKeys from csproj (moved to JetStream.Tests and Auth.Tests) - Update all namespaces from NATS.Server.Tests.* to NATS.Server.Core.Tests.* - Replace private GetFreePort/ReadUntilAsync helpers with TestUtilities calls - Fix stale namespace in Transport.Tests/NetworkingGoParityTests.cs
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using NATS.Server.Subscriptions;
|
||||
|
||||
namespace NATS.Server.Core.Tests;
|
||||
|
||||
public class SubListAsyncCacheSweepTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Cache_sweep_runs_async_and_prunes_stale_entries_without_write_locking_match_path()
|
||||
{
|
||||
using var sl = new SubList();
|
||||
sl.Insert(new Subscription { Subject = ">", Sid = "all" });
|
||||
|
||||
for (var i = 0; i < 1500; i++)
|
||||
_ = sl.Match($"orders.{i}");
|
||||
|
||||
var initial = sl.CacheCount;
|
||||
initial.ShouldBeGreaterThan(1024);
|
||||
|
||||
await sl.TriggerCacheSweepAsyncForTest();
|
||||
sl.CacheCount.ShouldBeLessThan(initial);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using NATS.Server.Subscriptions;
|
||||
|
||||
namespace NATS.Server.Core.Tests;
|
||||
|
||||
public class SubListHighFanoutOptimizationTests
|
||||
{
|
||||
[Fact]
|
||||
public void High_fanout_nodes_enable_packed_list_optimization()
|
||||
{
|
||||
using var sl = new SubList();
|
||||
for (var i = 0; i < 300; i++)
|
||||
{
|
||||
sl.Insert(new Subscription
|
||||
{
|
||||
Subject = "orders.created",
|
||||
Sid = i.ToString(),
|
||||
});
|
||||
}
|
||||
|
||||
sl.HighFanoutNodeCountForTest.ShouldBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using NATS.Server.Subscriptions;
|
||||
|
||||
namespace NATS.Server.Core.Tests;
|
||||
|
||||
public class SubListMatchBytesTests
|
||||
{
|
||||
[Fact]
|
||||
public void MatchBytes_matches_subject_without_string_allocation_and_respects_remote_filter()
|
||||
{
|
||||
using var sl = new SubList();
|
||||
sl.MatchBytes("orders.created"u8).PlainSubs.Length.ShouldBe(0);
|
||||
|
||||
sl.Insert(new Subscription { Subject = "orders.*", Sid = "1" });
|
||||
sl.MatchBytes("orders.created"u8).PlainSubs.Length.ShouldBe(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using NATS.Server.Subscriptions;
|
||||
|
||||
namespace NATS.Server.Core.Tests;
|
||||
|
||||
public class SubListNotificationTests
|
||||
{
|
||||
[Fact]
|
||||
public void Interest_change_notifications_are_emitted_for_local_and_remote_changes()
|
||||
{
|
||||
using var sl = new SubList();
|
||||
var changes = new List<InterestChange>();
|
||||
sl.InterestChanged += changes.Add;
|
||||
|
||||
var sub = new Subscription { Subject = "orders.created", Sid = "1" };
|
||||
sl.Insert(sub);
|
||||
sl.Remove(sub);
|
||||
sl.ApplyRemoteSub(new RemoteSubscription("orders.*", null, "r1", "A"));
|
||||
sl.ApplyRemoteSub(RemoteSubscription.Removal("orders.*", null, "r1", "A"));
|
||||
|
||||
changes.Count.ShouldBe(4);
|
||||
changes.Select(c => c.Kind).ShouldContain(InterestChangeKind.LocalAdded);
|
||||
changes.Select(c => c.Kind).ShouldContain(InterestChangeKind.RemoteAdded);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using NATS.Server.Subscriptions;
|
||||
|
||||
namespace NATS.Server.Core.Tests;
|
||||
|
||||
public class SubListQueueWeightTests
|
||||
{
|
||||
[Fact]
|
||||
public void Remote_queue_weight_expands_matches()
|
||||
{
|
||||
using var sl = new SubList();
|
||||
sl.ApplyRemoteSub(new RemoteSubscription("orders.*", "q", "r1", "A", QueueWeight: 3));
|
||||
|
||||
var matches = sl.MatchRemote("A", "orders.created");
|
||||
matches.Count.ShouldBe(3);
|
||||
matches.ShouldAllBe(m => m.Queue == "q");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using NATS.Server.Subscriptions;
|
||||
|
||||
namespace NATS.Server.Core.Tests;
|
||||
|
||||
public class SubListRemoteFilterTests
|
||||
{
|
||||
[Fact]
|
||||
public void Match_remote_filters_by_account_and_subject()
|
||||
{
|
||||
using var sl = new SubList();
|
||||
sl.ApplyRemoteSub(new RemoteSubscription("orders.*", null, "r1", "A"));
|
||||
sl.ApplyRemoteSub(new RemoteSubscription("orders.*", null, "r2", "B"));
|
||||
|
||||
var aMatches = sl.MatchRemote("A", "orders.created");
|
||||
aMatches.Count.ShouldBe(1);
|
||||
aMatches[0].Account.ShouldBe("A");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user