From aae39e132add1b727e1b29ddb9cfb5a98c9005bb Mon Sep 17 00:00:00 2001 From: Hongyan Li Date: Wed, 3 Dec 2025 15:55:36 +0800 Subject: [PATCH] test: automation to cover nill resource selector The auto covered upstream issue https://github.com/prometheus-operator/prometheus-operator/issue/6018 --- test/e2e/monitoring_stack_controller_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/e2e/monitoring_stack_controller_test.go b/test/e2e/monitoring_stack_controller_test.go index c41b1e507..cb41bf4dc 100644 --- a/test/e2e/monitoring_stack_controller_test.go +++ b/test/e2e/monitoring_stack_controller_test.go @@ -66,6 +66,9 @@ func TestMonitoringStackController(t *testing.T) { }, { name: "resource selector nil propagates to Prometheus", scenario: nilResrouceSelectorPropagatesToPrometheus, + }, { + name: "prometheus with nil resource selector becomes ready", + scenario: nilResourceSelectorPrometheusBecomesReady, }, { name: "stack spec are reflected in Prometheus", scenario: reconcileStack, @@ -174,6 +177,21 @@ func nilResrouceSelectorPropagatesToPrometheus(t *testing.T) { } } +func nilResourceSelectorPrometheusBecomesReady(t *testing.T) { + ms := newMonitoringStack(t, "nil-selector-ready") + ms.Spec.ResourceSelector = nil + + err := f.K8sClient.Create(context.Background(), ms) + assert.NilError(t, err, "failed to create monitoring stack with nil resourceSelector") + + // Verify Prometheus CR is created + f.AssertResourceEventuallyExists(ms.Name, ms.Namespace, &monv1.Prometheus{})(t) + + // Verify Prometheus pods become ready despite nil resourceSelector + // covers upstream issue #932 + f.AssertStatefulsetReady("prometheus-"+ms.Name, ms.Namespace, framework.WithTimeout(5*time.Minute))(t) +} + func promConfigDefaultsAreApplied(t *testing.T) { tests := []struct { name string