From bca55793768b001b7bd6e34503fbdc4d54e2cece Mon Sep 17 00:00:00 2001 From: BrunoTarijon Date: Mon, 4 Mar 2024 17:01:01 -0300 Subject: [PATCH] add e2e test Signed-off-by: BrunoTarijon --- rollout/canary.go | 1 + test/e2e/canary_test.go | 18 +++ .../alb-canary-rollout-with-delay.yaml | 104 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 test/e2e/functional/alb-canary-rollout-with-delay.yaml diff --git a/rollout/canary.go b/rollout/canary.go index a3033fea02..d8107a492f 100644 --- a/rollout/canary.go +++ b/rollout/canary.go @@ -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 { diff --git a/test/e2e/canary_test.go b/test/e2e/canary_test.go index 8656aa5c4d..4262e2c605 100644 --- a/test/e2e/canary_test.go +++ b/test/e2e/canary_test.go @@ -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(). diff --git a/test/e2e/functional/alb-canary-rollout-with-delay.yaml b/test/e2e/functional/alb-canary-rollout-with-delay.yaml new file mode 100644 index 0000000000..8fa0e58696 --- /dev/null +++ b/test/e2e/functional/alb-canary-rollout-with-delay.yaml @@ -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}