From c240fdf085ce24c6110a6764e8b9657a3788abfe Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Thu, 31 Oct 2024 18:23:27 +0800 Subject: [PATCH] *: avoid flaky test with high load scenario (#57016) --- pkg/statistics/handle/cache/internal/lfu/lfu_cache_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/statistics/handle/cache/internal/lfu/lfu_cache_test.go b/pkg/statistics/handle/cache/internal/lfu/lfu_cache_test.go index e0d660ba653ba..be5ba7f94feba 100644 --- a/pkg/statistics/handle/cache/internal/lfu/lfu_cache_test.go +++ b/pkg/statistics/handle/cache/internal/lfu/lfu_cache_test.go @@ -310,6 +310,7 @@ func TestMemoryControlWithUpdate(t *testing.T) { t1 := testutil.NewMockStatisticsTable(i, 1, true, false, false) lfu.Put(1, t1) } - time.Sleep(1 * time.Second) - require.Equal(t, int64(0), lfu.Cost()) + require.Eventually(t, func() bool { + return int64(0) == lfu.Cost() + }, 5*time.Second, 100*time.Millisecond) }