Skip to content

Commit 3e176c9

Browse files
Merge pull request #22512 from paulfantom/test_watchdog_alert
test/extended: check if prometheus is firing a watchdog alert
2 parents 2108314 + 48f2d9b commit 3e176c9

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/extended/prometheus/prometheus.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
dto "github.com/prometheus/client_model/go"
1616
"github.com/prometheus/common/expfmt"
1717

18-
"k8s.io/api/core/v1"
18+
v1 "k8s.io/api/core/v1"
1919
kapierrs "k8s.io/apimachinery/pkg/api/errors"
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121
"k8s.io/apimachinery/pkg/util/wait"
@@ -150,6 +150,22 @@ var _ = g.Describe("[Feature:Prometheus][Conformance] Prometheus", func() {
150150
return true, nil
151151
})).NotTo(o.HaveOccurred())
152152
})
153+
g.It("should have a Watchdog alert in firing state", func() {
154+
oc.SetupProject()
155+
ns := oc.Namespace()
156+
execPodName := e2e.CreateExecPodOrFail(oc.AdminKubeClient(), ns, "execpod", func(pod *v1.Pod) { pod.Spec.Containers[0].Image = "centos:7" })
157+
defer func() { oc.AdminKubeClient().CoreV1().Pods(ns).Delete(execPodName, metav1.NewDeleteOptions(1)) }()
158+
159+
tests := map[string][]metricTest{
160+
// should have constantly firing a watchdog alert
161+
`ALERTS{alertstate="firing",alertname="Watchdog"}`: {metricTest{greaterThanEqual: true, value: 1}},
162+
// should be only one watchdog alert (this is a workaround as metricTest doesn't offer equality operator)
163+
`ALERTS{alertstate="firing",alertname="Watchdog",severity="none"}`: {metricTest{greaterThanEqual: false, value: 2}},
164+
}
165+
runQueries(tests, oc, ns, execPodName, url, bearerToken)
166+
167+
e2e.Logf("Watchdog alert is firing: %s", bearerToken)
168+
})
153169
})
154170
})
155171

0 commit comments

Comments
 (0)