From 7dbfa66294688cd1bed39fc5ba2125abca8b1934 Mon Sep 17 00:00:00 2001 From: Brandon Palm Date: Wed, 7 Oct 2026 13:32:50 -0500 Subject: [PATCH] NO-JIRA: Add regression test for ConditionMatcher Any-mode early-return The Matches() Any-mode fix landed in master via #466 and the verifyOperatorStatusConditionWithTimeout helper via #517, so this branch no longer carries them. What remains: a unit test locking in that Any mode succeeds when a non-matching condition precedes a matching one in the iteration order, and a Makefile fix to double-quote E2E_GINKGO_LABEL_FILTER so filters containing single quotes are passed through correctly. --- Makefile | 2 +- test/e2e/condition_matcher_unit_test.go | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index efe6faf5f..13ceaf978 100644 --- a/Makefile +++ b/Makefile @@ -291,7 +291,7 @@ test-e2e: test-e2e-wait-for-stable-state ## Run end-to-end tests. -timeout $(E2E_TIMEOUT) \ -count 1 -v -p 1 \ -tags e2e -run "$(TEST)" . \ - -ginkgo.label-filter='$(E2E_GINKGO_LABEL_FILTER)' + -ginkgo.label-filter="$(E2E_GINKGO_LABEL_FILTER)" .PHONY: test-e2e-wait-for-stable-state test-e2e-wait-for-stable-state: diff --git a/test/e2e/condition_matcher_unit_test.go b/test/e2e/condition_matcher_unit_test.go index c70f06df5..8400d4a5e 100644 --- a/test/e2e/condition_matcher_unit_test.go +++ b/test/e2e/condition_matcher_unit_test.go @@ -6,6 +6,7 @@ package e2e import ( "strings" "testing" + "time" opv1 "github.com/openshift/api/operator/v1" operatorv1alpha1 "github.com/openshift/cert-manager-operator/api/operator/v1alpha1" @@ -119,6 +120,20 @@ func TestVerifyOperatorStatusCondition(t *testing.T) { expectError: true, errorContains: "context deadline exceeded", }, + { + name: "Any mode succeeds when matching condition appears after non-matching one", + expectedConditions: map[string]opv1.ConditionStatus{ + "Degraded": opv1.ConditionTrue, + }, + initialObjects: []runtime.Object{ + newCertManagerObjectWithConditions( + opv1.OperatorCondition{Type: controllerPrefix + "-static-resources-Degraded", Status: opv1.ConditionFalse}, + opv1.OperatorCondition{Type: controllerPrefix + "Degraded", Status: opv1.ConditionTrue}, + ), + }, + matchAny: true, + expectError: false, + }, { name: "A missing condition for Progressing", expectedConditions: map[string]opv1.ConditionStatus{ @@ -149,7 +164,7 @@ func TestVerifyOperatorStatusCondition(t *testing.T) { {controllerPrefix, tt.matchAny}, }, tt.expectedConditions) - err := verifyOperatorStatusCondition(fakeClient.OperatorV1alpha1(), matchers) + err := verifyOperatorStatusConditionWithTimeout(fakeClient.OperatorV1alpha1(), matchers, 10*time.Second) if tt.expectError && err == nil { t.Errorf("Expected an error, but got nil")