@@ -91,6 +91,7 @@ var _ = Describe("Reconcile Test", func() {
91
91
err := cl .Create (ctx , operator )
92
92
Expect (err ).NotTo (HaveOccurred ())
93
93
})
94
+
94
95
When ("the BundleDeployment does not exist" , func () {
95
96
BeforeEach (func () {
96
97
By ("running reconcile" )
@@ -111,14 +112,12 @@ var _ = Describe("Reconcile Test", func() {
111
112
Expect (bd .Spec .Template .Spec .Source .Image ).NotTo (BeNil ())
112
113
Expect (bd .Spec .Template .Spec .Source .Image .Ref ).To (Equal ("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed" ))
113
114
})
114
- It ("sets resolution success status" , func () {
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 .ReasonInstallationSucceeded ))
120
- Expect (cond .Message ).To (Equal ("install was successful" ))
121
- })
115
+ It ("sets the status on operator" , func () {
116
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
117
+ Expect (cond ).NotTo (BeNil ())
118
+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
119
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
120
+ Expect (cond .Message ).To (ContainSubstring ("waiting for bundleDeployment" ))
122
121
})
123
122
})
124
123
When ("the expected BundleDeployment already exists" , func () {
@@ -176,14 +175,12 @@ var _ = Describe("Reconcile Test", func() {
176
175
Expect (bd .Spec .Template .Spec .Source .Image ).NotTo (BeNil ())
177
176
Expect (bd .Spec .Template .Spec .Source .Image .Ref ).To (Equal ("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed" ))
178
177
})
179
- It ("sets resolution success status" , func () {
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 .ReasonInstallationSucceeded ))
185
- Expect (cond .Message ).To (Equal ("install was successful" ))
186
- })
178
+ It ("sets the status on operator" , func () {
179
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
180
+ Expect (cond ).NotTo (BeNil ())
181
+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
182
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
183
+ Expect (cond .Message ).To (ContainSubstring ("waiting for bundleDeployment" ))
187
184
})
188
185
})
189
186
When ("an out-of-date BundleDeployment exists" , func () {
@@ -227,14 +224,11 @@ var _ = Describe("Reconcile Test", func() {
227
224
Expect (bd .Spec .Template .Spec .Source .Image .Ref ).To (Equal ("quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed" ))
228
225
})
229
226
It ("sets resolution success status" , func () {
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 .ReasonInstallationSucceeded ))
235
- Expect (cond .Message ).To (Equal ("install was successful" ))
236
- })
237
-
227
+ cond := apimeta .FindStatusCondition (operator .Status .Conditions , operatorsv1alpha1 .TypeReady )
228
+ Expect (cond ).NotTo (BeNil ())
229
+ Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
230
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
231
+ Expect (cond .Message ).To (ContainSubstring ("waiting for bundleDeployment" ))
238
232
})
239
233
})
240
234
})
@@ -268,12 +262,16 @@ var _ = Describe("Reconcile Test", func() {
268
262
})
269
263
When ("the operator specifies a duplicate package" , func () {
270
264
const pkgName = "prometheus"
265
+ var dupOperator * operatorsv1alpha1.Operator
266
+
271
267
BeforeEach (func () {
272
268
By ("initializing cluster state" )
273
- err := cl . Create ( ctx , & operatorsv1alpha1.Operator {
269
+ dupOperator = & operatorsv1alpha1.Operator {
274
270
ObjectMeta : metav1.ObjectMeta {Name : fmt .Sprintf ("orig-%s" , opKey .Name )},
275
271
Spec : operatorsv1alpha1.OperatorSpec {PackageName : pkgName },
276
- })
272
+ }
273
+
274
+ err := cl .Create (ctx , dupOperator )
277
275
Expect (err ).NotTo (HaveOccurred ())
278
276
279
277
operator = & operatorsv1alpha1.Operator {
@@ -283,6 +281,12 @@ var _ = Describe("Reconcile Test", func() {
283
281
err = cl .Create (ctx , operator )
284
282
Expect (err ).NotTo (HaveOccurred ())
285
283
})
284
+
285
+ AfterEach (func () {
286
+ err := cl .Delete (ctx , dupOperator )
287
+ Expect (err ).NotTo (HaveOccurred ())
288
+ })
289
+
286
290
It ("sets resolution failure status" , func () {
287
291
By ("running reconcile" )
288
292
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
@@ -303,11 +307,11 @@ var _ = Describe("Reconcile Test", func() {
303
307
When ("the existing operator status is based on bundleDeployment" , func () {
304
308
const pkgName = "prometheus"
305
309
var (
306
- bd rukpakv1alpha1.BundleDeployment
310
+ bd * rukpakv1alpha1.BundleDeployment
307
311
)
308
312
BeforeEach (func () {
309
313
By ("creating the expected BundleDeployment" )
310
- bd : = & rukpakv1alpha1.BundleDeployment {
314
+ bd = & rukpakv1alpha1.BundleDeployment {
311
315
ObjectMeta : metav1.ObjectMeta {Name : opKey .Name },
312
316
Spec : rukpakv1alpha1.BundleDeploymentSpec {
313
317
ProvisionerClassName : "core-rukpak-io-plain" ,
@@ -338,7 +342,13 @@ var _ = Describe("Reconcile Test", func() {
338
342
Expect (err ).NotTo (HaveOccurred ())
339
343
340
344
})
341
- It ("verify if operator status when bundle deployment is waiting to be created" , func () {
345
+
346
+ AfterEach (func () {
347
+ err := cl .Delete (ctx , bd )
348
+ Expect (err ).NotTo (HaveOccurred ())
349
+ })
350
+
351
+ It ("verify operator status when bundle deployment is waiting to be created" , func () {
342
352
By ("running reconcile" )
343
353
res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : opKey })
344
354
Expect (res ).To (Equal (ctrl.Result {}))
@@ -353,14 +363,11 @@ var _ = Describe("Reconcile Test", func() {
353
363
cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
354
364
Expect (cond ).NotTo (BeNil ())
355
365
Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
356
- Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonInstallationSucceeded ))
366
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
357
367
Expect (cond .Message ).To (ContainSubstring (`waiting for bundleDeployment` ))
358
368
})
359
369
360
370
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
371
apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
365
372
Type : rukpakv1alpha1 .TypeHasValidBundle ,
366
373
Status : metav1 .ConditionFalse ,
@@ -369,7 +376,7 @@ var _ = Describe("Reconcile Test", func() {
369
376
})
370
377
371
378
By ("updating the status of bundleDeployment" )
372
- err = cl .Status ().Update (ctx , & bd )
379
+ err : = cl .Status ().Update (ctx , bd )
373
380
Expect (err ).NotTo (HaveOccurred ())
374
381
375
382
By ("running reconcile" )
@@ -391,9 +398,6 @@ var _ = Describe("Reconcile Test", func() {
391
398
})
392
399
393
400
It ("verify operator status when `InstallReady` condition of rukpak is false" , func () {
394
- err := cl .Get (ctx , opKey , & bd )
395
- Expect (err ).NotTo (HaveOccurred ())
396
-
397
401
apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
398
402
Type : rukpakv1alpha1 .TypeInstalled ,
399
403
Status : metav1 .ConditionFalse ,
@@ -402,7 +406,7 @@ var _ = Describe("Reconcile Test", func() {
402
406
})
403
407
404
408
By ("updating the status of bundleDeployment" )
405
- err = cl .Status ().Update (ctx , & bd )
409
+ err : = cl .Status ().Update (ctx , bd )
406
410
Expect (err ).NotTo (HaveOccurred ())
407
411
408
412
By ("running reconcile" )
@@ -424,9 +428,6 @@ var _ = Describe("Reconcile Test", func() {
424
428
})
425
429
426
430
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
431
apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
431
432
Type : rukpakv1alpha1 .TypeInstalled ,
432
433
Status : metav1 .ConditionTrue ,
@@ -435,7 +436,7 @@ var _ = Describe("Reconcile Test", func() {
435
436
})
436
437
437
438
By ("updating the status of bundleDeployment" )
438
- err = cl .Status ().Update (ctx , & bd )
439
+ err : = cl .Status ().Update (ctx , bd )
439
440
Expect (err ).NotTo (HaveOccurred ())
440
441
441
442
By ("running reconcile" )
@@ -457,9 +458,6 @@ var _ = Describe("Reconcile Test", func() {
457
458
})
458
459
459
460
It ("verify any other unknown status of bundledeployment" , func () {
460
- err := cl .Get (ctx , opKey , & bd )
461
- Expect (err ).NotTo (HaveOccurred ())
462
-
463
461
apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
464
462
Type : rukpakv1alpha1 .TypeHasValidBundle ,
465
463
Status : metav1 .ConditionUnknown ,
@@ -475,7 +473,7 @@ var _ = Describe("Reconcile Test", func() {
475
473
})
476
474
477
475
By ("updating the status of bundleDeployment" )
478
- err = cl .Status ().Update (ctx , & bd )
476
+ err : = cl .Status ().Update (ctx , bd )
479
477
Expect (err ).NotTo (HaveOccurred ())
480
478
481
479
By ("running reconcile" )
@@ -492,14 +490,11 @@ var _ = Describe("Reconcile Test", func() {
492
490
cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
493
491
Expect (cond ).NotTo (BeNil ())
494
492
Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
495
- Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonInstallationSucceeded ))
496
- Expect (cond .Message ).To (ContainSubstring (`waiting for rukpak to install bundleDeployment successfully ` ))
493
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
494
+ Expect (cond .Message ).To (ContainSubstring (`could not determine the state of bundleDeployment ` ))
497
495
})
498
496
499
497
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
498
apimeta .SetStatusCondition (& bd .Status .Conditions , metav1.Condition {
504
499
Type : rukpakv1alpha1 .TypeInstalled ,
505
500
Status : metav1 .ConditionUnknown ,
@@ -508,7 +503,7 @@ var _ = Describe("Reconcile Test", func() {
508
503
})
509
504
510
505
By ("updating the status of bundleDeployment" )
511
- err = cl .Status ().Update (ctx , & bd )
506
+ err : = cl .Status ().Update (ctx , bd )
512
507
Expect (err ).NotTo (HaveOccurred ())
513
508
514
509
By ("running reconcile" )
@@ -525,14 +520,14 @@ var _ = Describe("Reconcile Test", func() {
525
520
cond := apimeta .FindStatusCondition (op .Status .Conditions , operatorsv1alpha1 .TypeReady )
526
521
Expect (cond ).NotTo (BeNil ())
527
522
Expect (cond .Status ).To (Equal (metav1 .ConditionUnknown ))
528
- Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonInstallationSucceeded ))
529
- Expect (cond .Message ).To (ContainSubstring (`waiting for rukpak to install bundleDeployment successfully ` ))
523
+ Expect (cond .Reason ).To (Equal (operatorsv1alpha1 .ReasonBundleDeploymentFailed ))
524
+ Expect (cond .Message ).To (ContainSubstring (`could not determine the state of bundleDeployment ` ))
530
525
})
531
526
})
532
527
AfterEach (func () {
533
528
verifyInvariants (ctx , operator )
534
529
535
- err := cl .DeleteAllOf (ctx , operator )
530
+ err := cl .Delete (ctx , operator )
536
531
Expect (err ).To (Not (HaveOccurred ()))
537
532
})
538
533
})
0 commit comments