Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: zachaller <[email protected]>
  • Loading branch information
zachaller committed Jun 24, 2022
1 parent 0677680 commit fffd89d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 10 additions & 2 deletions rollout/trafficrouting.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,17 @@ func (c *rolloutContext) reconcileTrafficRouting() error {
}
if weightVerified != nil {
if *weightVerified {
c.log.Infof("Desired weight (stepIdx: %d) %d verified", *index, desiredWeight)
if index != nil {
c.log.Infof("Desired weight (stepIdx: %d) %d verified", *index, desiredWeight)
} else {
c.log.Infof("Desired weight (stepIdx: n/a) %d verified", desiredWeight)
}
} else {
c.log.Infof("Desired weight (stepIdx: %d) %d not yet verified", *index, desiredWeight)
if index != nil {
c.log.Infof("Desired weight (stepIdx: %d) %d verified", *index, desiredWeight)
} else {
c.log.Infof("Desired weight (stepIdx: n/a) %d verified", desiredWeight)
}
c.enqueueRolloutAfter(c.rollout, defaults.GetRolloutVerifyRetryInterval())
}
}
Expand Down
13 changes: 8 additions & 5 deletions rollout/trafficrouting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestRolloutUseDesiredWeight(t *testing.T) {
return nil
})
f.fakeTrafficRouting.On("SetHeaderRouting", mock.Anything, mock.Anything).Return(nil)
f.fakeTrafficRouting.On("VerifyWeight", mock.Anything).Return(true, nil)
f.fakeTrafficRouting.On("VerifyWeight", mock.Anything).Return(pointer.BoolPtr(true), nil)
f.run(getKey(r2, t))
}

Expand Down Expand Up @@ -224,7 +224,7 @@ func TestRolloutUseDesiredWeight100(t *testing.T) {
return nil
})
f.fakeTrafficRouting.On("SetHeaderRouting", mock.Anything, mock.Anything).Return(nil)
f.fakeTrafficRouting.On("VerifyWeight", mock.Anything).Return(true, nil)
f.fakeTrafficRouting.On("VerifyWeight", mock.Anything).Return(pointer.BoolPtr(true), nil)
f.run(getKey(r2, t))
}

Expand Down Expand Up @@ -718,7 +718,9 @@ func TestCanaryWithTrafficRoutingAddScaleDownDelay(t *testing.T) {
f := newFixture(t)
defer f.Close()

r1 := newCanaryRollout("foo", 1, nil, nil, pointer.Int32Ptr(1), intstr.FromInt(1), intstr.FromInt(1))
r1 := newCanaryRollout("foo", 1, nil, []v1alpha1.CanaryStep{{
SetWeight: pointer.Int32Ptr(10),
}}, pointer.Int32Ptr(0), intstr.FromInt(1), intstr.FromInt(1))
r1.Spec.Strategy.Canary.CanaryService = "canary"
r1.Spec.Strategy.Canary.StableService = "stable"
r1.Spec.Strategy.Canary.TrafficRouting = &v1alpha1.RolloutTrafficRouting{
Expand All @@ -730,7 +732,6 @@ func TestCanaryWithTrafficRoutingAddScaleDownDelay(t *testing.T) {
rs2PodHash := rs2.Labels[v1alpha1.DefaultRolloutUniqueLabelKey]
r2 = updateCanaryRolloutStatus(r2, rs2PodHash, 2, 1, 2, false)
r2.Status.ObservedGeneration = strconv.Itoa(int(r2.Generation))
r2.Status.CurrentStepIndex = nil
availableCondition, _ := newAvailableCondition(true)
conditions.SetRolloutCondition(&r2.Status, availableCondition)
_, r2.Status.Canary.Weights = calculateWeightStatus(r2, rs2PodHash, rs2PodHash, 0)
Expand Down Expand Up @@ -758,7 +759,9 @@ func TestCanaryWithTrafficRoutingScaleDownLimit(t *testing.T) {

inTheFuture := timeutil.MetaNow().Add(10 * time.Second).UTC().Format(time.RFC3339)

r1 := newCanaryRollout("foo", 1, nil, nil, pointer.Int32Ptr(1), intstr.FromInt(1), intstr.FromInt(1))
r1 := newCanaryRollout("foo", 1, nil, []v1alpha1.CanaryStep{{
SetWeight: pointer.Int32Ptr(10),
}}, pointer.Int32Ptr(1), intstr.FromInt(1), intstr.FromInt(1))
rs1 := newReplicaSetWithStatus(r1, 1, 1)
rs1.Annotations[v1alpha1.DefaultReplicaSetScaleDownDeadlineAnnotationKey] = inTheFuture
r1.Spec.Strategy.Canary.ScaleDownDelayRevisionLimit = pointer.Int32Ptr(1)
Expand Down

0 comments on commit fffd89d

Please sign in to comment.