Skip to content

Commit

Permalink
Merge pull request #654 from assafad/runbook-test
Browse files Browse the repository at this point in the history
Force runbooks names to equal alerts names
  • Loading branch information
kubevirt-bot authored Aug 15, 2023
2 parents b068449 + 5f4fff1 commit b76f208
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit b76f208

Please sign in to comment.