Skip to content

Commit cb2509e

Browse files
authored
refactor(conformance): move some common resources to shared place and add EPP service to tests needed. (#982)
* move some common resources to shared place and add EPP to the inferencePool. * moving more common resource to base. * change epp service name. * Merge main fix. * naming. * remove unneeded comments.
1 parent 45aedfe commit cb2509e

12 files changed

+251
-320
lines changed

conformance/conformance.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ import (
6868

6969
// Constants for the shared Gateway
7070
const (
71-
SharedGatewayName = "conformance-gateway" // Name of the Gateway in manifests.yaml
72-
SharedGatewayNamespace = "gateway-conformance-infra" // Namespace of the Gateway
71+
SharedGatewayName = "conformance-primary-gateway" // Name of the Gateway in manifests.yaml
72+
SharedGatewayNamespace = "gateway-conformance-infra" // Namespace of the Gateway
7373
)
7474

7575
// GatewayLayerProfileName defines the name for the conformance profile that tests
@@ -88,6 +88,7 @@ const SupportInferencePool features.FeatureName = "SupportInferencePool"
8888
// of the "Gateway" profile for the Inference Extension MUST support.
8989
var InferenceCoreFeatures = sets.New(
9090
features.SupportGateway, // This is needed to ensure manifest gets applied during setup.
91+
features.SupportHTTPRoute,
9192
SupportInferencePool,
9293
)
9394

conformance/resources/manifests/manifests.yaml

Lines changed: 226 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@ metadata:
1818
labels:
1919
gateway-conformance: backend
2020
---
21-
apiVersion: v1
22-
kind: Namespace
23-
metadata:
24-
name: gateway-conformance-web-backend
25-
labels:
26-
gateway-conformance: web-backend
27-
---
21+
# A basic Gateway resource that allows HTTPRoutes from the same namespace.
22+
# Tests can use this as a parent reference for routes that target InferencePools.
2823
apiVersion: gateway.networking.k8s.io/v1
2924
kind: Gateway
3025
metadata:
31-
name: conformance-gateway
26+
name: conformance-primary-gateway
3227
namespace: gateway-conformance-infra
3328
spec:
3429
gatewayClassName: "{GATEWAY_CLASS_NAME}"
@@ -58,30 +53,32 @@ spec:
5853
allowedRoutes:
5954
namespaces:
6055
from: All
56+
57+
### The following defines the essential resources for the gateway conformance test.
58+
### All resources are created in the 'gateway-conformance-app-backend' namespace.
6159
---
60+
# Deploys a mock backend service to act as a model server.
6261
apiVersion: apps/v1
6362
kind: Deployment
6463
metadata:
65-
name: inference-model-1
64+
name: primary-inference-model-server-deployment
6665
namespace: gateway-conformance-app-backend
6766
labels:
68-
app: inference-model-1
67+
app: primary-inference-model-server
6968
spec:
70-
replicas: 1
7169
selector:
7270
matchLabels:
73-
app: inference-model-1
71+
app: primary-inference-model-server
7472
template:
7573
metadata:
7674
labels:
77-
app: inference-model-1
75+
app: primary-inference-model-server
7876
spec:
7977
containers:
80-
- name: echo-basic-1
78+
- name: echoserver
8179
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
8280
ports:
83-
- name: http
84-
containerPort: 3000
81+
- containerPort: 3000
8582
readinessProbe:
8683
httpGet:
8784
path: /
@@ -103,29 +100,28 @@ spec:
103100
fieldRef:
104101
fieldPath: status.podIP
105102
---
103+
# Deploys a secondary mock backend service to act as a model server.
106104
apiVersion: apps/v1
107105
kind: Deployment
108106
metadata:
109-
name: inference-model-2
107+
name: secondary-inference-model-server-deployment
110108
namespace: gateway-conformance-app-backend
111109
labels:
112-
app: inference-model-2
110+
app: secondary-inference-model-server
113111
spec:
114-
replicas: 1
115112
selector:
116113
matchLabels:
117-
app: inference-model-2
114+
app: secondary-inference-model-server
118115
template:
119116
metadata:
120117
labels:
121-
app: inference-model-2
118+
app: secondary-inference-model-server
122119
spec:
123120
containers:
124-
- name: echo-basic-2
121+
- name: echoserver
125122
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
126123
ports:
127-
- name: http
128-
containerPort: 3000
124+
- containerPort: 3000
129125
readinessProbe:
130126
httpGet:
131127
path: /
@@ -146,3 +142,209 @@ spec:
146142
valueFrom:
147143
fieldRef:
148144
fieldPath: status.podIP
145+
---
146+
# --- Primary InferencePool Definition ---
147+
apiVersion: inference.networking.x-k8s.io/v1alpha2
148+
kind: InferencePool
149+
metadata:
150+
name: primary-inference-pool
151+
namespace: gateway-conformance-app-backend
152+
spec:
153+
selector:
154+
app: primary-inference-model-server
155+
targetPortNumber: 3000
156+
extensionRef:
157+
name: primary-endpoint-picker-svc
158+
---
159+
# --- Primary Conformance EPP service Definition ---
160+
apiVersion: v1
161+
kind: Service
162+
metadata:
163+
name: primary-endpoint-picker-svc
164+
namespace: gateway-conformance-app-backend
165+
spec:
166+
selector:
167+
app: primary-app-backend-epp
168+
ports:
169+
- protocol: TCP
170+
port: 9002
171+
targetPort: 9002
172+
appProtocol: http2
173+
type: ClusterIP
174+
---
175+
# --- Primary Conformance EPP Deployment ---
176+
apiVersion: apps/v1
177+
kind: Deployment
178+
metadata:
179+
name: primary-app-endpoint-picker
180+
namespace: gateway-conformance-app-backend
181+
labels:
182+
app: primary-app-backend-epp
183+
spec:
184+
replicas: 1
185+
selector:
186+
matchLabels:
187+
app: primary-app-backend-epp
188+
template:
189+
metadata:
190+
labels:
191+
app: primary-app-backend-epp
192+
spec:
193+
# Conservatively, this timeout should mirror the longest grace period of the pods within the pool
194+
terminationGracePeriodSeconds: 130
195+
containers:
196+
- name: epp
197+
image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main
198+
imagePullPolicy: Always
199+
args:
200+
- -poolName
201+
- "primary-inference-pool"
202+
- -poolNamespace
203+
- "gateway-conformance-app-backend"
204+
- -v
205+
- "4"
206+
- --zap-encoder
207+
- "json"
208+
- -grpcPort
209+
- "9002"
210+
- -grpcHealthPort
211+
- "9003"
212+
env:
213+
- name: USE_STREAMING
214+
value: "true"
215+
- name: ENABLE_REQ_HEADER_BASED_SCHEDULER_FOR_TESTING # Used for conformance test.
216+
value: "true"
217+
ports:
218+
- containerPort: 9002
219+
- containerPort: 9003
220+
- name: metrics
221+
containerPort: 9090
222+
livenessProbe:
223+
grpc:
224+
port: 9003
225+
service: inference-extension
226+
initialDelaySeconds: 5
227+
periodSeconds: 10
228+
readinessProbe:
229+
grpc:
230+
port: 9003
231+
service: inference-extension
232+
initialDelaySeconds: 5
233+
periodSeconds: 10
234+
---
235+
# --- Secondary InferencePool Definition ---
236+
apiVersion: inference.networking.x-k8s.io/v1alpha2
237+
kind: InferencePool
238+
metadata:
239+
name: secondary-inference-pool
240+
namespace: gateway-conformance-app-backend
241+
spec:
242+
selector:
243+
app: secondary-inference-model-server
244+
targetPortNumber: 3000
245+
extensionRef:
246+
name: secondary-endpoint-picker-svc
247+
---
248+
# --- Secondary Conformance EPP service Definition ---
249+
apiVersion: v1
250+
kind: Service
251+
metadata:
252+
name: secondary-endpoint-picker-svc
253+
namespace: gateway-conformance-app-backend
254+
spec:
255+
selector:
256+
app: secondary-app-backend-epp
257+
ports:
258+
- protocol: TCP
259+
port: 9002
260+
targetPort: 9002
261+
appProtocol: http2
262+
type: ClusterIP
263+
---
264+
# --- Secondary Conformance EPP Deployment ---
265+
apiVersion: apps/v1
266+
kind: Deployment
267+
metadata:
268+
name: secondary-app-endpoint-picker
269+
namespace: gateway-conformance-app-backend
270+
labels:
271+
app: secondary-app-backend-epp
272+
spec:
273+
replicas: 1
274+
selector:
275+
matchLabels:
276+
app: secondary-app-backend-epp
277+
template:
278+
metadata:
279+
labels:
280+
app: secondary-app-backend-epp
281+
spec:
282+
# Conservatively, this timeout should mirror the longest grace period of the pods within the pool
283+
terminationGracePeriodSeconds: 130
284+
containers:
285+
- name: epp
286+
image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main
287+
imagePullPolicy: Always
288+
args:
289+
- -poolName
290+
- "secondary-inference-pool"
291+
- -poolNamespace
292+
- "gateway-conformance-app-backend"
293+
- -v
294+
- "4"
295+
- --zap-encoder
296+
- "json"
297+
- -grpcPort
298+
- "9002"
299+
- -grpcHealthPort
300+
- "9003"
301+
env:
302+
- name: USE_STREAMING
303+
value: "true"
304+
- name: ENABLE_REQ_HEADER_BASED_SCHEDULER_FOR_TESTING # Used for conformance test.
305+
value: "true"
306+
ports:
307+
- containerPort: 9002
308+
- containerPort: 9003
309+
- name: metrics
310+
containerPort: 9090
311+
livenessProbe:
312+
grpc:
313+
port: 9003
314+
service: inference-extension
315+
initialDelaySeconds: 5
316+
periodSeconds: 10
317+
readinessProbe:
318+
grpc:
319+
port: 9003
320+
service: inference-extension
321+
initialDelaySeconds: 5
322+
periodSeconds: 10
323+
---
324+
# --- Required Role and RoleBinding for Conformance Test for EPP ---
325+
apiVersion: rbac.authorization.k8s.io/v1
326+
kind: Role
327+
metadata:
328+
name: inference-model-reader
329+
namespace: gateway-conformance-app-backend
330+
rules:
331+
- apiGroups: ["inference.networking.x-k8s.io"]
332+
resources: ["inferencemodels", "inferencepools"]
333+
verbs: ["get", "list", "watch"]
334+
- apiGroups: [""]
335+
resources: ["pods"]
336+
verbs: ["get", "list", "watch"]
337+
---
338+
apiVersion: rbac.authorization.k8s.io/v1
339+
kind: RoleBinding
340+
metadata:
341+
name: epp-to-inference-model-reader
342+
namespace: gateway-conformance-app-backend
343+
subjects:
344+
- kind: ServiceAccount
345+
name: default
346+
namespace: gateway-conformance-app-backend
347+
roleRef:
348+
kind: Role
349+
name: inference-model-reader
350+
apiGroup: rbac.authorization.k8s.io

conformance/tests/basic/httproute_invalid_inferencepool_ref.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var HTTPRouteInvalidInferencePoolRef = suite.ConformanceTest{
4747
appBackendNamespace = "gateway-conformance-app-backend"
4848
infraNamespace = "gateway-conformance-infra"
4949
routeName = "httproute-to-non-existent-pool"
50-
gatewayName = "conformance-gateway"
50+
gatewayName = "conformance-primary-gateway"
5151
)
5252
routeNN := types.NamespacedName{Name: routeName, Namespace: appBackendNamespace}
5353
gatewayNN := types.NamespacedName{Name: gatewayName, Namespace: infraNamespace}

conformance/tests/basic/httproute_invalid_inferencepool_ref.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ spec:
1616
parentRefs:
1717
- group: gateway.networking.k8s.io
1818
kind: Gateway
19-
name: conformance-gateway # Name of the shared Gateway from base manifests
19+
name: conformance-primary-gateway # Name of the shared Gateway from base manifests
2020
namespace: gateway-conformance-infra # Namespace of the shared Gateway
2121
sectionName: http
2222
rules:
2323
- backendRefs:
2424
- group: inference.networking.x-k8s.io
2525
kind: InferencePool
2626
name: non-existent-inference-pool # Intentionally Non-Existing
27-
port: 8080
2827
matches:
2928
- path:
3029
type: PathPrefix

conformance/tests/basic/inferencepool_accepted.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var InferencePoolAccepted = suite.ConformanceTest{
4747
},
4848
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
4949
// created by the associated manifest file.
50-
poolNN := types.NamespacedName{Name: "inferencepool-basic-accepted", Namespace: "gateway-conformance-app-backend"}
50+
poolNN := types.NamespacedName{Name: "primary-inference-pool", Namespace: "gateway-conformance-app-backend"}
5151

5252
t.Run("InferencePool should have Accepted condition set to True", func(t *testing.T) {
5353
// Define the expected status condition. We use the standard "Accepted"

0 commit comments

Comments
 (0)