Skip to content

Commit b772ec2

Browse files
test: added advanced header based tests
Signed-off-by: Kostis Kapelonis <kostis.kapelonis@octopus.com>
1 parent 57c4e4a commit b772ec2

18 files changed

Lines changed: 556 additions & 0 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GRPCRoute
3+
metadata:
4+
name: grpcroute-header-advanced
5+
namespace: default
6+
spec:
7+
(length(rules)): 1
8+
rules:
9+
- backendRefs:
10+
- name: argo-rollouts-stable-service
11+
- name: argo-rollouts-canary-service
12+
(weight): 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GRPCRoute
3+
metadata:
4+
name: grpcroute-header-advanced
5+
namespace: default
6+
spec:
7+
(length(rules)): 2
8+
rules:
9+
- backendRefs:
10+
- name: argo-rollouts-stable-service
11+
(weight): 70
12+
- name: argo-rollouts-canary-service
13+
(weight): 30
14+
- name: canary-route1
15+
matches:
16+
- headers:
17+
- name: X-Test
18+
type: Exact
19+
value: test
20+
backendRefs:
21+
- name: argo-rollouts-canary-service
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GRPCRoute
3+
metadata:
4+
name: grpcroute-header-advanced
5+
namespace: default
6+
spec:
7+
(length(rules)): 3
8+
rules:
9+
- backendRefs:
10+
- name: argo-rollouts-stable-service
11+
(weight): 40
12+
- name: argo-rollouts-canary-service
13+
(weight): 60
14+
- name: canary-route1
15+
matches:
16+
- headers:
17+
- name: X-Test
18+
type: Exact
19+
value: test
20+
backendRefs:
21+
- name: argo-rollouts-canary-service
22+
- name: canary-route2
23+
matches:
24+
- headers:
25+
- name: X-Version
26+
type: Exact
27+
value: v2
28+
backendRefs:
29+
- name: argo-rollouts-canary-service
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GRPCRoute
3+
metadata:
4+
name: grpcroute-header-advanced
5+
namespace: default
6+
spec:
7+
(length(rules)): 3
8+
rules:
9+
- backendRefs:
10+
- name: argo-rollouts-stable-service
11+
(weight): 10
12+
- name: argo-rollouts-canary-service
13+
(weight): 90
14+
# Issue #158: Header-based routes should NOT have their weights updated
15+
# They should maintain a single canary backendRef (weight stays at 1, not updated to match setWeight)
16+
- name: canary-route1
17+
matches:
18+
- headers:
19+
- name: X-Test
20+
type: Exact
21+
value: test
22+
backendRefs:
23+
- name: argo-rollouts-canary-service
24+
(weight): 1
25+
- name: canary-route2
26+
matches:
27+
- headers:
28+
- name: X-Version
29+
type: Exact
30+
value: v2
31+
backendRefs:
32+
- name: argo-rollouts-canary-service
33+
(weight): 1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GRPCRoute
3+
metadata:
4+
name: grpcroute-header-advanced
5+
namespace: default
6+
spec:
7+
(length(rules)): 1
8+
rules:
9+
- backendRefs:
10+
- name: argo-rollouts-stable-service
11+
- name: argo-rollouts-canary-service
12+
(weight): 0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Rollout
3+
metadata:
4+
name: grpcroute-header-advanced-rollout
5+
namespace: default
6+
status:
7+
(phase): Healthy
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
apiVersion: chainsaw.kyverno.io/v1alpha1
2+
kind: Test
3+
metadata:
4+
name: advanced-header-based-grpcroute
5+
labels:
6+
route-type: grpc
7+
test-scope: headers
8+
spec:
9+
description: >
10+
Verifies that header-based routes are not affected by setWeight operations (issue #158).
11+
The plugin must maintain header-match rules with a single canary backendRef (no weight)
12+
regardless of subsequent setWeight calls. This test creates two header routes at different
13+
weight stages (30% and 60%) and verifies they remain unchanged when weight increases to 90%.
14+
namespace: default
15+
concurrent: false
16+
17+
steps:
18+
- name: create-resources
19+
description: Create the GRPCRoute and Rollout with multiple setWeight and setHeaderRoute steps.
20+
try:
21+
- apply:
22+
file: resources/grpcroute.yaml
23+
- apply:
24+
file: resources/rollout.yaml
25+
26+
- name: assert-initial-state
27+
description: Plugin initializes the GRPCRoute with 1 rule and canary weight 0.
28+
try:
29+
- assert:
30+
timeout: 30s
31+
file: assertions/grpcroute-initial.yaml
32+
33+
- name: wait-for-initial-healthy
34+
description: Wait for the initial rollout to reach Healthy before triggering a canary.
35+
try:
36+
- assert:
37+
timeout: 5m
38+
file: assertions/rollout-healthy.yaml
39+
40+
- name: trigger-canary
41+
description: Update the rollout image to start a canary (setWeight:30 -> setHeaderRoute -> pause).
42+
try:
43+
- patch:
44+
resource:
45+
apiVersion: argoproj.io/v1alpha1
46+
kind: Rollout
47+
metadata:
48+
name: grpcroute-header-advanced-rollout
49+
namespace: default
50+
spec:
51+
template:
52+
spec:
53+
containers:
54+
- name: rollouts-demo
55+
image: argoproj/rollouts-demo:green
56+
57+
- name: assert-first-header-routing-active
58+
description: After setWeight:30 and first header route, verify 1 weight rule + 1 header rule.
59+
try:
60+
- assert:
61+
timeout: 2m
62+
file: assertions/grpcroute-after-first-header.yaml
63+
64+
- name: assert-second-header-routing-active
65+
description: After setWeight:60 and second header route, verify 1 weight rule + 2 header rules.
66+
try:
67+
- assert:
68+
timeout: 2m
69+
file: assertions/grpcroute-after-second-header.yaml
70+
71+
- name: assert-weight-90-header-routes-unchanged
72+
description: >
73+
After setWeight:90, verify that header routes are NOT updated.
74+
This is the key assertion for issue #158 - header routes should maintain
75+
their single canary backendRef with no weight, regardless of setWeight calls.
76+
try:
77+
- assert:
78+
timeout: 2m
79+
file: assertions/grpcroute-after-weight-90.yaml
80+
81+
- name: assert-rollout-healthy
82+
description: Wait for the canary to complete (all pauses auto-expire).
83+
try:
84+
- assert:
85+
timeout: 5m
86+
file: assertions/rollout-healthy.yaml
87+
88+
- name: assert-cleanup
89+
description: Plugin must remove all header-match rules and reset canary weight to 0 after rollout completes.
90+
try:
91+
- assert:
92+
timeout: 60s
93+
file: assertions/grpcroute-after-cleanup.yaml
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GRPCRoute
3+
metadata:
4+
name: grpcroute-header-advanced
5+
namespace: default
6+
spec:
7+
parentRefs:
8+
- name: traefik-gateway
9+
namespace: default
10+
rules:
11+
- backendRefs:
12+
- name: argo-rollouts-stable-service
13+
port: 80
14+
- name: argo-rollouts-canary-service
15+
port: 80
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Rollout
3+
metadata:
4+
name: grpcroute-header-advanced-rollout
5+
namespace: default
6+
spec:
7+
replicas: 2
8+
strategy:
9+
canary:
10+
canaryService: argo-rollouts-canary-service
11+
stableService: argo-rollouts-stable-service
12+
trafficRouting:
13+
managedRoutes:
14+
- name: canary-route1
15+
- name: canary-route2
16+
plugins:
17+
argoproj-labs/gatewayAPI:
18+
grpcRoutes:
19+
- name: grpcroute-header-advanced
20+
useHeaderRoutes: true
21+
namespace: default
22+
steps:
23+
- setWeight: 30
24+
- setHeaderRoute:
25+
name: canary-route1
26+
match:
27+
- headerName: X-Test
28+
headerValue:
29+
exact: test
30+
- pause: {duration: 30s}
31+
- setWeight: 60
32+
- setHeaderRoute:
33+
name: canary-route2
34+
match:
35+
- headerName: X-Version
36+
headerValue:
37+
exact: v2
38+
- pause: {duration: 30s}
39+
- setWeight: 90
40+
- pause: {duration: 30s}
41+
revisionHistoryLimit: 2
42+
selector:
43+
matchLabels:
44+
app: rollouts-demo
45+
template:
46+
metadata:
47+
labels:
48+
app: rollouts-demo
49+
spec:
50+
containers:
51+
- name: rollouts-demo
52+
image: argoproj/rollouts-demo:red
53+
ports:
54+
- name: http
55+
containerPort: 8080
56+
protocol: TCP
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: httproute-header-advanced
5+
namespace: default
6+
spec:
7+
(length(rules)): 1
8+
rules:
9+
- backendRefs:
10+
- name: argo-rollouts-stable-service
11+
- name: argo-rollouts-canary-service
12+
(weight): 0

0 commit comments

Comments
 (0)