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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user