From 5f4fff1d8770b43f80dcf69ec0b0e02209531943 Mon Sep 17 00:00:00 2001 From: Assaf Admi Date: Sun, 13 Aug 2023 10:25:43 +0300 Subject: [PATCH] Force runbooks names to equal alerts names Signed-off-by: assafad --- tests/metrics_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/metrics_test.go b/tests/metrics_test.go index cb13e3ec4..393d4116c 100644 --- a/tests/metrics_test.go +++ b/tests/metrics_test.go @@ -205,9 +205,11 @@ var _ = Describe("Metrics", func() { for _, rule := range group.Rules { if rule.Alert != "" { Expect(rule.Annotations).To(HaveKeyWithValue("summary", Not(BeEmpty())), - fmt.Sprintf("%s summary is missing or empty", rule.Alert)) - Expect(rule.Annotations).To(HaveKeyWithValue("runbook_url", Not(BeEmpty())), - fmt.Sprintf("%s runbook_url is missing or empty", rule.Alert)) + "%s summary is missing or empty", rule.Alert) + Expect(rule.Annotations).To(HaveKey("runbook_url"), + "%s runbook_url is missing", rule.Alert) + Expect(rule.Annotations).To(HaveKeyWithValue("runbook_url", HaveSuffix(rule.Alert)), + "%s runbook is not equal to alert name", rule.Alert) resp, err := http.Head(rule.Annotations["runbook_url"]) Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("%s runbook is not available", rule.Alert)) Expect(resp.StatusCode).Should(Equal(http.StatusOK), fmt.Sprintf("%s runbook is not available", rule.Alert)) @@ -221,13 +223,13 @@ var _ = Describe("Metrics", func() { for _, rule := range group.Rules { if rule.Alert != "" { Expect(rule.Labels).To(HaveKeyWithValue("severity", BeElementOf("info", "warning", "critical")), - fmt.Sprintf("%s severity label is missing or not valid", rule.Alert)) + "%s severity label is missing or not valid", rule.Alert) Expect(rule.Labels).To(HaveKeyWithValue("operator_health_impact", BeElementOf("none", "warning", "critical")), - fmt.Sprintf("%s operator_health_impact label is missing or not valid", rule.Alert)) + "%s operator_health_impact label is missing or not valid", rule.Alert) Expect(rule.Labels).To(HaveKeyWithValue("kubernetes_operator_part_of", "kubevirt"), - fmt.Sprintf("%s kubernetes_operator_part_of label is missing or not valid", rule.Alert)) + "%s kubernetes_operator_part_of label is missing or not valid", rule.Alert) Expect(rule.Labels).To(HaveKeyWithValue("kubernetes_operator_component", "ssp-operator"), - fmt.Sprintf("%s kubernetes_operator_component label is missing or not valid", rule.Alert)) + "%s kubernetes_operator_component label is missing or not valid", rule.Alert) } } }