-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: when Rollout has pingpong and stable/canary service defined, onl…
…y alb traffic management uses pingpong. (#3628) * fix: when Rollout has pingpong and stable/canary service defined, GetStableAndCanaryServices returns based on isPingpongPreferred. Only when it is ALB controller, then isPringpongPreferred is true. Signed-off-by: mayz985 <[email protected]> * fix lint error Signed-off-by: mayz985 <[email protected]> * added e2e Signed-off-by: mayz985 <[email protected]> --------- Signed-off-by: mayz985 <[email protected]>
- Loading branch information
1 parent
e20bcde
commit 7df3d17
Showing
8 changed files
with
310 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package trafficrouting | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" | ||
"github.com/stretchr/testify/assert" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const PING_SVC = "ping-service" | ||
const PONG_SVC = "pong-service" | ||
|
||
func fakeRollout(stableSvc, canarySvc string, pingPong *v1alpha1.PingPongSpec, stableIng string, port int32) *v1alpha1.Rollout { | ||
return &v1alpha1.Rollout{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "rollout", | ||
Namespace: metav1.NamespaceDefault, | ||
}, | ||
Spec: v1alpha1.RolloutSpec{ | ||
Strategy: v1alpha1.RolloutStrategy{ | ||
Canary: &v1alpha1.CanaryStrategy{ | ||
StableService: stableSvc, | ||
CanaryService: canarySvc, | ||
PingPong: pingPong, | ||
TrafficRouting: &v1alpha1.RolloutTrafficRouting{ | ||
ALB: &v1alpha1.ALBTrafficRouting{ | ||
Ingress: stableIng, | ||
ServicePort: port, | ||
}, | ||
Istio: &v1alpha1.IstioTrafficRouting{ | ||
VirtualService: &v1alpha1.IstioVirtualService{ | ||
Name: "istio-vsvc", | ||
}, | ||
DestinationRule: &v1alpha1.IstioDestinationRule{ | ||
Name: "istio-destrule", | ||
CanarySubsetName: "canary", | ||
StableSubsetName: "stable", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func TestGetStableAndCanaryServices(t *testing.T) { | ||
// Rollout has no pingPong | ||
rollout := fakeRollout("stable-service", "canary-service", nil, "stable-ingress", 443) | ||
|
||
stableService, canaryService := GetStableAndCanaryServices(rollout, true) | ||
assert.Equal(t, "stable-service", stableService) | ||
assert.Equal(t, "canary-service", canaryService) | ||
|
||
stableService, canaryService = GetStableAndCanaryServices(rollout, false) | ||
assert.Equal(t, "stable-service", stableService) | ||
assert.Equal(t, "canary-service", canaryService) | ||
|
||
// Rollout has pingPong and stable/canary | ||
pp := &v1alpha1.PingPongSpec{PingService: PING_SVC, PongService: PONG_SVC} | ||
rollout = fakeRollout("stable-service", "canary-service", pp, "stable-ingress", 443) | ||
|
||
stableService, canaryService = GetStableAndCanaryServices(rollout, true) | ||
assert.Equal(t, PONG_SVC, stableService) | ||
assert.Equal(t, PING_SVC, canaryService) | ||
|
||
stableService, canaryService = GetStableAndCanaryServices(rollout, false) | ||
assert.Equal(t, "stable-service", stableService) | ||
assert.Equal(t, "canary-service", canaryService) | ||
|
||
// Rollout has pingPong, no stable/canary | ||
rollout = fakeRollout("", "", pp, "stable-ingress", 443) | ||
|
||
stableService, canaryService = GetStableAndCanaryServices(rollout, true) | ||
assert.Equal(t, PONG_SVC, stableService) | ||
assert.Equal(t, PING_SVC, canaryService) | ||
|
||
stableService, canaryService = GetStableAndCanaryServices(rollout, false) | ||
assert.Equal(t, PONG_SVC, stableService) | ||
assert.Equal(t, PING_SVC, canaryService) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.