Skip to content

Commit d5e554b

Browse files
test: replace direct metric deletion check with registry gathering to verify label removal in tenant quota controller
Signed-off-by: Ankit Kr. Chowdhury <rakesh856100@gmail.com>
1 parent c17bdf8 commit d5e554b

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎internal/controller/tenantquota_controller_test.go‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
agentraxv1alpha1 "github.com/gitcommitankit/agentrax/api/v1alpha1"
3333
"github.com/gitcommitankit/agentrax/internal/observability"
3434
"github.com/prometheus/client_golang/prometheus/testutil"
35+
crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
3536
)
3637

3738
var _ = Describe("TenantQuota Controller", func() {
@@ -178,8 +179,22 @@ var _ = Describe("TenantQuota Controller", func() {
178179
}, timeout, interval).Should(BeTrue())
179180

180181
Eventually(func(g Gomega) {
181-
// DeleteLabelValues returns false when the series is already gone.
182-
g.Expect(observability.QuotaUsageRatio.DeleteLabelValues(tqNS)).To(BeFalse())
182+
mfs, err := crmetrics.Registry.Gather()
183+
g.Expect(err).NotTo(HaveOccurred())
184+
found := false
185+
for _, mf := range mfs {
186+
if mf.GetName() == "agentrax_tenant_quota_usage_ratio" {
187+
for _, m := range mf.GetMetric() {
188+
for _, lbl := range m.GetLabel() {
189+
if lbl.GetName() == "tenant" && lbl.GetValue() == tqNS {
190+
found = true
191+
break
192+
}
193+
}
194+
}
195+
}
196+
}
197+
g.Expect(found).To(BeFalse(), "expected no metric sample labeled tenant=%q to remain", tqNS)
183198
}, timeout, interval).Should(Succeed())
184199
})
185200
})

0 commit comments

Comments
 (0)