Skip to content

Commit 68c73c0

Browse files
authored
feat(conformance): Add HTTPRouteMultipleRulesDifferentPools test (#834)
* copy of accepted inference pool test to start from. * add yaml file for the test * update time out * update the yaml file to add port 9002 * read timeout config from local repo * remove excess comments * correct spelling for scenarios * check route condition on RouteConditionResolvedRefs * remove empty lines in yaml * set optional/defaulted fields as unspecified * fix timeout * fix boilerplate header * change varialbe names to use primary secondary consistently. * remove extra comments * factor out common code * Add actual http traffic validation using echo-basic * remove extra comments from manifest * remove modifiedTimeoutConfig.HTTPRouteMustHaveCondition per review comment. * intermediate update * fix the test run * factor out common code * move epp def to shared manifest * remove extra comments * revert back to two epps * add to do for epp image * switch to GeneralMustHaveConditionTimeout * undo gateway version changes * remove unused HTTPRouteMustHaveConditions * update doc string for GetPod * update docstring * Remove resource type from names in manifests. * remove type from name * remove health check * add todo for combining getpod methods
1 parent 191e710 commit 68c73c0

File tree

6 files changed

+446
-27
lines changed

6 files changed

+446
-27
lines changed

conformance/resources/manifests/manifests.yaml

Lines changed: 90 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,45 @@
44
# individual test files or other resource directories (e.g., sample_backends).
55

66
---
7-
# Namespace for core infrastructure like Gateways.
87
apiVersion: v1
98
kind: Namespace
109
metadata:
1110
name: gateway-conformance-infra
1211
labels:
1312
gateway-conformance: infra
1413
---
15-
# Namespace for application backends (potentially simulating model servers
16-
# or where InferencePools might reside in some tests).
1714
apiVersion: v1
1815
kind: Namespace
1916
metadata:
2017
name: gateway-conformance-app-backend
2118
labels:
2219
gateway-conformance: backend
2320
---
24-
# Namespace for simple web server backends. This is expected by
25-
# the upstream conformance suite's Setup method.
2621
apiVersion: v1
2722
kind: Namespace
2823
metadata:
2924
name: gateway-conformance-web-backend
3025
labels:
3126
gateway-conformance: web-backend
3227
---
33-
# A basic Gateway resource that allows HTTPRoutes from the same namespace.
34-
# Tests can use this as a parent reference for routes that target InferencePools.
3528
apiVersion: gateway.networking.k8s.io/v1
3629
kind: Gateway
3730
metadata:
3831
name: conformance-gateway
3932
namespace: gateway-conformance-infra
4033
spec:
41-
# The conformance suite runner will replace this placeholder
42-
# with the actual GatewayClass name provided via flags.
4334
gatewayClassName: "{GATEWAY_CLASS_NAME}"
4435
listeners:
45-
- name: http # Standard listener name
36+
- name: http
4637
port: 80
4738
protocol: HTTP
4839
allowedRoutes:
4940
namespaces:
5041
from: All
5142
kinds:
52-
# Allows HTTPRoutes to attach, which can then reference InferencePools.
5343
- group: gateway.networking.k8s.io
5444
kind: HTTPRoute
5545
---
56-
# --- Conformance Secondary Gateway Definition ---
57-
# A second generic Gateway resource for tests requiring multiple Gateways.
5846
apiVersion: gateway.networking.k8s.io/v1
5947
kind: Gateway
6048
metadata:
@@ -66,7 +54,95 @@ spec:
6654
- name: http
6755
port: 80
6856
protocol: HTTP
69-
hostname: "secondary.example.com" # Distinct hostname to differentiate from conformance-gateway
57+
hostname: "secondary.example.com"
7058
allowedRoutes:
7159
namespaces:
7260
from: All
61+
---
62+
apiVersion: apps/v1
63+
kind: Deployment
64+
metadata:
65+
name: inference-model-1
66+
namespace: gateway-conformance-app-backend
67+
labels:
68+
app: inference-model-1
69+
spec:
70+
replicas: 1
71+
selector:
72+
matchLabels:
73+
app: inference-model-1
74+
template:
75+
metadata:
76+
labels:
77+
app: inference-model-1
78+
spec:
79+
containers:
80+
- name: echo-basic-1
81+
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
82+
ports:
83+
- name: http
84+
containerPort: 3000
85+
readinessProbe:
86+
httpGet:
87+
path: /
88+
port: 3000
89+
initialDelaySeconds: 3
90+
periodSeconds: 5
91+
failureThreshold: 2
92+
env:
93+
- name: POD_NAME
94+
valueFrom:
95+
fieldRef:
96+
fieldPath: metadata.name
97+
- name: NAMESPACE
98+
valueFrom:
99+
fieldRef:
100+
fieldPath: metadata.namespace
101+
- name: POD_IP
102+
valueFrom:
103+
fieldRef:
104+
fieldPath: status.podIP
105+
---
106+
apiVersion: apps/v1
107+
kind: Deployment
108+
metadata:
109+
name: inference-model-2
110+
namespace: gateway-conformance-app-backend
111+
labels:
112+
app: inference-model-2
113+
spec:
114+
replicas: 1
115+
selector:
116+
matchLabels:
117+
app: inference-model-2
118+
template:
119+
metadata:
120+
labels:
121+
app: inference-model-2
122+
spec:
123+
containers:
124+
- name: echo-basic-2
125+
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
126+
ports:
127+
- name: http
128+
containerPort: 3000
129+
readinessProbe:
130+
httpGet:
131+
path: /
132+
port: 3000
133+
initialDelaySeconds: 3
134+
periodSeconds: 5
135+
failureThreshold: 2
136+
env:
137+
- name: POD_NAME
138+
valueFrom:
139+
fieldRef:
140+
fieldPath: metadata.name
141+
- name: NAMESPACE
142+
valueFrom:
143+
fieldRef:
144+
fieldPath: metadata.namespace
145+
- name: POD_IP
146+
valueFrom:
147+
fieldRef:
148+
fieldPath: status.podIP
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package basic
18+
19+
import (
20+
"testing"
21+
22+
"k8s.io/apimachinery/pkg/labels"
23+
"k8s.io/apimachinery/pkg/types"
24+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
25+
"sigs.k8s.io/gateway-api/pkg/features"
26+
27+
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
28+
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
29+
trafficutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
30+
)
31+
32+
func init() {
33+
tests.ConformanceTests = append(tests.ConformanceTests, HTTPRouteMultipleRulesDifferentPools)
34+
}
35+
36+
var HTTPRouteMultipleRulesDifferentPools = suite.ConformanceTest{
37+
ShortName: "HTTPRouteMultipleRulesDifferentPools",
38+
Description: "An HTTPRoute with two rules routing to two different InferencePools",
39+
Manifests: []string{"tests/basic/inferencepool_multiple_rules_different_pools.yaml"},
40+
Features: []features.FeatureName{
41+
features.SupportGateway,
42+
features.SupportHTTPRoute,
43+
features.FeatureName("SupportInferencePool"),
44+
},
45+
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
46+
const (
47+
appBackendNamespace = "gateway-conformance-app-backend"
48+
infraNamespace = "gateway-conformance-infra"
49+
50+
poolPrimaryName = "pool-primary"
51+
poolSecondaryName = "pool-secondary"
52+
routeName = "httproute-multiple-rules-different-pools"
53+
gatewayName = "conformance-gateway"
54+
55+
backendPrimaryLabelValue = "inference-model-1"
56+
backendSecondaryLabelValue = "inference-model-2"
57+
backendAppLabelKey = "app"
58+
59+
primaryPath = "/primary"
60+
secondaryPath = "/secondary"
61+
)
62+
63+
primaryPoolNN := types.NamespacedName{Name: poolPrimaryName, Namespace: appBackendNamespace}
64+
secondaryPoolNN := types.NamespacedName{Name: poolSecondaryName, Namespace: appBackendNamespace}
65+
routeNN := types.NamespacedName{Name: routeName, Namespace: appBackendNamespace}
66+
gatewayNN := types.NamespacedName{Name: gatewayName, Namespace: infraNamespace}
67+
68+
t.Run("Wait for resources to be accepted", func(t *testing.T) {
69+
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(t, s.Client, routeNN, gatewayNN, primaryPoolNN)
70+
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(t, s.Client, routeNN, gatewayNN, secondaryPoolNN)
71+
})
72+
73+
t.Run("Traffic should be routed to the correct pool based on path", func(t *testing.T) {
74+
primarySelector := labels.SelectorFromSet(labels.Set{backendAppLabelKey: backendPrimaryLabelValue})
75+
secondarySelector := labels.SelectorFromSet(labels.Set{backendAppLabelKey: backendSecondaryLabelValue})
76+
77+
primaryPod := k8sutils.GetPod(t, s.Client, appBackendNamespace, primarySelector, s.TimeoutConfig.RequestTimeout)
78+
secondaryPod := k8sutils.GetPod(t, s.Client, appBackendNamespace, secondarySelector, s.TimeoutConfig.RequestTimeout)
79+
80+
gwAddr := k8sutils.GetGatewayEndpoint(t, s.Client, s.TimeoutConfig, gatewayNN)
81+
82+
t.Run("request to primary pool", func(t *testing.T) {
83+
trafficutils.MakeRequestAndExpectResponseFromPod(t, s.RoundTripper, s.TimeoutConfig, gwAddr, primaryPath, primaryPod)
84+
})
85+
86+
t.Run("request to secondary pool", func(t *testing.T) {
87+
trafficutils.MakeRequestAndExpectResponseFromPod(t, s.RoundTripper, s.TimeoutConfig, gwAddr, secondaryPath, secondaryPod)
88+
})
89+
})
90+
},
91+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: pool-primary-epp
6+
namespace: gateway-conformance-app-backend
7+
spec:
8+
selector:
9+
app: pool-primary-epp
10+
ports:
11+
- name: grpc
12+
port: 9002
13+
targetPort: 9002
14+
---
15+
apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
name: pool-primary-epp
19+
namespace: gateway-conformance-app-backend
20+
labels:
21+
app: pool-primary-epp
22+
spec:
23+
replicas: 1
24+
selector:
25+
matchLabels:
26+
app: pool-primary-epp
27+
template:
28+
metadata:
29+
labels:
30+
app: pool-primary-epp
31+
spec:
32+
containers:
33+
- name: epp
34+
# TODO(#996) Switch to use a released version of the image instead of epp:main
35+
image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main
36+
imagePullPolicy: Always
37+
env:
38+
- name: ENABLE_REQ_HEADER_BASED_SCHEDULER_FOR_TESTING
39+
value: "true"
40+
args:
41+
- "-poolName"
42+
- "pool-primary"
43+
- "-poolNamespace"
44+
- "gateway-conformance-app-backend"
45+
- -grpcPort
46+
- "9002"
47+
- -grpcHealthPort
48+
- "9003"
49+
---
50+
apiVersion: v1
51+
kind: Service
52+
metadata:
53+
name: pool-secondary-epp
54+
namespace: gateway-conformance-app-backend
55+
spec:
56+
selector:
57+
app: pool-secondary-epp
58+
ports:
59+
- name: grpc
60+
port: 9002
61+
targetPort: 9002
62+
---
63+
apiVersion: apps/v1
64+
kind: Deployment
65+
metadata:
66+
name: pool-secondary-epp
67+
namespace: gateway-conformance-app-backend
68+
labels:
69+
app: pool-secondary-epp
70+
spec:
71+
replicas: 1
72+
selector:
73+
matchLabels:
74+
app: pool-secondary-epp
75+
template:
76+
metadata:
77+
labels:
78+
app: pool-secondary-epp
79+
spec:
80+
containers:
81+
- name: epp
82+
image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main
83+
imagePullPolicy: Always
84+
env:
85+
- name: ENABLE_REQ_HEADER_BASED_SCHEDULER_FOR_TESTING
86+
value: "true"
87+
args:
88+
- "-poolName"
89+
- "pool-secondary"
90+
- "-poolNamespace"
91+
- "gateway-conformance-app-backend"
92+
- -grpcPort
93+
- "9002"
94+
- -grpcHealthPort
95+
- "9003"
96+
---
97+
apiVersion: inference.networking.x-k8s.io/v1alpha2
98+
kind: InferencePool
99+
metadata:
100+
name: pool-primary
101+
namespace: gateway-conformance-app-backend
102+
spec:
103+
selector:
104+
app: inference-model-1
105+
targetPortNumber: 3000
106+
extensionRef:
107+
name: pool-primary-epp
108+
portNumber: 9002
109+
---
110+
apiVersion: inference.networking.x-k8s.io/v1alpha2
111+
kind: InferencePool
112+
metadata:
113+
name: pool-secondary
114+
namespace: gateway-conformance-app-backend
115+
spec:
116+
selector:
117+
app: inference-model-2
118+
targetPortNumber: 3000
119+
extensionRef:
120+
name: pool-secondary-epp
121+
portNumber: 9002
122+
---
123+
apiVersion: gateway.networking.k8s.io/v1
124+
kind: HTTPRoute
125+
metadata:
126+
name: httproute-multiple-rules-different-pools
127+
namespace: gateway-conformance-app-backend
128+
spec:
129+
parentRefs:
130+
- name: conformance-gateway
131+
namespace: gateway-conformance-infra
132+
rules:
133+
- matches:
134+
- path:
135+
type: PathPrefix
136+
value: /primary
137+
backendRefs:
138+
- name: pool-primary
139+
kind: InferencePool
140+
group: inference.networking.x-k8s.io
141+
port: 80
142+
- matches:
143+
- path:
144+
type: PathPrefix
145+
value: /secondary
146+
backendRefs:
147+
- name: pool-secondary
148+
kind: InferencePool
149+
group: inference.networking.x-k8s.io
150+
port: 80

0 commit comments

Comments
 (0)