Skip to content

test/extended: check if prometheus is firing a watchdog alert #22512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion test/extended/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
kapierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -150,6 +150,22 @@ var _ = g.Describe("[Feature:Prometheus][Conformance] Prometheus", func() {
return true, nil
})).NotTo(o.HaveOccurred())
})
g.It("should have a Watchdog alert in firing state", func() {
oc.SetupProject()
ns := oc.Namespace()
execPodName := e2e.CreateExecPodOrFail(oc.AdminKubeClient(), ns, "execpod", func(pod *v1.Pod) { pod.Spec.Containers[0].Image = "centos:7" })
defer func() { oc.AdminKubeClient().CoreV1().Pods(ns).Delete(execPodName, metav1.NewDeleteOptions(1)) }()

tests := map[string][]metricTest{
// should have constantly firing a watchdog alert
`ALERTS{alertstate="firing",alertname="Watchdog"}`: {metricTest{greaterThanEqual: true, value: 1}},
// should be only one watchdog alert (this is a workaround as metricTest doesn't offer equality operator)
`ALERTS{alertstate="firing",alertname="Watchdog",severity="none"}`: {metricTest{greaterThanEqual: false, value: 2}},
}
runQueries(tests, oc, ns, execPodName, url, bearerToken)

e2e.Logf("Watchdog alert is firing: %s", bearerToken)
})
})
})

Expand Down