fix(tests): replace flaky sleep with retry loop in SubscriptionIndexTests

Use a 2-second deadline retry loop instead of fixed Thread.Sleep(200)
for async cache sweep verification, mirroring the Go test pattern.
This commit is contained in:
Joseph Doherty
2026-02-28 18:44:05 -05:00
parent 9db4130d53
commit 0cc5d89199
2 changed files with 6 additions and 3 deletions

View File

@@ -360,8 +360,11 @@ public class SubscriptionIndexTests
for (int i = 0; i < 2 * SubscriptionIndex.SlCacheMax; i++)
s.Match($"foo-{i}");
// Cache sweep runs async, wait briefly.
Thread.Sleep(200);
// Cache sweep runs async; mirror Go test's retry window.
var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(2);
while (DateTime.UtcNow < deadline && s.CacheCount() > SubscriptionIndex.SlCacheMax)
Thread.Sleep(10);
s.CacheCount().ShouldBeLessThanOrEqualTo(SubscriptionIndex.SlCacheMax);
// Test wildcard cache update.

View File

@@ -1,6 +1,6 @@
# NATS .NET Porting Status Report
Generated: 2026-02-28 23:39:18 UTC
Generated: 2026-02-28 23:44:05 UTC
## Modules (12 total)