Skip to content

Commit

Permalink
update usage of testutil.GatherAndCompare
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Le <[email protected]>
  • Loading branch information
CharlieTLe committed Oct 27, 2024
1 parent ef5a2ea commit d711e1b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,7 @@ func TestDistributor_MetricsCleanup(t *testing.T) {
cortex_distributor_ingester_query_failures_total{ingester="ingester-1"} 1
`), permanentMetrics...))

err = testutil.GatherAndCompare(reg, strings.NewReader(""), removedMetrics...)
require.ErrorContains(t, err, "expected metric name(s) not found")
require.ErrorContains(t, err, strings.Join(removedMetrics, " "))
require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(""), removedMetrics...))
}

func TestDistributor_PushIngestionRateLimiter(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/v1/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func TestFrontendMetricsCleanup(t *testing.T) {

fr.cleanupInactiveUserMetrics("1")

require.ErrorContains(t, testutil.GatherAndCompare(reg, strings.NewReader(""), "cortex_query_frontend_queue_length"), "expected metric name(s) not found")
require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(""), "cortex_query_frontend_queue_length"))
}

testFrontend(t, defaultFrontendConfig(), handler, test, matchMaxConcurrency, nil, reg)
Expand Down
4 changes: 1 addition & 3 deletions pkg/ingester/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4512,9 +4512,7 @@ func TestIngesterCompactAndCloseIdleTSDB(t *testing.T) {
require.Equal(t, int64(0), i.TSDBState.seriesCount.Load()) // Flushing removed all series from memory.

// Verify that user has disappeared from metrics.
err = testutil.GatherAndCompare(r, strings.NewReader(""), userMetrics...)
require.ErrorContains(t, err, "expected metric name(s) not found")
require.ErrorContains(t, err, strings.Join(userMetrics, " "))
require.NoError(t, testutil.GatherAndCompare(r, strings.NewReader(""), userMetrics...))

require.NoError(t, testutil.GatherAndCompare(r, strings.NewReader(`
# HELP cortex_ingester_memory_users The current number of users in memory.
Expand Down

0 comments on commit d711e1b

Please sign in to comment.