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:
Ivan Kozlovic
2018-08-27 15:01:38 -06:00
parent c926b56d1f
commit 156224a85b

View File

@@ -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()