@@ -348,8 +348,31 @@ var _ = Describe("Reconcile Test", func() {
348348 Expect (err ).NotTo (HaveOccurred ())
349349 })
350350
351+ It ("verify operator status when bundle deployment status is stale while being created" , func () {
352+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
353+ Expect (res ).To (Equal (ctrl.Result {}))
354+ Expect (err ).NotTo (HaveOccurred ())
355+
356+ By ("fetching the updated operator after reconcile" )
357+ op := & operatorsv1alpha1.Operator {}
358+ err = cl .Get (ctx , opKey , op )
359+ Expect (err ).NotTo (HaveOccurred ())
360+
361+ By ("checking the expected conditions" )
362+ cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
363+ Expect (cond ).NotTo (BeNil ())
364+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
365+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonInstallationStatusUnknown ))
366+ Expect (cond .Message ).To (Equal (fmt .Sprintf ("waiting for bundleDeployment %q status to be updated. BundleDeployment conditions out of date." , bd .Name )))
367+ })
368+
351369 It ("verify operator status when bundle deployment is waiting to be created" , func () {
352370 By ("running reconcile" )
371+ bd .Status .ObservedGeneration = bd .GetGeneration ()
372+ By ("updating the status of bundleDeployment" )
373+ err := cl .Status ().Update (ctx , bd )
374+ Expect (err ).NotTo (HaveOccurred ())
375+
353376 res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
354377 Expect (res ).To (Equal (ctrl.Result {}))
355378 Expect (err ).NotTo (HaveOccurred ())
@@ -364,7 +387,7 @@ var _ = Describe("Reconcile Test", func() {
364387 Expect (cond ).NotTo (BeNil ())
365388 Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
366389 Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonInstallationStatusUnknown ))
367- Expect (cond .Message ).To (ContainSubstring ( ` waiting for bundleDeployment` ))
390+ Expect (cond .Message ).To (Equal ( fmt . Sprintf ( " waiting for bundleDeployment %q status to be updated" , bd . Name ) ))
368391 })
369392
370393 It ("verify operator status when `HasValidBundle` condition of rukpak is false" , func () {
@@ -374,6 +397,7 @@ var _ = Describe("Reconcile Test", func() {
374397 Message : "failed to unpack" ,
375398 Reason : rukpakv1alpha1 .ReasonUnpackFailed ,
376399 })
400+ bd .Status .ObservedGeneration = bd .GetGeneration ()
377401
378402 By ("updating the status of bundleDeployment" )
379403 err := cl .Status ().Update (ctx , bd )
@@ -404,6 +428,7 @@ var _ = Describe("Reconcile Test", func() {
404428 Message : "failed to install" ,
405429 Reason : rukpakv1alpha1 .ReasonInstallFailed ,
406430 })
431+ bd .Status .ObservedGeneration = bd .GetGeneration ()
407432
408433 By ("updating the status of bundleDeployment" )
409434 err := cl .Status ().Update (ctx , bd )
@@ -434,6 +459,7 @@ var _ = Describe("Reconcile Test", func() {
434459 Message : "operator installed successfully" ,
435460 Reason : rukpakv1alpha1 .ReasonInstallationSucceeded ,
436461 })
462+ bd .Status .ObservedGeneration = bd .GetGeneration ()
437463
438464 By ("updating the status of bundleDeployment" )
439465 err := cl .Status ().Update (ctx , bd )
@@ -471,6 +497,7 @@ var _ = Describe("Reconcile Test", func() {
471497 Message : "installing" ,
472498 Reason : rukpakv1alpha1 .ReasonInstallationSucceeded ,
473499 })
500+ bd .Status .ObservedGeneration = bd .GetGeneration ()
474501
475502 By ("updating the status of bundleDeployment" )
476503 err := cl .Status ().Update (ctx , bd )
@@ -501,6 +528,7 @@ var _ = Describe("Reconcile Test", func() {
501528 Message : "installing" ,
502529 Reason : rukpakv1alpha1 .ReasonInstallationSucceeded ,
503530 })
531+ bd .Status .ObservedGeneration = bd .GetGeneration ()
504532
505533 By ("updating the status of bundleDeployment" )
506534 err := cl .Status ().Update (ctx , bd )
0 commit comments