Skip to content

Commit

Permalink
test(canary): fix case TestRollBackToActiveReplicaSetWithinWindow
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Chen <[email protected]>
  • Loading branch information
amazingandyyy committed Aug 16, 2023
1 parent be07a73 commit ff373d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions rollout/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions rollout/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ff373d5

Please sign in to comment.