Skip to content

Commit

Permalink
Add unit test for a case where stableRS is not yet ready so we should…
Browse files Browse the repository at this point in the history
…nt patch the DestinationRule
  • Loading branch information
erickbitso committed Aug 1, 2024
1 parent c89f7ba commit b02cfe6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions rollout/trafficrouting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

"github.com/argoproj/argo-rollouts/rollout/trafficrouting"
"github.com/argoproj/argo-rollouts/rollout/trafficrouting/apisix"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -232,6 +233,40 @@ func TestRolloutUseDesiredWeight(t *testing.T) {
f.run(getKey(r2, t))
}

func TestReconcileTrafficRoutingStableRSAvailability(t *testing.T) {

steps := []v1alpha1.CanaryStep{
{
SetWeight: pointer.Int32Ptr(10),
},
}

r := newCanaryRollout("foo", 10, nil, steps, pointer.Int32Ptr(1), intstr.FromInt(1), intstr.FromInt(0))
r.Spec.Strategy.Canary.TrafficRouting = &v1alpha1.RolloutTrafficRouting{
Istio: &v1alpha1.IstioTrafficRouting{},
}
roCtx := &rolloutContext{
rollout: r,
log: logutil.WithRollout(r),
}

// Create a function that implements this func(roCtx *rolloutContext) ([]trafficrouting.TrafficRoutingReconciler, error)
roCtx.newTrafficRoutingReconciler = func(roCtx *rolloutContext) ([]trafficrouting.TrafficRoutingReconciler, error) {

return []trafficrouting.TrafficRoutingReconciler{
newUnmockedFakeTrafficRoutingReconciler(),
}, nil
}

r1 := newCanaryRollout("foo", 10, nil, steps, pointer.Int32Ptr(2), intstr.FromInt(1), intstr.FromInt(0))
rs1 := newReplicaSetWithStatus(r1, 10, 0)
roCtx.stableRS = rs1

err := roCtx.reconcileTrafficRouting()
assert.NoError(t, err)

}

func TestRolloutUseDesiredWeight100(t *testing.T) {
f := newFixture(t)
defer f.Close()
Expand Down

0 comments on commit b02cfe6

Please sign in to comment.