From ff373d5873dcfa79326241a3407b2a2c4a485710 Mon Sep 17 00:00:00 2001 From: Andy Chen Date: Wed, 16 Aug 2023 10:12:11 -0700 Subject: [PATCH] test(canary): fix case TestRollBackToActiveReplicaSetWithinWindow Signed-off-by: Andy Chen --- rollout/canary.go | 2 -- rollout/canary_test.go | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rollout/canary.go b/rollout/canary.go index 24460caf1e..d958aea94d 100644 --- a/rollout/canary.go +++ b/rollout/canary.go @@ -365,8 +365,6 @@ func (c *rolloutContext) syncRolloutStatusCanary() error { c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: "SkipSteps"}, "Rollback to stable ReplicaSets") newStatus.CurrentStepIndex = &stepCount } else if c.isRollbackWithinWindow() && replicasetutil.IsActive(c.newRS) { - // Else if we get here we detected that we are within the rollback window - // we can skip steps and move back to the active ReplicaSet c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: "SkipSteps"}, "Rollback to active ReplicaSets within RollbackWindow") newStatus.CurrentStepIndex = &stepCount } diff --git a/rollout/canary_test.go b/rollout/canary_test.go index 3e6b57be51..b660062771 100644 --- a/rollout/canary_test.go +++ b/rollout/canary_test.go @@ -860,25 +860,25 @@ func TestRollBackToActiveReplicaSetWithinWindow(t *testing.T) { } rs1 := newReplicaSetWithStatus(r1, 10, 10) - rs1.CreationTimestamp = metav1.Time{Time: time.Now().Add(-10 * time.Minute)} + rs1.CreationTimestamp = metav1.NewTime(time.Now().Add(-1 * time.Hour).Truncate(time.Second)) r2 := bumpVersion(r1) rs2 := newReplicaSetWithStatus(r2, 10, 10) - rs2.CreationTimestamp = metav1.Time{Time: time.Now().Add(-1 * time.Minute)} + rs2.CreationTimestamp = metav1.NewTime(time.Now().Truncate(time.Second)) r2.Spec.Template = r1.Spec.Template - rs2PodHash := rs2.Labels[v1alpha1.DefaultRolloutUniqueLabelKey] + rs1PodHash := rs1.Labels[v1alpha1.DefaultRolloutUniqueLabelKey] f.kubeobjects = append(f.kubeobjects, rs1, rs2) f.replicaSetLister = append(f.replicaSetLister, rs1, rs2) - r2 = updateCanaryRolloutStatus(r2, rs2PodHash, 10, 10, 10, false) + r2 = updateCanaryRolloutStatus(r2, rs1PodHash, 20, 10, 20, false) f.rolloutLister = append(f.rolloutLister, r2) f.objects = append(f.objects, r2) updatedRSIndex := f.expectUpdateReplicaSetAction(rs1) f.expectUpdateReplicaSetAction(rs1) - patchIndex := f.expectPatchRolloutAction(r2) + patchIndex := f.expectPatchRolloutAction(r1) f.run(getKey(r2, t)) expectedRS1 := rs1.DeepCopy()