Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an e2e test to verify that canary weight is reinitialized to zero #13

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions tests/data/route_with_weights.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: v1
kind: Service
metadata:
name: rollouts-demo-stable
spec:
ports:
- port: 8080
targetPort: http
protocol: TCP
name: http
selector:
app: rollouts-demo

---
apiVersion: v1
kind: Service
metadata:
name: rollouts-demo-canary
spec:
ports:
- port: 8080
targetPort: http
protocol: TCP
name: http
selector:
app: rollouts-demo

---

kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: rollouts-demo
annotations:
haproxy.router.openshift.io/disable_cookies: "true"
spec:
to:
kind: Service
name: rollouts-demo-stable
weight: 50
alternateBackends:
- kind: Service
name: rollouts-demo-canary
weight: 50
port:
targetPort: http
wildcardPolicy: None
41 changes: 41 additions & 0 deletions tests/data/sample_rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
spec:
replicas: 5
strategy:
canary:
canaryService: rollouts-demo-canary
stableService: rollouts-demo-stable
steps:
- setWeight: 20
- pause: {}
- setWeight: 70
- pause: {}
trafficRouting:
plugins:
argoproj-labs/openshift:
routes:
- rollouts-demo
namespace: argo-rollouts-e2e
revisionHistoryLimit: 2
selector:
matchLabels:
app: rollouts-demo
template:
metadata:
labels:
app: rollouts-demo
spec:
containers:
- name: rollouts-demo
image: quay.io/nginx/nginx-unprivileged
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 5m
29 changes: 29 additions & 0 deletions tests/e2e/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,35 @@ var _ = Describe("OpenShift Route Traffic Plugin Tests", func() {
Expect(err).ToNot(HaveOccurred())
})

It("should initialize the canary weight to zero when a Rollout is created", func() {
By("create a Route with predefined weights for stable and canary")
err := fixtures.ApplyResources("../data/route_with_weights.yaml", namespace)
Expect(err).ToNot(HaveOccurred())

By("Route should retain the weights set for canary and stable")
route := &routeapi.Route{
ObjectMeta: metav1.ObjectMeta{
Name: "rollouts-demo",
Namespace: namespace,
},
}
Eventually(route, "30s", "1s").Should(routeFixture.HaveWeights(50, 50))

By("apply the Rollout and verify if the weights have been reinitialized")
err = fixtures.ApplyResources("../data/sample_rollout.yaml", namespace)
Expect(err).ToNot(HaveOccurred())

rollout, err := rolloutClient.ArgoprojV1alpha1().Rollouts(namespace).Get(
ctx,
rolloutName,
metav1.GetOptions{},
)
Expect(err).ToNot(HaveOccurred())
Eventually(rollout, "60s", "1s").Should(rolloutFixture.HavePhase(rolloutsv1alpha1.RolloutPhaseHealthy))

Eventually(route, "30s", "1s").Should(routeFixture.HaveWeights(100, 0))
})

It("should handle a Rollout with multiple steps", func() {
err := fixtures.ApplyResources("../data/single_route.yaml", namespace)
Expect(err).ToNot(HaveOccurred())
Expand Down
Loading