Skip to content

Commit

Permalink
fix: unavailable stable RS was not scaled down to make room for canary (
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesuen committed Sep 28, 2020
1 parent cb198b3 commit 8239dd7
Show file tree
Hide file tree
Showing 19 changed files with 540 additions and 154 deletions.
6 changes: 4 additions & 2 deletions test/e2e/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type AnalysisSuite struct {
}

func (s *AnalysisSuite) TestRolloutWithBackgroundAnalysis() {
s.T().Parallel()
s.Given().
RolloutObjects("@functional/analysistemplate-web-background.yaml").
RolloutObjects("@functional/rollout-background-analysis.yaml").
Expand All @@ -24,7 +25,7 @@ func (s *AnalysisSuite) TestRolloutWithBackgroundAnalysis() {
Then().
ExpectAnalysisRunCount(0).
When().
UpdateImage("argoproj/rollouts-demo:yellow").
UpdateSpec().
WaitForRolloutStatus("Paused").
Then().
ExpectAnalysisRunCount(1).
Expand All @@ -36,6 +37,7 @@ func (s *AnalysisSuite) TestRolloutWithBackgroundAnalysis() {
}

func (s *AnalysisSuite) TestRolloutWithInlineAnalysis() {
s.T().Parallel()
s.Given().
RolloutObjects("@functional/analysistemplate-echo-job.yaml").
RolloutObjects("@functional/rollout-inline-analysis.yaml").
Expand All @@ -45,7 +47,7 @@ func (s *AnalysisSuite) TestRolloutWithInlineAnalysis() {
Then().
ExpectAnalysisRunCount(0).
When().
UpdateImage("argoproj/rollouts-demo:yellow").
UpdateSpec().
WaitForRolloutStatus("Paused").
Then().
ExpectAnalysisRunCount(1).
Expand Down
97 changes: 88 additions & 9 deletions test/e2e/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ type CanarySuite struct {
fixtures.E2ESuite
}

func TestCanarySuite(t *testing.T) {
suite.Run(t, new(CanarySuite))
}

func (s *CanarySuite) TestCanarySetCanaryScale() {
s.T().Skip("skipping v0.10 feature")
s.T().Parallel()
canarySteps := `
- pause: {}
- setCanaryScale:
Expand All @@ -36,42 +41,116 @@ func (s *CanarySuite) TestCanarySetCanaryScale() {
When().
ApplyManifests().
WaitForRolloutStatus("Healthy").
UpdateImage("argoproj/rollouts-demo:yellow").
UpdateSpec().
// at step 0
WaitForRolloutStatus("Paused").
Then().
ExpectCanaryPodCount(0).
ExpectCanaryStablePodCount(0, 4).
When().
PromoteRollout().
WaitForRolloutCanaryStepIndex(2).
Then().
// at step 2
ExpectCanaryPodCount(1).
ExpectCanaryStablePodCount(1, 4).
When().
PromoteRollout().
WaitForRolloutCanaryStepIndex(4).
Then().
// at step 4
ExpectCanaryPodCount(1).
ExpectCanaryStablePodCount(1, 4).
When().
PromoteRollout().
WaitForRolloutCanaryStepIndex(6).
Then().
// at step 6
ExpectCanaryPodCount(3).
ExpectCanaryStablePodCount(3, 4).
When().
PromoteRollout().
WaitForRolloutCanaryStepIndex(8).
Then().
// at step 8
ExpectCanaryPodCount(2).
ExpectCanaryStablePodCount(2, 4).
When().
PromoteRollout().
WaitForRolloutStatus("Healthy").
Then().
ExpectCanaryPodCount(4)
ExpectCanaryStablePodCount(4, 4)
}

func TestCanarySuite(t *testing.T) {
suite.Run(t, new(CanarySuite))
// TestRolloutScalingWhenPaused verifies behavior when scaling a rollout up/down when paused
func (s *FunctionalSuite) TestRolloutScalingWhenPaused() {
s.Given().
RolloutObjects(`@functional/rollout-basic.yaml`).
SetSteps(`
- setWeight: 25
- pause: {}`).
When().
ApplyManifests().
WaitForRolloutStatus("Healthy").
UpdateSpec().
WaitForRolloutStatus("Paused").
Then().
ExpectCanaryStablePodCount(1, 1).
When().
ScaleRollout(8).
WaitForRolloutAvailableReplicas(8).
Then().
ExpectCanaryStablePodCount(2, 6).
When().
ScaleRollout(4).
WaitForRolloutAvailableReplicas(4).
Then().
ExpectCanaryStablePodCount(1, 3)
}

// TestRolloutScalingDuringUpdate verifies behavior when scaling a rollout up/down in middle of update
func (s *FunctionalSuite) TestRolloutScalingDuringUpdate() {
s.Given().
HealthyRollout(`
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: updatescaling
spec:
replicas: 4
strategy:
canary:
maxSurge: 2
maxUnavailable: 0
selector:
matchLabels:
app: updatescaling
template:
metadata:
labels:
app: updatescaling
spec:
containers:
- name: updatescaling
image: nginx:1.19-alpine
resources:
requests:
memory: 16Mi
cpu: 1m`).
When().
PatchSpec(`
spec:
template:
spec:
containers:
- name: updatescaling
command: [/bad-command]`).
WaitForRolloutReplicas(6).
Then().
ExpectCanaryStablePodCount(2, 4).
When().
ScaleRollout(8).
WaitForRolloutReplicas(10).
Then().
// NOTE: the numbers below may change in the future.
// See: https://github.com/argoproj/argo-rollouts/issues/738
ExpectCanaryStablePodCount(6, 4).
When().
ScaleRollout(4)
// WaitForRolloutReplicas(4) // this doesn't work yet (bug)
}
3 changes: 2 additions & 1 deletion test/e2e/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ExperimentSuite struct {
}

func (s *ExperimentSuite) TestRolloutWithExperiment() {
s.T().Parallel()
s.Given().
RolloutObjects("@functional/rollout-experiment.yaml").
When().
Expand All @@ -23,7 +24,7 @@ func (s *ExperimentSuite) TestRolloutWithExperiment() {
// TODO: verify there are no experiments
Then().
When().
UpdateImage("argoproj/rollouts-demo:yellow").
UpdateSpec().
// TODO: wait for experiment to start and complete successful
// TODO: verify pods
WaitForRolloutStatus("Paused").
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/functional/alb-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ spec:
spec:
containers:
- name: REPLACEME
image: argoproj/rollouts-demo:blue
image: nginx:1.19-alpine
ports:
- name: http
containerPort: 8080
containerPort: 80
protocol: TCP
resources:
requests:
memory: 32Mi
memory: 16Mi
cpu: 5m
strategy:
canary:
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/functional/analysis-run-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
spec:
containers:
- name: sleep
image: alpine:3.8
image: nginx:1.19-alpine
command: [sleep, "30"]
restartPolicy: Never
backoffLimit: 0
2 changes: 1 addition & 1 deletion test/e2e/functional/analysistemplate-echo-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
spec:
containers:
- name: sleep
image: alpine:3.12
image: nginx:1.19-alpine
command: [echo, done]
restartPolicy: Never
backoffLimit: 0
9 changes: 2 additions & 7 deletions test/e2e/functional/rollout-background-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ spec:
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:blue
args: [--termination-delay, "0"]
ports:
- name: http
containerPort: 8080
protocol: TCP
image: nginx:1.19-alpine
resources:
requests:
memory: 32Mi
memory: 16Mi
cpu: 5m
10 changes: 2 additions & 8 deletions test/e2e/functional/rollout-basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ spec:
app: basic
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:blue
imagePullPolicy: IfNotPresent
# reduce termination delay (default 10s) for e2e tests
args: [--termination-delay, "0"]
ports:
- name: http
containerPort: 8080
- name: basic
image: nginx:1.19-alpine
resources:
requests:
memory: 16Mi
Expand Down
36 changes: 0 additions & 36 deletions test/e2e/functional/rollout-container-resource-formats.yaml

This file was deleted.

9 changes: 2 additions & 7 deletions test/e2e/functional/rollout-experiment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ spec:
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:blue
args: [--termination-delay, "0"]
ports:
- name: http
containerPort: 8080
protocol: TCP
image: nginx:1.19-alpine
resources:
requests:
memory: 32Mi
memory: 16Mi
cpu: 5m
9 changes: 2 additions & 7 deletions test/e2e/functional/rollout-inline-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ spec:
spec:
containers:
- name: rollouts-demo
image: argoproj/rollouts-demo:blue
args: [--termination-delay, "0"]
ports:
- name: http
containerPort: 8080
protocol: TCP
image: nginx:1.19-alpine
resources:
requests:
memory: 32Mi
memory: 16Mi
cpu: 5m
Loading

0 comments on commit 8239dd7

Please sign in to comment.