Skip to content

Commit 91c4ff4

Browse files
committed
functional tests for upstreamSettingsPolicy
1 parent c3f6b15 commit 91c4ff4

File tree

7 files changed

+505
-0
lines changed

7 files changed

+505
-0
lines changed

apis/v1alpha1/policy_methods.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ func (p *ObservabilityPolicy) GetPolicyStatus() v1alpha2.PolicyStatus {
3131
func (p *ObservabilityPolicy) SetPolicyStatus(status v1alpha2.PolicyStatus) {
3232
p.Status = status
3333
}
34+
35+
func (p *UpstreamSettingsPolicy) GetTargetRefs() []v1alpha2.LocalPolicyTargetReference {
36+
return p.Spec.TargetRefs
37+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: coffee
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: coffee
10+
template:
11+
metadata:
12+
labels:
13+
app: coffee
14+
spec:
15+
containers:
16+
- name: coffee
17+
image: nginxdemos/nginx-hello:plain-text
18+
ports:
19+
- containerPort: 8080
20+
---
21+
apiVersion: v1
22+
kind: Service
23+
metadata:
24+
name: coffee
25+
spec:
26+
ports:
27+
- port: 80
28+
targetPort: 8080
29+
protocol: TCP
30+
name: http
31+
selector:
32+
app: coffee
33+
---
34+
apiVersion: apps/v1
35+
kind: Deployment
36+
metadata:
37+
name: tea
38+
spec:
39+
replicas: 1
40+
selector:
41+
matchLabels:
42+
app: tea
43+
template:
44+
metadata:
45+
labels:
46+
app: tea
47+
spec:
48+
containers:
49+
- name: tea
50+
image: nginxdemos/nginx-hello:plain-text
51+
ports:
52+
- containerPort: 8080
53+
---
54+
apiVersion: v1
55+
kind: Service
56+
metadata:
57+
name: tea
58+
spec:
59+
ports:
60+
- port: 80
61+
targetPort: 8080
62+
protocol: TCP
63+
name: http
64+
selector:
65+
app: tea
66+
---
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: Gateway
3+
metadata:
4+
name: gateway
5+
spec:
6+
gatewayClassName: nginx
7+
listeners:
8+
- name: http
9+
port: 80
10+
protocol: HTTP
11+
hostname: "*.example.com"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: grpc-backend
5+
spec:
6+
selector:
7+
app: grpc-backend
8+
ports:
9+
- protocol: TCP
10+
port: 8080
11+
targetPort: 50051
12+
---
13+
apiVersion: apps/v1
14+
kind: Deployment
15+
metadata:
16+
name: grpc-backend
17+
labels:
18+
app: grpc-backend
19+
spec:
20+
replicas: 1
21+
selector:
22+
matchLabels:
23+
app: grpc-backend
24+
template:
25+
metadata:
26+
labels:
27+
app: grpc-backend
28+
spec:
29+
containers:
30+
- name: grpc-backend
31+
image: ghcr.io/nginxinc/kic-test-grpc-server:0.2.3
32+
env:
33+
- name: POD_NAME
34+
valueFrom:
35+
fieldRef:
36+
fieldPath: metadata.name
37+
resources:
38+
requests:
39+
cpu: 10m
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: coffee
5+
spec:
6+
parentRefs:
7+
- name: gateway
8+
sectionName: http
9+
hostnames:
10+
- "cafe.example.com"
11+
rules:
12+
- matches:
13+
- path:
14+
type: PathPrefix
15+
value: /coffee
16+
backendRefs:
17+
- name: coffee
18+
port: 80
19+
---
20+
apiVersion: gateway.networking.k8s.io/v1
21+
kind: GRPCRoute
22+
metadata:
23+
name: grpc-route
24+
spec:
25+
parentRefs:
26+
- name: gateway
27+
sectionName: http
28+
rules:
29+
- matches:
30+
- method:
31+
service: helloworld.Greeter
32+
method: SayHello
33+
backendRefs:
34+
- name: grpc-backend
35+
port: 8080
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: gateway.nginx.org/v1alpha1
2+
kind: UpstreamSettingsPolicy
3+
metadata:
4+
name: coffee-svc-usp
5+
spec:
6+
zoneSize: 512k
7+
targetRefs:
8+
- group: core
9+
kind: Service
10+
name: coffee
11+
keepAlive:
12+
connections: 10
13+
requests: 3
14+
time: 10s
15+
timeout: 50s
16+
---
17+
apiVersion: gateway.nginx.org/v1alpha1
18+
kind: UpstreamSettingsPolicy
19+
metadata:
20+
name: tea-multiple-svc-usp
21+
spec:
22+
zoneSize: 512k
23+
targetRefs:
24+
- group: core
25+
kind: Service
26+
name: tea
27+
- group: core
28+
kind: Service
29+
name: coffee
30+
keepAlive:
31+
connections: 10
32+
requests: 3
33+
time: 10s
34+
timeout: 50s
35+
---
36+
apiVersion: gateway.nginx.org/v1alpha1
37+
kind: UpstreamSettingsPolicy
38+
metadata:
39+
name: grpc-svc-usp
40+
spec:
41+
targetRef:
42+
group: core
43+
kind: Service
44+
name: grpc-backend
45+
keepAlive:
46+
connections: 10
47+
requests: 3
48+
time: 10s
49+
timeout: 50s

0 commit comments

Comments
 (0)