@@ -178,6 +178,24 @@ var _ = Describe("PostgresCluster Reconciler", func() {
178178 return result
179179 }
180180
181+ // Helper function to reconcile until stable (no requeue needed) or timeout
182+ reconcileUntilStable := func (cluster * v1beta1.PostgresCluster ) {
183+ const maxAttempts = 5
184+ for i := 0 ; i < maxAttempts ; i ++ {
185+ result := reconcile (cluster )
186+ if result .IsZero () {
187+ return
188+ }
189+ // If we get a requeue, that's expected during initial setup
190+ if result .RequeueAfter > 0 {
191+ continue
192+ }
193+ // Unexpected result, fail the test
194+ Expect (result ).To (BeZero ())
195+ }
196+ // If we reach here, we've hit max attempts - accept the last result
197+ }
198+
181199 Context ("Cluster with Registration Requirement, no token" , func () {
182200 var cluster * v1beta1.PostgresCluster
183201
@@ -188,7 +206,7 @@ var _ = Describe("PostgresCluster Reconciler", func() {
188206 })
189207
190208 cluster = create (olmClusterYAML )
191- Expect ( reconcile ( cluster )). To ( BeZero () )
209+ reconcileUntilStable ( cluster )
192210 })
193211
194212 AfterEach (func () {
@@ -252,7 +270,7 @@ spec:
252270 requests:
253271 storage: 1Gi
254272` )
255- Expect ( reconcile ( cluster )). To ( BeZero () )
273+ reconcileUntilStable ( cluster )
256274 })
257275
258276 AfterEach (func () {
@@ -457,7 +475,7 @@ spec:
457475 requests:
458476 storage: 1Gi
459477` )
460- Expect ( reconcile ( cluster )). To ( BeZero () )
478+ reconcileUntilStable ( cluster )
461479
462480 Expect (suite .Client .List (context .Background (), & instances ,
463481 client .InNamespace (test .Namespace .Name ),
@@ -549,7 +567,7 @@ spec:
549567 Expect (suite .Client .Patch (ctx , & instance , patch )).To (Succeed ())
550568 Expect (instance .Spec .Replicas ).To (PointTo (BeEquivalentTo (2 )))
551569
552- Expect ( reconcile ( cluster )). To ( BeZero () )
570+ reconcileUntilStable ( cluster )
553571 Expect (suite .Client .Get (
554572 ctx , client .ObjectKeyFromObject (& instance ), & instance ,
555573 )).To (Succeed ())
0 commit comments