Skip to content

Commit 102125c

Browse files
committed
More test assert fixes
Follow up to prometheus/client_golang#1424 Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
1 parent fa0d03b commit 102125c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/compactor/blocks_cleaner_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,7 @@ func TestBlocksCleaner_ShouldNotCleanupUserThatDoesntBelongToShardAnymore(t *tes
464464
require.ElementsMatch(t, []string{"user-1", "user-2"}, cleaner.lastOwnedUsers)
465465

466466
// But there are no metrics for any user, because we did not in fact clean them.
467-
assert.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
468-
# HELP cortex_bucket_blocks_count Total number of blocks in the bucket. Includes blocks marked for deletion, but not partial blocks.
469-
# TYPE cortex_bucket_blocks_count gauge
470-
`),
471-
"cortex_bucket_blocks_count",
472-
))
467+
assert.ErrorContains(t, testutil.GatherAndCompare(reg, strings.NewReader(""), "cortex_bucket_blocks_count"), "expected metric name(s) not found")
473468

474469
// Running cleanUsers again will see that users are no longer owned.
475470
require.NoError(t, cleaner.runCleanupWithErr(ctx))

pkg/compactor/compactor_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,6 @@ func TestMultitenantCompactor_ShouldNotCompactBlocksForUsersMarkedForDeletion(t
965965
"cortex_compactor_runs_started_total", "cortex_compactor_runs_completed_total", "cortex_compactor_runs_failed_total",
966966
"cortex_compactor_blocks_cleaned_total", "cortex_compactor_block_cleanup_failures_total", "cortex_compactor_blocks_marked_for_deletion_total",
967967
"cortex_compactor_block_cleanup_started_total", "cortex_compactor_block_cleanup_completed_total", "cortex_compactor_block_cleanup_failed_total",
968-
"cortex_bucket_blocks_count", "cortex_bucket_blocks_marked_for_deletion_count", "cortex_bucket_index_last_successful_update_timestamp_seconds",
969968
}
970969
assert.NoError(t, prom_testutil.GatherAndCompare(registry, strings.NewReader(`
971970
# TYPE cortex_compactor_runs_started_total counter
@@ -1007,6 +1006,12 @@ func TestMultitenantCompactor_ShouldNotCompactBlocksForUsersMarkedForDeletion(t
10071006
# HELP cortex_compactor_block_cleanup_failed_total Total number of blocks cleanup runs failed.
10081007
cortex_compactor_block_cleanup_failed_total 0
10091008
`), testedMetrics...))
1009+
assert.ErrorContains(t, prom_testutil.GatherAndCompare(registry, strings.NewReader(""),
1010+
"cortex_bucket_blocks_count",
1011+
"cortex_bucket_blocks_marked_for_deletion_count",
1012+
"cortex_bucket_index_last_successful_update_timestamp_seconds"),
1013+
"expected metric name(s) not found",
1014+
)
10101015
}
10111016

10121017
func TestMultitenantCompactor_ShouldCompactAllUsersOnShardingEnabledButOnlyOneInstanceRunning(t *testing.T) {

0 commit comments

Comments
 (0)