diff --git a/server/cluster/cluster_test.go b/server/cluster/cluster_test.go index d3da21ab3ddf..ddf27f5c352f 100644 --- a/server/cluster/cluster_test.go +++ b/server/cluster/cluster_test.go @@ -3476,10 +3476,14 @@ func TestStoreOverloadedWithReplace(t *testing.T) { re.False(oc.AddOperator(op3)) ops, _ := lb.Schedule(tc, false /* dryRun */) re.Empty(ops) - // sleep 2 seconds to make sure that token is filled up - time.Sleep(2 * time.Second) - ops, _ = lb.Schedule(tc, false /* dryRun */) - re.NotEmpty(ops) + // make sure that token is filled up + testutil.Eventually(re, func() bool { + ops, _ = lb.Schedule(tc, false /* dryRun */) + if len(ops) == 0 { + return false + } + return true + }) } func TestDownStoreLimit(t *testing.T) {