mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
Fix sublist cache flapping test
Use `checkFor` to ensure that cache size is ok. Repeated test 1000 times and no failure now. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -313,12 +313,12 @@ func TestSublistCache(t *testing.T) {
|
||||
s.Match(fmt.Sprintf("foo-%d\n", i))
|
||||
}
|
||||
|
||||
// Let cleanup Go routine run.
|
||||
runtime.Gosched()
|
||||
|
||||
if cc := s.CacheCount(); cc > slCacheMax {
|
||||
t.Fatalf("Cache should be constrained by cacheMax, got %d for current count\n", cc)
|
||||
}
|
||||
checkFor(t, 2*time.Second, 10*time.Millisecond, func() error {
|
||||
if cc := s.CacheCount(); cc > slCacheMax {
|
||||
return fmt.Errorf("Cache should be constrained by cacheMax, got %d for current count", cc)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
// Test that adding to a wildcard properly adds to the cache.
|
||||
s = NewSublist()
|
||||
|
||||
Reference in New Issue
Block a user