5
5
"fmt"
6
6
"reflect"
7
7
"testing"
8
+ "time"
8
9
9
10
"github.com/google/go-cmp/cmp"
10
11
"github.com/google/go-cmp/cmp/cmpopts"
@@ -358,12 +359,22 @@ func TestUpdateClusterVersionStatus_FilteringMultipleErrorsForFailingCondition(t
358
359
type args struct {
359
360
syncWorkerStatus * SyncWorkerStatus
360
361
}
362
+ payload .COUpdateStartTimesEnsure ("co-not-timeout" )
363
+ payload .COUpdateStartTimesAt ("co-timeout" , time .Now ().Add (- 60 * time .Minute ))
364
+ payload .COUpdateStartTimesAt ("machine-config" , time .Now ().Add (- 60 * time .Minute ))
365
+ defer func () {
366
+ payload .COUpdateStartTimesRemove ("co-not-timeout" )
367
+ payload .COUpdateStartTimesRemove ("co-timeout" )
368
+ payload .COUpdateStartTimesRemove ("machine-config" )
369
+ }()
370
+
361
371
tests := []struct {
362
372
name string
363
373
args args
364
374
shouldModifyWhenNotReconcilingAndHistoryNotEmpty bool
365
375
expectedConditionNotModified * configv1.ClusterOperatorStatusCondition
366
376
expectedConditionModified * configv1.ClusterOperatorStatusCondition
377
+ expectedProgressingCondition * configv1.ClusterOperatorStatusCondition
367
378
}{
368
379
{
369
380
name : "no errors are present" ,
@@ -394,10 +405,74 @@ func TestUpdateClusterVersionStatus_FilteringMultipleErrorsForFailingCondition(t
394
405
name : "single UpdateEffectNone error" ,
395
406
args : args {
396
407
syncWorkerStatus : & SyncWorkerStatus {
408
+ Actual : configv1.Release {Version : "1.2.3" },
409
+ Failure : & payload.UpdateError {
410
+ UpdateEffect : payload .UpdateEffectNone ,
411
+ Reason : "ClusterOperatorUpdating" ,
412
+ Message : "Cluster operator A is updating" ,
413
+ Name : "co-not-timeout" ,
414
+ },
415
+ },
416
+ },
417
+ expectedConditionNotModified : & configv1.ClusterOperatorStatusCondition {
418
+ Type : ClusterStatusFailing ,
419
+ Status : configv1 .ConditionTrue ,
420
+ Reason : "ClusterOperatorUpdating" ,
421
+ Message : "Cluster operator A is updating" ,
422
+ },
423
+ shouldModifyWhenNotReconcilingAndHistoryNotEmpty : true ,
424
+ expectedConditionModified : & configv1.ClusterOperatorStatusCondition {
425
+ Type : ClusterStatusFailing ,
426
+ Status : configv1 .ConditionFalse ,
427
+ },
428
+ expectedProgressingCondition : & configv1.ClusterOperatorStatusCondition {
429
+ Type : configv1 .OperatorProgressing ,
430
+ Status : configv1 .ConditionTrue ,
431
+ Reason : "ClusterOperatorUpdating" ,
432
+ Message : "Working towards 1.2.3: waiting on co-not-timeout" ,
433
+ },
434
+ },
435
+ {
436
+ name : "single UpdateEffectNone error and timeout" ,
437
+ args : args {
438
+ syncWorkerStatus : & SyncWorkerStatus {
439
+ Actual : configv1.Release {Version : "1.2.3" },
440
+ Failure : & payload.UpdateError {
441
+ UpdateEffect : payload .UpdateEffectNone ,
442
+ Reason : "ClusterOperatorUpdating" ,
443
+ Message : "Cluster operator A is updating" ,
444
+ Name : "co-timeout" ,
445
+ },
446
+ },
447
+ },
448
+ expectedConditionNotModified : & configv1.ClusterOperatorStatusCondition {
449
+ Type : ClusterStatusFailing ,
450
+ Status : configv1 .ConditionTrue ,
451
+ Reason : "ClusterOperatorUpdating" ,
452
+ Message : "Cluster operator A is updating" ,
453
+ },
454
+ shouldModifyWhenNotReconcilingAndHistoryNotEmpty : true ,
455
+ expectedConditionModified : & configv1.ClusterOperatorStatusCondition {
456
+ Type : ClusterStatusFailing ,
457
+ Status : configv1 .ConditionFalse ,
458
+ },
459
+ expectedProgressingCondition : & configv1.ClusterOperatorStatusCondition {
460
+ Type : configv1 .OperatorProgressing ,
461
+ Status : configv1 .ConditionTrue ,
462
+ Reason : "ClusterOperatorUpdating" ,
463
+ Message : "Working towards 1.2.3: waiting on co-timeout over 30 minutes which is longer than expected" ,
464
+ },
465
+ },
466
+ {
467
+ name : "single UpdateEffectNone error and machine-config" ,
468
+ args : args {
469
+ syncWorkerStatus : & SyncWorkerStatus {
470
+ Actual : configv1.Release {Version : "1.2.3" },
397
471
Failure : & payload.UpdateError {
398
472
UpdateEffect : payload .UpdateEffectNone ,
399
473
Reason : "ClusterOperatorUpdating" ,
400
474
Message : "Cluster operator A is updating" ,
475
+ Name : "machine-config" ,
401
476
},
402
477
},
403
478
},
@@ -412,6 +487,12 @@ func TestUpdateClusterVersionStatus_FilteringMultipleErrorsForFailingCondition(t
412
487
Type : ClusterStatusFailing ,
413
488
Status : configv1 .ConditionFalse ,
414
489
},
490
+ expectedProgressingCondition : & configv1.ClusterOperatorStatusCondition {
491
+ Type : configv1 .OperatorProgressing ,
492
+ Status : configv1 .ConditionTrue ,
493
+ Reason : "ClusterOperatorUpdating" ,
494
+ Message : "Working towards 1.2.3: waiting on machine-config" ,
495
+ },
415
496
},
416
497
{
417
498
name : "single condensed UpdateEffectFail UpdateError" ,
@@ -621,6 +702,13 @@ func TestUpdateClusterVersionStatus_FilteringMultipleErrorsForFailingCondition(t
621
702
if diff := cmp .Diff (expectedCondition , condition , ignoreLastTransitionTime ); diff != "" {
622
703
t .Errorf ("unexpected condition when Reconciling == %t && isHistoryEmpty == %t\n :%s" , c .isReconciling , c .isHistoryEmpty , diff )
623
704
}
705
+
706
+ if tc .expectedProgressingCondition != nil && ! c .isReconciling && ! c .isHistoryEmpty {
707
+ progressingCondition := resourcemerge .FindOperatorStatusCondition (cvStatus .Conditions , configv1 .OperatorProgressing )
708
+ if diff := cmp .Diff (tc .expectedProgressingCondition , progressingCondition , ignoreLastTransitionTime ); diff != "" {
709
+ t .Errorf ("unexpected progressingCondition when Reconciling == %t && isHistoryEmpty == %t\n :%s" , c .isReconciling , c .isHistoryEmpty , diff )
710
+ }
711
+ }
624
712
}
625
713
})
626
714
}
0 commit comments