Skip to content

Commit

Permalink
Make read-write mode test robust to instance startup race condition. (g…
Browse files Browse the repository at this point in the history
…rafana#3447)

Without this change, the test occasionally fails due to errors like
"expanding series: empty ring" when querying for data.
  • Loading branch information
charleskorn authored and mason committed Dec 16, 2022
1 parent f61e2ce commit a83123e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions integration/read_write_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/grafana/e2e"
e2edb "github.com/grafana/e2e/db"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/prompb"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -40,6 +41,13 @@ func TestReadWriteMode(t *testing.T) {
c, err := e2emimir.NewClient(writeInstance.HTTPEndpoint(), readInstance.HTTPEndpoint(), "", "", "user-1")
require.NoError(t, err)

// Wait for the ingester to join the ring and become active - this prevents "empty ring" errors later when we try to query data.
require.NoError(t, readInstance.WaitSumMetricsWithOptions(
e2e.Equals(1),
[]string{"cortex_ring_members"},
e2e.WithLabelMatchers(labels.MustNewMatcher(labels.MatchEqual, "name", "ingester"), labels.MustNewMatcher(labels.MatchEqual, "state", "ACTIVE")),
))

// Push some data to the cluster.
now := time.Now()
series, expectedVector := generateSeries("test_series_1", now, prompb.Label{Name: "foo", Value: "bar"})
Expand Down

0 comments on commit a83123e

Please sign in to comment.