@@ -112,11 +112,13 @@ var _ = Describe("Reconcile Test", func() {
112
112
Expect (bd .Spec .Template .Spec .Source .Image .Ref ).To (Equal ("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed" ))
113
113
})
114
114
It ("sets resolution success status" , func () {
115
- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
116
- Expect (cond ).NotTo (BeNil ())
117
- Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
118
- Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
119
- Expect (cond .Message ).To (Equal ("resolution was successful" ))
115
+ Eventually (func () {
116
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
117
+ Expect (cond ).NotTo (BeNil ())
118
+ Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
119
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
120
+ Expect (cond .Message ).To (Equal ("resolution was successful" ))
121
+ })
120
122
})
121
123
})
122
124
When ("the expected BundleDeployment already exists" , func () {
@@ -175,11 +177,13 @@ var _ = Describe("Reconcile Test", func() {
175
177
Expect (bd .Spec .Template .Spec .Source .Image .Ref ).To (Equal ("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed" ))
176
178
})
177
179
It ("sets resolution success status" , func () {
178
- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
179
- Expect (cond ).NotTo (BeNil ())
180
- Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
181
- Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
182
- Expect (cond .Message ).To (Equal ("resolution was successful" ))
180
+ Eventually (func () {
181
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
182
+ Expect (cond ).NotTo (BeNil ())
183
+ Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
184
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
185
+ Expect (cond .Message ).To (Equal ("resolution was successful" ))
186
+ })
183
187
})
184
188
})
185
189
When ("an out-of-date BundleDeployment exists" , func () {
@@ -223,11 +227,14 @@ var _ = Describe("Reconcile Test", func() {
223
227
Expect (bd .Spec .Template .Spec .Source .Image .Ref ).To (Equal ("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed" ))
224
228
})
225
229
It ("sets resolution success status" , func () {
226
- cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
227
- Expect (cond ).NotTo (BeNil ())
228
- Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
229
- Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
230
- Expect (cond .Message ).To (Equal ("resolution was successful" ))
230
+ Eventually (func () {
231
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
232
+ Expect (cond ).NotTo (BeNil ())
233
+ Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
234
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
235
+ Expect (cond .Message ).To (Equal ("resolution was successful" ))
236
+ })
237
+
231
238
})
232
239
})
233
240
})
@@ -331,24 +338,77 @@ var _ = Describe("Reconcile Test", func() {
331
338
Expect (err ).NotTo (HaveOccurred ())
332
339
333
340
})
334
- It ("verify if operator status is updated according to bundleDeployment" , func () {
341
+ It ("verify if operator status when bundle deployment is waiting to be created" , func () {
342
+ By ("running reconcile" )
343
+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
344
+ Expect (res ).To (Equal (ctrl.Result {}))
345
+ Expect (err ).NotTo (HaveOccurred ())
346
+
347
+ By ("fetching the updated operator after reconcile" )
348
+ op := & operatorsv1alpha1.Operator {}
349
+ err = cl .Get (ctx , opKey , op )
350
+ Expect (err ).NotTo (HaveOccurred ())
351
+
352
+ By ("checking the expected conditions" )
353
+ cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
354
+ Expect (cond ).NotTo (BeNil ())
355
+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
356
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
357
+ Expect (cond .Message ).To (ContainSubstring (`waiting for bundleDeployment` ))
358
+ })
359
+
360
+ It ("verify operator status when `HasValidBundle` condition of rukpak is false" , func () {
361
+ err := cl .Get (ctx , opKey , & bd )
362
+ Expect (err ).NotTo (HaveOccurred ())
363
+
364
+ apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
365
+ Type : rukpakv1alpha1 .TypeHasValidBundle ,
366
+ Status : metav1 .ConditionFalse ,
367
+ Message : "failed to unpack" ,
368
+ Reason : rukpakv1alpha1 .ReasonUnpackFailed ,
369
+ })
370
+
371
+ By ("updating the status of bundleDeployment" )
372
+ err = cl .Status ().Update (ctx , & bd )
373
+ Expect (err ).NotTo (HaveOccurred ())
374
+
375
+ By ("running reconcile" )
376
+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
377
+ Expect (res ).To (Equal (ctrl.Result {}))
378
+ Expect (err ).NotTo (HaveOccurred ())
379
+
380
+ By ("fetching the updated operator after reconcile" )
381
+ op := & operatorsv1alpha1.Operator {}
382
+ err = cl .Get (ctx , opKey , op )
383
+ Expect (err ).NotTo (HaveOccurred ())
384
+
385
+ By ("checking the expected conditions" )
386
+ cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
387
+ Expect (cond ).NotTo (BeNil ())
388
+ Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
389
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
390
+ Expect (cond .Message ).To (ContainSubstring (`failed to unpack` ))
391
+ })
392
+
393
+ It ("verify operator status when `InstallReady` condition of rukpak is false" , func () {
335
394
err := cl .Get (ctx , opKey , & bd )
336
395
Expect (err ).NotTo (HaveOccurred ())
396
+
337
397
apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
338
- Type : rukpakv1alpha1 .TypeInstalled ,
339
- LastTransitionTime : metav1 .Now (),
340
- Status : metav1 .ConditionFalse ,
341
- Message : "fail to unpack" ,
342
- Reason : rukpakv1alpha1 .ReasonInstallFailed ,
398
+ Type : rukpakv1alpha1 .TypeInstalled ,
399
+ Status : metav1 .ConditionFalse ,
400
+ Message : "failed to install" ,
401
+ Reason : rukpakv1alpha1 .ReasonInstallFailed ,
343
402
})
403
+
404
+ By ("updating the status of bundleDeployment" )
344
405
err = cl .Status ().Update (ctx , & bd )
345
406
Expect (err ).NotTo (HaveOccurred ())
346
407
347
408
By ("running reconcile" )
348
409
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
349
410
Expect (res ).To (Equal (ctrl.Result {}))
350
- Expect (err ).To (HaveOccurred ())
351
- Expect (err .Error ()).To (ContainSubstring (`error observed by Rukpak` ))
411
+ Expect (err ).NotTo (HaveOccurred ())
352
412
353
413
By ("fetching the updated operator after reconcile" )
354
414
op := & operatorsv1alpha1.Operator {}
@@ -360,7 +420,113 @@ var _ = Describe("Reconcile Test", func() {
360
420
Expect (cond ).NotTo (BeNil ())
361
421
Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
362
422
Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
363
- Expect (cond .Message ).To (ContainSubstring (`error observed by Rukpak` ))
423
+ Expect (cond .Message ).To (ContainSubstring (`failed to install` ))
424
+ })
425
+
426
+ It ("verify operator status when `InstallReady` condition of rukpak is true" , func () {
427
+ err := cl .Get (ctx , opKey , & bd )
428
+ Expect (err ).NotTo (HaveOccurred ())
429
+
430
+ apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
431
+ Type : rukpakv1alpha1 .TypeInstalled ,
432
+ Status : metav1 .ConditionTrue ,
433
+ Message : "operator installed successfully" ,
434
+ Reason : rukpakv1alpha1 .ReasonInstallationSucceeded ,
435
+ })
436
+
437
+ By ("updating the status of bundleDeployment" )
438
+ err = cl .Status ().Update (ctx , & bd )
439
+ Expect (err ).NotTo (HaveOccurred ())
440
+
441
+ By ("running reconcile" )
442
+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
443
+ Expect (res ).To (Equal (ctrl.Result {}))
444
+ Expect (err ).NotTo (HaveOccurred ())
445
+
446
+ By ("fetching the updated operator after reconcile" )
447
+ op := & operatorsv1alpha1.Operator {}
448
+ err = cl .Get (ctx , opKey , op )
449
+ Expect (err ).NotTo (HaveOccurred ())
450
+
451
+ By ("checking the expected conditions" )
452
+ cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
453
+ Expect (cond ).NotTo (BeNil ())
454
+ Expect (cond .Status ).To (Equal (metav1 .ConditionTrue ))
455
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
456
+ Expect (cond .Message ).To (ContainSubstring (`resolution was successful` ))
457
+ })
458
+
459
+ It ("verify any other unknown status of bundledeployment" , func () {
460
+ err := cl .Get (ctx , opKey , & bd )
461
+ Expect (err ).NotTo (HaveOccurred ())
462
+
463
+ apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
464
+ Type : rukpakv1alpha1 .TypeHasValidBundle ,
465
+ Status : metav1 .ConditionUnknown ,
466
+ Message : "unpacking" ,
467
+ Reason : rukpakv1alpha1 .ReasonUnpackSuccessful ,
468
+ })
469
+
470
+ apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
471
+ Type : rukpakv1alpha1 .TypeInstalled ,
472
+ Status : metav1 .ConditionUnknown ,
473
+ Message : "installing" ,
474
+ Reason : rukpakv1alpha1 .ReasonInstallationSucceeded ,
475
+ })
476
+
477
+ By ("updating the status of bundleDeployment" )
478
+ err = cl .Status ().Update (ctx , & bd )
479
+ Expect (err ).NotTo (HaveOccurred ())
480
+
481
+ By ("running reconcile" )
482
+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
483
+ Expect (res ).To (Equal (ctrl.Result {}))
484
+ Expect (err ).NotTo (HaveOccurred ())
485
+
486
+ By ("fetching the updated operator after reconcile" )
487
+ op := & operatorsv1alpha1.Operator {}
488
+ err = cl .Get (ctx , opKey , op )
489
+ Expect (err ).NotTo (HaveOccurred ())
490
+
491
+ By ("checking the expected conditions" )
492
+ cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
493
+ Expect (cond ).NotTo (BeNil ())
494
+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
495
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
496
+ Expect (cond .Message ).To (ContainSubstring (`waiting for rukpak to install bundleDeployment successfully` ))
497
+ })
498
+
499
+ It ("verify operator status when bundleDeployment installation status is unknown" , func () {
500
+ err := cl .Get (ctx , opKey , & bd )
501
+ Expect (err ).NotTo (HaveOccurred ())
502
+
503
+ apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
504
+ Type : rukpakv1alpha1 .TypeInstalled ,
505
+ Status : metav1 .ConditionUnknown ,
506
+ Message : "installing" ,
507
+ Reason : rukpakv1alpha1 .ReasonInstallationSucceeded ,
508
+ })
509
+
510
+ By ("updating the status of bundleDeployment" )
511
+ err = cl .Status ().Update (ctx , & bd )
512
+ Expect (err ).NotTo (HaveOccurred ())
513
+
514
+ By ("running reconcile" )
515
+ res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
516
+ Expect (res ).To (Equal (ctrl.Result {}))
517
+ Expect (err ).NotTo (HaveOccurred ())
518
+
519
+ By ("fetching the updated operator after reconcile" )
520
+ op := & operatorsv1alpha1.Operator {}
521
+ err = cl .Get (ctx , opKey , op )
522
+ Expect (err ).NotTo (HaveOccurred ())
523
+
524
+ By ("checking the expected conditions" )
525
+ cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
526
+ Expect (cond ).NotTo (BeNil ())
527
+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
528
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonResolutionSucceeded ))
529
+ Expect (cond .Message ).To (ContainSubstring (`waiting for rukpak to install bundleDeployment successfully` ))
364
530
})
365
531
})
366
532
AfterEach (func () {
0 commit comments