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,12 @@ 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" },
397
409
Failure : & payload.UpdateError {
398
410
UpdateEffect : payload .UpdateEffectNone ,
399
411
Reason : "ClusterOperatorUpdating" ,
400
412
Message : "Cluster operator A is updating" ,
413
+ Name : "co-not-timeout" ,
401
414
},
402
415
},
403
416
},
@@ -412,6 +425,76 @@ func TestUpdateClusterVersionStatus_FilteringMultipleErrorsForFailingCondition(t
412
425
Type : ClusterStatusFailing ,
413
426
Status : configv1 .ConditionFalse ,
414
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 .ConditionUnknown ,
458
+ Reason : "SlowClusterOperator" ,
459
+ Message : "waiting on co-timeout over 30 minutes which is longer than expected" ,
460
+ },
461
+ expectedProgressingCondition : & configv1.ClusterOperatorStatusCondition {
462
+ Type : configv1 .OperatorProgressing ,
463
+ Status : configv1 .ConditionTrue ,
464
+ Reason : "ClusterOperatorUpdating" ,
465
+ Message : "Working towards 1.2.3: waiting on co-timeout over 30 minutes which is longer than expected" ,
466
+ },
467
+ },
468
+ {
469
+ name : "single UpdateEffectNone error and machine-config" ,
470
+ args : args {
471
+ syncWorkerStatus : & SyncWorkerStatus {
472
+ Actual : configv1.Release {Version : "1.2.3" },
473
+ Failure : & payload.UpdateError {
474
+ UpdateEffect : payload .UpdateEffectNone ,
475
+ Reason : "ClusterOperatorUpdating" ,
476
+ Message : "Cluster operator A is updating" ,
477
+ Name : "machine-config" ,
478
+ },
479
+ },
480
+ },
481
+ expectedConditionNotModified : & configv1.ClusterOperatorStatusCondition {
482
+ Type : ClusterStatusFailing ,
483
+ Status : configv1 .ConditionTrue ,
484
+ Reason : "ClusterOperatorUpdating" ,
485
+ Message : "Cluster operator A is updating" ,
486
+ },
487
+ shouldModifyWhenNotReconcilingAndHistoryNotEmpty : true ,
488
+ expectedConditionModified : & configv1.ClusterOperatorStatusCondition {
489
+ Type : ClusterStatusFailing ,
490
+ Status : configv1 .ConditionFalse ,
491
+ },
492
+ expectedProgressingCondition : & configv1.ClusterOperatorStatusCondition {
493
+ Type : configv1 .OperatorProgressing ,
494
+ Status : configv1 .ConditionTrue ,
495
+ Reason : "ClusterOperatorUpdating" ,
496
+ Message : "Working towards 1.2.3: waiting on machine-config" ,
497
+ },
415
498
},
416
499
{
417
500
name : "single condensed UpdateEffectFail UpdateError" ,
@@ -621,6 +704,13 @@ func TestUpdateClusterVersionStatus_FilteringMultipleErrorsForFailingCondition(t
621
704
if diff := cmp .Diff (expectedCondition , condition , ignoreLastTransitionTime ); diff != "" {
622
705
t .Errorf ("unexpected condition when Reconciling == %t && isHistoryEmpty == %t\n :%s" , c .isReconciling , c .isHistoryEmpty , diff )
623
706
}
707
+
708
+ if tc .expectedProgressingCondition != nil && ! c .isReconciling && ! c .isHistoryEmpty {
709
+ progressingCondition := resourcemerge .FindOperatorStatusCondition (cvStatus .Conditions , configv1 .OperatorProgressing )
710
+ if diff := cmp .Diff (tc .expectedProgressingCondition , progressingCondition , ignoreLastTransitionTime ); diff != "" {
711
+ t .Errorf ("unexpected progressingCondition when Reconciling == %t && isHistoryEmpty == %t\n :%s" , c .isReconciling , c .isHistoryEmpty , diff )
712
+ }
713
+ }
624
714
}
625
715
})
626
716
}
0 commit comments