Skip to content

Commit ec110c1

Browse files
authored
test(e2e/chainsaw): Add chainsaw test case for HTTPRoute extensionRef filter (#3004)
1 parent 8ab6ce3 commit ec110c1

12 files changed

+823
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# Assert httpbin Service exists
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: ($httpbin_service_name)
7+
namespace: ($httpbin_service_namespace)
8+
---
9+
# Assert httpbin Deployment is ready
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
metadata:
13+
name: ($httpbin_service_name)
14+
namespace: ($httpbin_service_namespace)
15+
status:
16+
# Filter conditions array to check for Available condition
17+
(conditions[?type == 'Available']):
18+
- status: 'True'
19+
readyReplicas: 1
20+
replicas: 1
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: ($httpbin_service_name)
6+
namespace: ($httpbin_service_namespace)
7+
labels:
8+
app: httpbin
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app: httpbin
14+
template:
15+
metadata:
16+
labels:
17+
app: httpbin
18+
spec:
19+
containers:
20+
- name: httpbin
21+
image: ghcr.io/mccutchen/go-httpbin:2.19
22+
ports:
23+
- name: http
24+
containerPort: 8080
25+
protocol: TCP
26+
livenessProbe:
27+
httpGet:
28+
path: /status/200
29+
port: http
30+
readinessProbe:
31+
httpGet:
32+
path: /status/200
33+
port: http
34+
resources:
35+
requests:
36+
cpu: 50m
37+
memory: 64Mi
38+
limits:
39+
cpu: 100m
40+
memory: 128Mi
41+
securityContext:
42+
runAsNonRoot: true
43+
---
44+
apiVersion: v1
45+
kind: Service
46+
metadata:
47+
name: ($httpbin_service_name)
48+
namespace: ($httpbin_service_namespace)
49+
labels:
50+
app: httpbin
51+
spec:
52+
selector:
53+
app: httpbin
54+
ports:
55+
- port: 80
56+
targetPort: http
57+
protocol: TCP
58+
name: http
59+
appProtocol: http
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: ($gateway_namespace)
6+
---
7+
apiVersion: gateway.networking.k8s.io/v1
8+
kind: GatewayClass
9+
metadata:
10+
name: ($gateway_class_name)
11+
status:
12+
(conditions[?type == 'Accepted']):
13+
- status: 'True'
14+
reason: Accepted
15+
---
16+
apiVersion: gateway.networking.k8s.io/v1
17+
kind: Gateway
18+
metadata:
19+
name: ($gateway_name)
20+
namespace: ($gateway_namespace)
21+
status:
22+
(conditions[?type == 'Accepted']):
23+
- status: 'True'
24+
reason: Accepted
25+
(conditions[?type == 'Programmed']):
26+
- status: 'True'
27+
reason: Programmed
28+
(conditions[?type == 'DataPlaneReady']):
29+
- status: 'True'
30+
reason: Ready
31+
(conditions[?type == 'KonnectGatewayControlPlaneProgrammed']):
32+
- status: 'True'
33+
reason: Programmed
34+
(conditions[?type == 'KonnectExtensionReady']):
35+
- status: 'True'
36+
reason: Ready
37+
(conditions[?type == 'GatewayService']):
38+
- status: 'True'
39+
reason: Ready
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
# Namespace for Kong resources
3+
apiVersion: v1
4+
kind: Namespace
5+
metadata:
6+
name: ($gateway_namespace)
7+
---
8+
# Namespace for default resources
9+
apiVersion: v1
10+
kind: Namespace
11+
metadata:
12+
name: default
13+
---
14+
kind: KonnectAPIAuthConfiguration
15+
apiVersion: konnect.konghq.com/v1alpha1
16+
metadata:
17+
name: konnect-api-auth-dev-1
18+
namespace: ($gateway_namespace)
19+
spec:
20+
type: token
21+
token: (env('KONNECT_TOKEN'))
22+
serverURL: (env('KONNECT_SERVER_URL') || 'eu.api.konghq.tech')
23+
---
24+
kind: GatewayConfiguration
25+
apiVersion: gateway-operator.konghq.com/v2beta1
26+
metadata:
27+
name: ($gateway_configuration_name)
28+
namespace: ($gateway_namespace)
29+
spec:
30+
konnect:
31+
authRef:
32+
name: konnect-api-auth-dev-1
33+
dataPlaneOptions:
34+
deployment:
35+
podTemplateSpec:
36+
spec:
37+
containers:
38+
- name: proxy
39+
image: ($gateway_dataplane_image)
40+
---
41+
kind: GatewayClass
42+
apiVersion: gateway.networking.k8s.io/v1
43+
metadata:
44+
name: ($gateway_class_name)
45+
spec:
46+
controllerName: konghq.com/gateway-operator
47+
parametersRef:
48+
group: gateway-operator.konghq.com
49+
kind: GatewayConfiguration
50+
name: ($gateway_name)
51+
namespace: ($gateway_namespace)
52+
---
53+
kind: Gateway
54+
apiVersion: gateway.networking.k8s.io/v1
55+
metadata:
56+
name: ($gateway_name)
57+
namespace: ($gateway_namespace)
58+
spec:
59+
gatewayClassName: ($gateway_class_name)
60+
listeners:
61+
- name: http
62+
protocol: HTTP
63+
port: 80
64+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# Assert HTTPRoute is accepted and programmed
3+
apiVersion: gateway.networking.k8s.io/v1
4+
kind: HTTPRoute
5+
metadata:
6+
name: ($http_route_name)
7+
namespace: ($http_route_namespace)
8+
status:
9+
parents:
10+
- parentRef:
11+
name: ($gateway_name)
12+
group: gateway.networking.k8s.io
13+
kind: Gateway
14+
controllerName: konghq.com/gateway-operator
15+
# Filter conditions array to check for all required conditions
16+
(conditions[?type == 'Accepted']):
17+
- status: "True"
18+
reason: Accepted
19+
(conditions[?type == 'ResolvedRefs']):
20+
- status: "True"
21+
reason: ResolvedRefs
22+
(conditions[?type == 'KongRouteProgrammed']):
23+
- status: "True"
24+
reason: KongRouteProgrammed
25+
(conditions[?type == 'KongServiceProgrammed']):
26+
- status: "True"
27+
reason: KongServiceProgrammed
28+
(conditions[?type == 'KongUpstreamProgrammed']):
29+
- status: "True"
30+
reason: KongUpstreamProgrammed
31+
(conditions[?type == 'KongTargetProgrammed']):
32+
- status: "True"
33+
reason: KongTargetProgrammed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
kind: HTTPRoute
3+
apiVersion: gateway.networking.k8s.io/v1
4+
metadata:
5+
name: ($http_route_name)
6+
namespace: ($http_route_namespace)
7+
spec:
8+
parentRefs:
9+
- group: gateway.networking.k8s.io
10+
kind: Gateway
11+
name: ($gateway_name)
12+
rules:
13+
- matches:
14+
- path:
15+
type: PathPrefix
16+
value: ($route_path)
17+
filters:
18+
- type: ExtensionRef
19+
extensionRef:
20+
group: configuration.konghq.com
21+
kind: KongPlugin
22+
name: ($rate_limiting_plugin_name)
23+
backendRefs:
24+
- name: ($httpbin_service_name)
25+
port: 80
26+
---
27+
kind: KongPlugin
28+
apiVersion: configuration.konghq.com/v1
29+
metadata:
30+
name: ($rate_limiting_plugin_name)
31+
namespace: ($http_route_namespace)
32+
plugin: rate-limiting
33+
config:
34+
minute: 20
35+
policy: local
36+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
kind: HTTPRoute
3+
apiVersion: gateway.networking.k8s.io/v1
4+
metadata:
5+
name: ($http_route_name)
6+
namespace: ($http_route_namespace)
7+
spec:
8+
parentRefs:
9+
- group: gateway.networking.k8s.io
10+
kind: Gateway
11+
name: ($gateway_name)
12+
rules:
13+
- matches:
14+
- path:
15+
type: PathPrefix
16+
value: ($route_path)
17+
filters:
18+
- type: ExtensionRef
19+
extensionRef:
20+
group: configuration.konghq.com
21+
kind: KongPlugin
22+
name: ($rate_limiting_plugin_name)
23+
- type: ExtensionRef
24+
extensionRef:
25+
group: configuration.konghq.com
26+
kind: KongPlugin
27+
name: ($response_transformer_plugin_name)
28+
backendRefs:
29+
- name: ($httpbin_service_name)
30+
port: 80
31+
---
32+
kind: KongPlugin
33+
apiVersion: configuration.konghq.com/v1
34+
metadata:
35+
name: ($rate_limiting_plugin_name)
36+
namespace: ($http_route_namespace)
37+
plugin: rate-limiting
38+
config:
39+
minute: 20
40+
policy: local
41+
---
42+
kind: KongPlugin
43+
apiVersion: configuration.konghq.com/v1
44+
metadata:
45+
name: ($response_transformer_plugin_name)
46+
namespace: ($http_route_namespace)
47+
plugin: response-transformer
48+
config:
49+
add:
50+
headers:
51+
- "X-Add:foo"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
kind: HTTPRoute
3+
apiVersion: gateway.networking.k8s.io/v1
4+
metadata:
5+
name: ($http_route_name)
6+
namespace: ($http_route_namespace)
7+
spec:
8+
parentRefs:
9+
- group: gateway.networking.k8s.io
10+
kind: Gateway
11+
name: ($gateway_name)
12+
rules:
13+
- matches:
14+
- path:
15+
type: PathPrefix
16+
value: ($route_path)
17+
filters:
18+
- type: ExtensionRef
19+
extensionRef:
20+
group: configuration.konghq.com
21+
kind: KongPlugin
22+
name: ($rate_limiting_plugin_name)
23+
backendRefs:
24+
- name: ($httpbin_service_name)
25+
port: 80
26+
---
27+
kind: KongPlugin
28+
apiVersion: configuration.konghq.com/v1
29+
metadata:
30+
name: ($rate_limiting_plugin_name)
31+
namespace: ($http_route_namespace)
32+
plugin: rate-limiting
33+
config:
34+
minute: 20
35+
policy: local
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
kind: KongPlugin
2+
apiVersion: configuration.konghq.com/v1
3+
metadata:
4+
name: ($rate_limiting_plugin_name)
5+
namespace: ($http_route_namespace)
6+
plugin: rate-limiting
7+
config:
8+
minute: 30
9+
policy: local
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
kind: HTTPRoute
3+
apiVersion: gateway.networking.k8s.io/v1
4+
metadata:
5+
name: ($http_route_name)
6+
namespace: ($http_route_namespace)
7+
spec:
8+
parentRefs:
9+
- group: gateway.networking.k8s.io
10+
kind: Gateway
11+
name: ($gateway_name)
12+
rules:
13+
- matches:
14+
- path:
15+
type: PathPrefix
16+
value: ($route_path)
17+
filters:
18+
- type: ExtensionRef
19+
extensionRef:
20+
group: configuration.konghq.com
21+
kind: KongPlugin
22+
name: ($rate_limiting_plugin_name)
23+
backendRefs:
24+
- name: ($httpbin_service_name)
25+
port: 80
26+
---
27+
kind: KongPlugin
28+
apiVersion: configuration.konghq.com/v1
29+
metadata:
30+
name: ($rate_limiting_plugin_name)
31+
namespace: ($http_route_namespace)
32+
plugin: rate-limiting
33+
config:
34+
minute: 30
35+
policy: local

0 commit comments

Comments
 (0)