From 6a3b4b469e1822537598fbfc781ad65e9a903b4b Mon Sep 17 00:00:00 2001 From: Charlie Le Date: Sun, 27 Oct 2024 11:10:14 -0700 Subject: [PATCH] fix flaky test Signed-off-by: Charlie Le --- pkg/ingester/ingester_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/ingester/ingester_test.go b/pkg/ingester/ingester_test.go index 86434beb4f..1ee6b41b1a 100644 --- a/pkg/ingester/ingester_test.go +++ b/pkg/ingester/ingester_test.go @@ -5315,12 +5315,14 @@ func Test_Ingester_ModeHandler(t *testing.T) { require.Equal(t, testData.expectedResponse, response.Code) require.Equal(t, testData.expectedState, i.lifecycler.GetState()) - - err = i.CheckReady(context.Background()) if testData.expectedIsReady { - require.NoError(t, err) + // Wait for instance to own tokens + test.Poll(t, 1*time.Second, nil, func() interface{} { + return i.CheckReady(context.Background()) + }) + require.NoError(t, i.CheckReady(context.Background())) } else { - require.NotNil(t, err) + require.NotNil(t, i.CheckReady(context.Background())) } }) }