Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: BrunoTarijon <[email protected]>
  • Loading branch information
BrunoTarijon authored and zachaller committed Aug 2, 2024
1 parent 708db68 commit bca5579
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions rollout/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (c *rolloutContext) scaleDownOldReplicaSetsForCanary(oldRSs []*appsv1.Repli
if c.rollout.Spec.Strategy.Canary.TrafficRouting != nil && c.isReplicaSetReferenced(targetRS) {
// We might get here if user interrupted an an update in order to move back to stable.
c.log.Infof("Skip scale down of older RS '%s': still referenced", targetRS.Name)
c.reconcileStableAndCanaryService()
continue
}
if maxScaleDown <= 0 {
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,24 @@ spec:
ExpectCanaryStablePodCount(2, 4)
}

func (s *CanarySuite) TestRolloutScalingWithServiceSwitchDelay() {
s.Given().
RolloutObjects(`@functional/alb-canary-rollout-with-delay.yaml`).
When().
ApplyManifests().
WaitForRolloutStatus("Healthy").
UpdateSpec().
WaitForRolloutStatus("Paused").
UpdateSpec().
Sleep(1*time.Second).
ScaleRollout(3).
WaitForRolloutStatus("Paused").
Then().
ExpectRevisionPodCount("1", 3).
ExpectRevisionPodCount("2", 0).
ExpectRevisionPodCount("3", 1)
}

// TestReduceWeightAndHonorMaxUnavailable verifies we honor maxUnavailable when decreasing weight or aborting
func (s *CanarySuite) TestReduceWeightAndHonorMaxUnavailable() {
s.Given().
Expand Down
104 changes: 104 additions & 0 deletions test/e2e/functional/alb-canary-rollout-with-delay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: v1
kind: Service
metadata:
name: alb-canary-with-delay-root
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-canary-with-delay
---
apiVersion: v1
kind: Service
metadata:
name: alb-canary-with-delay-desired
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-canary-with-delay
---
apiVersion: v1
kind: Service
metadata:
name: alb-canary-with-delay-stable
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-canary-with-delay
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: alb-canary-with-delay-ingress
annotations:
kubernetes.io/ingress.class: alb
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: alb-canary-with-delay-root
port:
name: use-annotation
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: alb-canary-with-delay
spec:
selector:
matchLabels:
app: alb-canary-with-delay
template:
metadata:
labels:
app: alb-canary-with-delay
spec:
containers:
- name: alb-canary-with-delay
lifecycle:
postStart:
exec:
command:
- sleep
- "2"
image: nginx:1.19-alpine
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 16Mi
cpu: 5m
strategy:
canary:
canaryService: alb-canary-with-delay-desired
stableService: alb-canary-with-delay-stable
trafficRouting:
alb:
ingress: alb-canary-with-delay-ingress
rootService: alb-canary-with-delay-root
servicePort: 80
steps:
- setWeight: 10
- pause: {duration: 5s}
- setWeight: 20
- pause: {duration: 5s}

0 comments on commit bca5579

Please sign in to comment.