Skip to content

Commit fdb1106

Browse files
Tyler Reidpracucci
andauthored
Fix flakey MaxChunkBytesPerQueryLimit test (#4258)
* Add replication factor flag to the prepConfig Struct. Use replication factor 2 in TestDistributor_QueryStream_ShouldReturnErrorIfMaxChunkBytesPerQueryLimitIsReached test to make the test stable Signed-off-by: Tyler Reid <[email protected]> * Add comment to explain replication factor default. Signed-off-by: Tyler Reid <[email protected]> * Update comment pkg/distributor/distributor_test.go Co-authored-by: Marco Pracucci <[email protected]> Signed-off-by: Tyler Reid <[email protected]> Co-authored-by: Marco Pracucci <[email protected]>
1 parent 5b70304 commit fdb1106

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

pkg/distributor/distributor_test.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,12 +1012,15 @@ func TestDistributor_QueryStream_ShouldReturnErrorIfMaxChunkBytesPerQueryLimitIs
10121012
flagext.DefaultValues(limits)
10131013

10141014
// Prepare distributors.
1015+
// Use replication factor of 2 to always read all the chunks from both ingesters,
1016+
// this guarantees us to always read the same chunks and have a stable test.
10151017
ds, _, r, _ := prepare(t, prepConfig{
1016-
numIngesters: 3,
1017-
happyIngesters: 3,
1018-
numDistributors: 1,
1019-
shardByAllLabels: true,
1020-
limits: limits,
1018+
numIngesters: 2,
1019+
happyIngesters: 2,
1020+
numDistributors: 1,
1021+
shardByAllLabels: true,
1022+
limits: limits,
1023+
replicationFactor: 2,
10211024
})
10221025
defer stopAll(ds, r)
10231026

@@ -1893,6 +1896,7 @@ type prepConfig struct {
18931896
skipLabelNameValidation bool
18941897
maxInflightRequests int
18951898
maxIngestionRate float64
1899+
replicationFactor int
18961900
}
18971901

18981902
func prepare(t *testing.T, cfg prepConfig) ([]*Distributor, []mockIngester, *ring.Ring, []*prometheus.Registry) {
@@ -1935,12 +1939,18 @@ func prepare(t *testing.T, cfg prepConfig) ([]*Distributor, []mockIngester, *rin
19351939
)
19361940
require.NoError(t, err)
19371941

1942+
// Use a default replication factor of 3 if there isn't a provided replication factor.
1943+
rf := cfg.replicationFactor
1944+
if rf == 0 {
1945+
rf = 3
1946+
}
1947+
19381948
ingestersRing, err := ring.New(ring.Config{
19391949
KVStore: kv.Config{
19401950
Mock: kvStore,
19411951
},
19421952
HeartbeatTimeout: 60 * time.Minute,
1943-
ReplicationFactor: 3,
1953+
ReplicationFactor: rf,
19441954
}, ring.IngesterRingKey, ring.IngesterRingKey, nil)
19451955
require.NoError(t, err)
19461956
require.NoError(t, services.StartAndAwaitRunning(context.Background(), ingestersRing))

0 commit comments

Comments
 (0)