Skip to content

Commit 32bd46f

Browse files
authored
Fix flaky TestNewDistributorsCanPushToOldIngestersWithReplication test due SG not ready (#5975)
* Fixing Flaky integration test Signed-off-by: alanprot <[email protected]> * lint Signed-off-by: alanprot <[email protected]> * fix TestQuerierWithBlocksStorageRunningInMicroservicesMode Signed-off-by: alanprot <[email protected]> --------- Signed-off-by: alanprot <[email protected]>
1 parent 49ac825 commit 32bd46f

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

integration/backward_compatibility_test.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
"github.com/prometheus/common/model"
12+
"github.com/prometheus/prometheus/model/labels"
1213
"github.com/stretchr/testify/assert"
1314
"github.com/stretchr/testify/require"
1415

@@ -210,6 +211,14 @@ func checkQueries(
210211

211212
for name, c := range cases {
212213
t.Run(name, func(t *testing.T) {
214+
// Start store gateway.
215+
storeGateway := e2ecortex.NewStoreGateway("store-gateway", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), c.storeGatewayFlags, c.storeGatewayImage)
216+
217+
require.NoError(t, s.Start(storeGateway))
218+
defer func() {
219+
require.NoError(t, s.Stop(storeGateway))
220+
}()
221+
213222
// Start query-frontend.
214223
queryFrontend := e2ecortex.NewQueryFrontend("query-frontend", c.queryFrontendFlags, c.queryFrontendImage)
215224
require.NoError(t, s.Start(queryFrontend))
@@ -227,18 +236,22 @@ func checkQueries(
227236
require.NoError(t, s.Stop(querier))
228237
}()
229238

230-
// Start store gateway.
231-
storeGateway := e2ecortex.NewStoreGateway("store-gateway", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), c.storeGatewayFlags, c.storeGatewayImage)
232-
233-
require.NoError(t, s.Start(storeGateway))
234-
defer func() {
235-
require.NoError(t, s.Stop(storeGateway))
236-
}()
237-
238239
// Wait until querier and query-frontend are ready, and the querier has updated the ring.
239240
require.NoError(t, s.WaitReady(querier, queryFrontend, storeGateway))
240241
expectedTokens := float64((numIngesters + 1) * 512) // Ingesters and Store Gateway.
241242
require.NoError(t, querier.WaitSumMetrics(e2e.Equals(expectedTokens), "cortex_ring_tokens_total"))
243+
require.NoError(t, storeGateway.WaitSumMetrics(e2e.Greater(0), "cortex_storegateway_bucket_sync_total"))
244+
245+
// Wait store-gateways and ingesters appears on querier ring
246+
require.NoError(t, querier.WaitSumMetricsWithOptions(e2e.Equals(1), []string{"cortex_ring_members"}, e2e.WithLabelMatchers(
247+
labels.MustNewMatcher(labels.MatchEqual, "name", "store-gateway-client"),
248+
labels.MustNewMatcher(labels.MatchEqual, "state", "ACTIVE"),
249+
)))
250+
251+
require.NoError(t, querier.WaitSumMetricsWithOptions(e2e.Greater(0), []string{"cortex_ring_members"}, e2e.WithLabelMatchers(
252+
labels.MustNewMatcher(labels.MatchEqual, "name", "ingester"),
253+
labels.MustNewMatcher(labels.MatchEqual, "state", "ACTIVE"),
254+
)))
242255

243256
// Query the series.
244257
for _, endpoint := range []string{queryFrontend.HTTPEndpoint(), querier.HTTPEndpoint()} {

integration/querier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
217217
require.NoError(t, s.StartAndWaitReady(compactor))
218218
} else {
219219
// Wait until the querier has discovered the uploaded blocks.
220-
require.NoError(t, querier.WaitSumMetrics(e2e.Equals(2), "cortex_blocks_meta_synced"))
220+
require.NoError(t, querier.WaitSumMetricsWithOptions(e2e.Equals(2), []string{"cortex_blocks_meta_synced"}, e2e.WaitMissingMetrics))
221221
}
222222

223223
// Wait until the store-gateway has synched the new uploaded blocks. When sharding is enabled

0 commit comments

Comments
 (0)