Skip to content

Commit 23c1e1d

Browse files
committed
test: add e2e tests for cluster-health-analyzer operand
Validate that the Monitoring UIPlugin with ClusterHealthAnalyzer enabled deploys the health-analyzer and correctly processes alerts into incident metrics. The test creates a crashing pod, waits for the corresponding PrometheusRule alert to fire, then verifies the cluster_health_components_map metric is exposed with the expected labels. Also extends the framework's AssertPromQLResult with configurable timeout and poll interval options (AssertPromQLResultWithOptions). Made-with: Cursor
1 parent cbd6ba3 commit 23c1e1d

File tree

3 files changed

+393
-3
lines changed

3 files changed

+393
-3
lines changed

test/e2e/framework/assertions.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,26 @@ func (f *Framework) GetPodMetrics(pod *v1.Pod, opts ...func(*HTTPOptions)) ([]by
422422
// It returns an error if the request fails. Otherwise the result is passed to
423423
// the callback function for additional checks.
424424
func (f *Framework) AssertPromQLResult(t *testing.T, expr string, callback func(model.Value) error) error {
425+
return f.AssertPromQLResultWithOptions(t, expr, callback)
426+
}
427+
428+
// AssertPromQLResultWithOptions is like AssertPromQLResult but accepts
429+
// WithTimeout and WithPollInterval options to override the default polling
430+
// parameters.
431+
func (f *Framework) AssertPromQLResultWithOptions(t *testing.T, expr string, callback func(model.Value) error, fns ...OptionFn) error {
425432
t.Helper()
433+
option := AssertOption{
434+
PollInterval: 20 * time.Second,
435+
WaitTimeout: 3 * DefaultTestTimeout,
436+
}
437+
for _, fn := range fns {
438+
fn(&option)
439+
}
426440
var (
427441
pollErr error
428442
v model.Value
429443
)
430-
if err := wait.PollUntilContextTimeout(context.Background(), 20*time.Second, 3*DefaultTestTimeout, true, func(context.Context) (bool, error) {
444+
if err := wait.PollUntilContextTimeout(context.Background(), option.PollInterval, option.WaitTimeout, true, func(context.Context) (bool, error) {
431445
v, pollErr = f.getPromQLResult(context.Background(), expr)
432446
if pollErr != nil {
433447
t.Logf("error from getPromQLResult(): %s", pollErr)

0 commit comments

Comments
 (0)