Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: zachaller <[email protected]>
  • Loading branch information
zachaller committed Aug 19, 2022
1 parent a126e36 commit 7a4492c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 3 additions & 1 deletion rollout/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ func newPausedCondition(isPaused bool) (v1alpha1.RolloutCondition, string) {

func newHealthyCondition(isCompleted bool) (v1alpha1.RolloutCondition, string) {
status := corev1.ConditionTrue
msg := conditions.RolloutHealthyAndCompletedMessage
if !isCompleted {
status = corev1.ConditionFalse
msg = conditions.RolloutNotHealthyAndCompletedMessage
}
condition := v1alpha1.RolloutCondition{
LastTransitionTime: timeutil.MetaNow(),
LastUpdateTime: timeutil.MetaNow(),
Message: conditions.RolloutHealthyAndCompletedReason,
Message: msg,
Reason: conditions.RolloutHealthyAndCompletedReason,
Status: status,
Type: v1alpha1.HealthyAndCompleted,
Expand Down
8 changes: 1 addition & 7 deletions rollout/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ func TestBlueGreenAWSVerifyTargetGroupsNotYetReady(t *testing.T) {
assert.Equal(t, expectedPatch, patch)
f.assertEvents([]string{
conditions.TargetGroupUnverifiedReason,
conditions.RolloutHealthyAndCompletedReason,
})
}

Expand Down Expand Up @@ -411,7 +410,6 @@ func TestBlueGreenAWSVerifyTargetGroupsReady(t *testing.T) {
f.assertEvents([]string{
conditions.TargetGroupVerifiedReason,
conditions.RolloutCompletedReason,
conditions.RolloutHealthyAndCompletedReason,
})
}

Expand Down Expand Up @@ -509,7 +507,6 @@ func TestCanaryAWSVerifyTargetGroupsNotYetReady(t *testing.T) {
f.run(getKey(r2, t))
f.assertEvents([]string{
conditions.TargetGroupUnverifiedReason,
conditions.RolloutHealthyAndCompletedReason,
})
}

Expand Down Expand Up @@ -608,7 +605,6 @@ func TestCanaryAWSVerifyTargetGroupsReady(t *testing.T) {
f.verifyPatchedReplicaSet(scaleDownRSIndex, 30)
f.assertEvents([]string{
conditions.TargetGroupVerifiedReason,
conditions.RolloutHealthyAndCompletedReason,
})
}

Expand Down Expand Up @@ -665,9 +661,7 @@ func TestCanaryAWSVerifyTargetGroupsSkip(t *testing.T) {
f.ingressLister = append(f.ingressLister, ingressutil.NewLegacyIngress(ing))

f.run(getKey(r2, t)) // there should be no api calls
f.assertEvents([]string{
conditions.RolloutHealthyAndCompletedReason,
})
f.assertEvents(nil)
}

// TestShouldVerifyTargetGroups returns whether or not we should verify the target group
Expand Down
8 changes: 5 additions & 3 deletions rollout/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,10 +926,12 @@ func (c *rolloutContext) promoteStable(newStatus *v1alpha1.RolloutStatus, reason
}
newStatus.StableRS = newStatus.CurrentPodHash
revision, _ := replicasetutil.Revision(c.rollout)
c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: conditions.RolloutCompletedReason},
conditions.RolloutCompletedMessage, revision, newStatus.CurrentPodHash, reason)
if conditions.RolloutComplete(c.rollout, newStatus) {
updateCompletedCond := conditions.NewRolloutCondition(v1alpha1.RolloutCompleted, corev1.ConditionTrue, conditions.RolloutCompletedReason, conditions.RolloutCompletedReason)
c.recorder.Eventf(c.rollout, record.EventOptions{EventReason: conditions.RolloutCompletedReason},
conditions.RolloutCompletedMessage, revision, newStatus.CurrentPodHash, reason)

updateCompletedCond := conditions.NewRolloutCondition(v1alpha1.RolloutCompleted, corev1.ConditionTrue,
conditions.RolloutCompletedReason, fmt.Sprintf(conditions.RolloutCompletedMessage, revision, newStatus.CurrentPodHash, reason))
conditions.SetRolloutCondition(newStatus, *updateCompletedCond)
}
}
Expand Down

0 comments on commit 7a4492c

Please sign in to comment.