Skip to content

Commit

Permalink
add e2e TestALBExperimentStepMultiIngress, TestALBExperimentStepNoSet…
Browse files Browse the repository at this point in the history
…WeightMultiIngress

Signed-off-by: n888 <[email protected]>
  • Loading branch information
n888 committed Apr 17, 2023
1 parent 3198108 commit fbe2843
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 1 deletion.
123 changes: 123 additions & 0 deletions test/e2e/alb/rollout-alb-multi-ingress-experiment-no-setweight.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
apiVersion: v1
kind: Service
metadata:
name: alb-rollout-root
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-rollout
---
apiVersion: v1
kind: Service
metadata:
name: alb-rollout-canary
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-rollout
---
apiVersion: v1
kind: Service
metadata:
name: alb-rollout-stable
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-rollout
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: alb-rollout-multi-ingress-1
annotations:
kubernetes.io/ingress.class: alb
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: alb-rollout-root
port:
name: use-annotation
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: alb-rollout-multi-ingress-2
annotations:
kubernetes.io/ingress.class: alb
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: alb-rollout-root
port:
name: use-annotation
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: alb-rollout
spec:
selector:
matchLabels:
app: alb-rollout
template:
metadata:
labels:
app: alb-rollout
spec:
containers:
- name: alb-rollout
image: nginx:1.19-alpine
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 16Mi
cpu: 5m
strategy:
canary:
canaryService: alb-rollout-canary
stableService: alb-rollout-stable
trafficRouting:
alb:
ingresses:
- alb-rollout-multi-ingress-1
- alb-rollout-multi-ingress-2
rootService: alb-rollout-root
servicePort: 80
steps:
- experiment:
duration: 15s
templates:
- name: experiment-alb-canary
specRef: canary
weight: 20
- name: experiment-alb-stable
specRef: stable
weight: 20
36 changes: 35 additions & 1 deletion test/e2e/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ func (s *AWSSuite) TestALBExperimentStepMultiIngress() {
Sleep(10 * time.Second).
Then().
Assert(func(t *fixtures.Then) {
//ingress := t.GetALBIngress()
ingresses := t.GetALBIngresses()
for _, ingress := range ingresses {
action, ok := ingress.Annotations["alb.ingress.kubernetes.io/actions.alb-rollout-root"]
Expand Down Expand Up @@ -272,6 +271,41 @@ func (s *AWSSuite) TestALBExperimentStepNoSetWeight() {
Assert(assertWeights(s, "alb-rollout-canary", "alb-rollout-stable", 0, 100))
}

func (s *AWSSuite) TestALBExperimentStepNoSetWeightMultiIngress() {
s.Given().
RolloutObjects("@alb/rollout-alb-multi-ingress-experiment-no-setweight.yaml").
When().
ApplyManifests().
WaitForRolloutStatus("Healthy").
Then().
Assert(assertWeightsMultiIngress(s, "alb-rollout-canary", "alb-rollout-stable", 0, 100)).
ExpectExperimentCount(0).
When().
UpdateSpec().
Sleep(10 * time.Second).
Then().
Assert(func(t *fixtures.Then) {
ingresses := t.GetALBIngresses()
for _, ingress := range ingresses {
action, ok := ingress.Annotations["alb.ingress.kubernetes.io/actions.alb-rollout-root"]
assert.True(s.T(), ok)

experiment := t.GetRolloutExperiments().Items[0]
exService1, exService2 := experiment.Status.TemplateStatuses[0].ServiceName, experiment.Status.TemplateStatuses[1].ServiceName

port := 80
expectedAction := fmt.Sprintf(actionTemplateWithExperiments, "alb-rollout-canary", port, 0, exService1, port, 20, exService2, port, 20, "alb-rollout-stable", port, 60)
assert.Equal(s.T(), expectedAction, action)
}
}).
When().
PromoteRollout().
WaitForRolloutStatus("Healthy").
Sleep(2 * time.Second). // stable is currently set first, and then changes made to VirtualServices/DestinationRules
Then().
Assert(assertWeightsMultiIngress(s, "alb-rollout-canary", "alb-rollout-stable", 0, 100))
}

func (s *AWSSuite) TestAlbHeaderRoute() {
s.Given().
RolloutObjects("@header-routing/alb-header-route.yaml").
Expand Down

0 comments on commit fbe2843

Please sign in to comment.