From 939860eb8512817ca6ee890dc7bfbcf5ddff9c10 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 23 Jun 2020 14:41:59 +0100 Subject: [PATCH] vfs: vfscache make TestCacheCleaner test more reliable --- vfs/vfscache/cache_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vfs/vfscache/cache_test.go b/vfs/vfscache/cache_test.go index 5b7e86a85..8a728b9db 100644 --- a/vfs/vfscache/cache_test.go +++ b/vfs/vfscache/cache_test.go @@ -565,9 +565,14 @@ func TestCacheCleaner(t *testing.T) { assert.Equal(t, fmt.Sprintf("%p", potato), fmt.Sprintf("%p", potato2)) assert.True(t, found) - time.Sleep(10 * opt.CachePollInterval) + for i := 0; i < 100; i++ { + time.Sleep(10 * opt.CachePollInterval) + potato2, found = c.get("potato") + if !found { + break + } + } - potato2, found = c.get("potato") assert.NotEqual(t, fmt.Sprintf("%p", potato), fmt.Sprintf("%p", potato2)) assert.False(t, found) }