mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-26 01:53:09 +00:00
Remove unused collectGaugeCount, assert surviving label values
Remove the unused collectGaugeCount helper and assert specific label values survive after each deletion using testutil.ToFloat64. Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
This commit is contained in:
@@ -473,27 +473,17 @@ func TestDeleteBackupLastSuccessfulTimestamp(t *testing.T) {
|
||||
|
||||
m.DeleteBackupLastSuccessfulTimestamp("schedule-1")
|
||||
assert.Equal(t, 2, testutil.CollectAndCount(g))
|
||||
assert.Equal(t, float64(now.Add(-time.Hour).Unix()), testutil.ToFloat64(g.WithLabelValues("schedule-2")))
|
||||
assert.Equal(t, float64(now.Add(-2*time.Hour).Unix()), testutil.ToFloat64(g.WithLabelValues("")))
|
||||
|
||||
m.DeleteBackupLastSuccessfulTimestamp("schedule-2")
|
||||
assert.Equal(t, 1, testutil.CollectAndCount(g))
|
||||
assert.Equal(t, float64(now.Add(-2*time.Hour).Unix()), testutil.ToFloat64(g.WithLabelValues("")))
|
||||
|
||||
m.DeleteBackupLastSuccessfulTimestamp("")
|
||||
assert.Equal(t, 0, testutil.CollectAndCount(g))
|
||||
}
|
||||
|
||||
// collectGaugeCount returns the number of time series in a GaugeVec.
|
||||
func collectGaugeCount(t *testing.T, g *prometheus.GaugeVec) int {
|
||||
t.Helper()
|
||||
ch := make(chan prometheus.Metric, 10)
|
||||
g.Collect(ch)
|
||||
close(ch)
|
||||
count := 0
|
||||
for range ch {
|
||||
count++
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// TestRepoMaintenanceMetrics verifies that repo maintenance metrics are properly recorded.
|
||||
func TestRepoMaintenanceMetrics(t *testing.T) {
|
||||
tests := []struct {
|
||||
|
||||
Reference in New Issue
Block a user