From 12a4c7c3a9577d25486412623c831d5ea34b6aa3 Mon Sep 17 00:00:00 2001 From: Charlie Le Date: Thu, 13 Feb 2025 15:02:52 -0800 Subject: [PATCH] Fix flaky ring consistency test Use 128 tokens instead of 10,000. Use ringDesc when generating testValues and creating a ring of ingesters. Fixes: https://github.com/cortexproject/cortex/issues/6513 Related: https://github.com/cortexproject/cortex/pull/6535 Signed-off-by: Charlie Le --- pkg/ring/ring_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/ring/ring_test.go b/pkg/ring/ring_test.go index ff51e9a4e6c..e2f7e0a8d1c 100644 --- a/pkg/ring/ring_test.go +++ b/pkg/ring/ring_test.go @@ -574,8 +574,6 @@ func TestRing_Get_Stability(t *testing.T) { } func TestRing_Get_Consistency(t *testing.T) { - // Number of tests to run. - const testCount = 10000 g := NewRandomTokenGenerator() tests := map[string]struct { @@ -686,10 +684,10 @@ func TestRing_Get_Consistency(t *testing.T) { for testName, testData := range tests { t.Run(testName, func(t *testing.T) { - testValues := g.GenerateTokens(NewDesc(), "", "", testCount, true) + ringDesc := &Desc{Ingesters: generateRingInstances(testData.initialInstances, testData.numZones, 128)} + testValues := g.GenerateTokens(ringDesc, "", "", 128, true) bufDescs, bufHosts, bufZones := MakeBuffersForGet() - for i := 0; i < testCount; i++ { - ringDesc := &Desc{Ingesters: generateRingInstances(testData.initialInstances, testData.numZones, 128)} + for i := 0; i < 128; i++ { ring := Ring{ cfg: Config{ HeartbeatTimeout: time.Hour,