-
Notifications
You must be signed in to change notification settings - Fork 182
feat(conformance): Add HTTPRouteMultipleGatewaysDifferentPools test #838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 91 commits
87d1756
a9dcb62
c36e5f8
aaf23e2
2a67e7d
8ac7d72
c859896
fe540a7
63fedab
66f325d
fd0fa10
68812d7
59b1f9c
8a078dc
c55a803
5efaeb2
2cd8dab
26704a1
bb62da7
796b584
403b588
6506d44
dafd21e
ecf11e4
f1ce162
f3d8e8c
1cd8790
44b1427
c6bacb4
d15c25e
1451a90
271b7a8
adcc104
1535ccc
c92a402
ff25051
5a61a70
6fa352d
5f1bcad
e5fc860
62791b5
2f08131
cf587a6
afc8bc3
8588183
8b6a873
efe3990
b63459d
b903d8f
2d52812
fc2a410
939ae57
d34457a
753917a
f4bcc9a
d5530dc
0ce459c
3b884d6
d90eae0
73731e3
b57fb8a
6ee73d5
b239930
66b8426
9432280
4b1f44a
450a5c5
5990c51
392171d
117652e
ad82e88
ab4e4bc
04f52f3
d6b588e
112d878
120feb3
8214cdf
76cb644
f50054f
b235dbd
5dca67b
f2c0602
daeb8e6
79b3015
f1ab79f
81562a2
871d4d6
ae33369
43c1fa1
182ee70
2afea17
948956c
eae8202
e88bf77
89869d7
be03841
7a9133c
810e055
17ab77b
fbce2d5
af6b681
22bf7f9
d491509
413ec25
0b94f9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
Copyright 2025 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package basic | ||
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/labels" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/gateway-api/conformance/utils/suite" | ||
|
||
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests" | ||
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes" | ||
trafficutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic" | ||
) | ||
|
||
func init() { | ||
tests.ConformanceTests = append(tests.ConformanceTests, HTTPRouteMultipleGatewaysDifferentPools) | ||
} | ||
|
||
var HTTPRouteMultipleGatewaysDifferentPools = suite.ConformanceTest{ | ||
ShortName: "HTTPRouteMultipleGatewaysDifferentPools", | ||
Description: "Validates two HTTPRoutes on different Gateways successfully referencing different InferencePools and routes traffic accordingly.", | ||
Manifests: []string{"tests/basic/httproute_multiple_gateways_different_pools.yaml"}, | ||
Test: func(t *testing.T, s *suite.ConformanceTestSuite) { | ||
const ( | ||
appBackendNamespace = "gateway-conformance-app-backend" | ||
infraNamespace = "gateway-conformance-infra" | ||
backendAppLabelKey = "app" | ||
|
||
primaryGatewayName = "conformance-gateway" | ||
routeForPrimaryGWName = "route-for-primary-gateway" | ||
primaryPoolName = "primary-pool" | ||
primaryBackendLabel = "inference-model-1" | ||
primaryRoutePath = "/test-primary-gateway" | ||
|
||
secondaryGatewayName = "conformance-secondary-gateway" | ||
routeForSecondaryGWName = "route-for-secondary-gateway" | ||
secondaryPoolName = "secondary-pool" | ||
secondaryBackendLabel = "inference-model-2" | ||
secondaryRoutePath = "/test-secondary-gateway" | ||
secondaryRouteHostname = "secondary.example.com" | ||
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
routeForPrimaryGWNN := types.NamespacedName{Name: routeForPrimaryGWName, Namespace: appBackendNamespace} | ||
routeForSecondaryGWNN := types.NamespacedName{Name: routeForSecondaryGWName, Namespace: appBackendNamespace} | ||
primaryPoolNN := types.NamespacedName{Name: primaryPoolName, Namespace: appBackendNamespace} | ||
secondaryPoolNN := types.NamespacedName{Name: secondaryPoolName, Namespace: appBackendNamespace} | ||
primaryGatewayNN := types.NamespacedName{Name: primaryGatewayName, Namespace: infraNamespace} | ||
secondaryGatewayNN := types.NamespacedName{Name: secondaryGatewayName, Namespace: infraNamespace} | ||
|
||
t.Run("Primary HTTPRoute, InferencePool, and Gateway path: verify status and traffic", func(t *testing.T) { | ||
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted( | ||
t, | ||
s.Client, | ||
routeForPrimaryGWNN, | ||
primaryGatewayNN, | ||
primaryPoolNN, | ||
) | ||
|
||
primaryGwAddr := k8sutils.GetGatewayEndpoint(t, s.Client, s.TimeoutConfig, primaryGatewayNN) | ||
primarySelector := labels.SelectorFromSet(labels.Set{backendAppLabelKey: primaryBackendLabel}) | ||
primaryPod := k8sutils.GetPod(t, s.Client, appBackendNamespace, primarySelector, s.TimeoutConfig.RequestTimeout) | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
trafficutils.MakeRequestAndExpectResponseFromPod(t, s.RoundTripper, s.TimeoutConfig, primaryGwAddr, primaryRoutePath, primaryPod) | ||
}) | ||
|
||
t.Run("Secondary HTTPRoute, InferencePool, and Gateway path: verify status and traffic", func(t *testing.T) { | ||
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted( | ||
t, | ||
s.Client, | ||
routeForSecondaryGWNN, | ||
secondaryGatewayNN, | ||
secondaryPoolNN, | ||
) | ||
|
||
secondaryGwAddr := k8sutils.GetGatewayEndpoint(t, s.Client, s.TimeoutConfig, secondaryGatewayNN) | ||
secondarySelector := labels.SelectorFromSet(labels.Set{backendAppLabelKey: secondaryBackendLabel}) | ||
secondaryPod := k8sutils.GetPod(t, s.Client, appBackendNamespace, secondarySelector, s.TimeoutConfig.RequestTimeout) | ||
|
||
trafficutils.MakeRequestAndExpectResponseFromPodWithHostname(t, s.RoundTripper, s.TimeoutConfig, secondaryGwAddr, secondaryRoutePath, secondaryRouteHostname, secondaryPod) | ||
}) | ||
}, | ||
} |
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: primary-pool-epp-service | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: primary-pool-epp | ||
ports: | ||
- name: grpc | ||
port: 9002 | ||
targetPort: 9002 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: primary-pool-epp | ||
namespace: gateway-conformance-app-backend | ||
labels: | ||
app: primary-pool-epp | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: primary-pool-epp | ||
template: | ||
metadata: | ||
labels: | ||
app: primary-pool-epp | ||
spec: | ||
containers: | ||
- name: epp | ||
image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main | ||
imagePullPolicy: Always | ||
env: | ||
- name: ENABLE_REQ_HEADER_BASED_SCHEDULER_FOR_TESTING | ||
value: "true" | ||
args: | ||
- "-poolName" | ||
- "primary-pool" | ||
- "-poolNamespace" | ||
- "gateway-conformance-app-backend" | ||
- -grpcPort | ||
- "9002" | ||
- -grpcHealthPort | ||
- "9003" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: secondary-pool-epp-service | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: secondary-pool-epp | ||
ports: | ||
- name: grpc | ||
port: 9002 | ||
targetPort: 9002 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: secondary-pool-epp | ||
namespace: gateway-conformance-app-backend | ||
labels: | ||
app: secondary-pool-epp | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: secondary-pool-epp | ||
template: | ||
metadata: | ||
labels: | ||
app: secondary-pool-epp | ||
spec: | ||
containers: | ||
- name: epp | ||
image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main | ||
imagePullPolicy: Always | ||
env: | ||
- name: ENABLE_REQ_HEADER_BASED_SCHEDULER_FOR_TESTING | ||
value: "true" | ||
args: | ||
- "-poolName" | ||
- "secondary-pool" | ||
- "-poolNamespace" | ||
- "gateway-conformance-app-backend" | ||
- -grpcPort | ||
- "9002" | ||
- -grpcHealthPort | ||
- "9003" | ||
--- | ||
apiVersion: networking.gke.io/v1 | ||
kind: HealthCheckPolicy | ||
metadata: | ||
name: primary-pool-health-check | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
targetRef: | ||
group: "inference.networking.x-k8s.io" | ||
kind: InferencePool | ||
name: primary-pool | ||
default: | ||
config: | ||
type: HTTP | ||
httpHealthCheck: | ||
requestPath: / | ||
port: 3000 | ||
|
||
--- | ||
apiVersion: networking.gke.io/v1 | ||
kind: HealthCheckPolicy | ||
metadata: | ||
name: secondary-pool-health-check | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
targetRef: | ||
group: "inference.networking.x-k8s.io" | ||
kind: InferencePool | ||
name: secondary-pool | ||
default: | ||
config: | ||
type: HTTP | ||
httpHealthCheck: | ||
requestPath: / | ||
port: 3000 | ||
|
||
--- | ||
apiVersion: inference.networking.x-k8s.io/v1alpha2 | ||
kind: InferencePool | ||
metadata: | ||
name: primary-pool | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: "inference-model-1" | ||
targetPortNumber: 3000 | ||
extensionRef: | ||
name: primary-pool-epp-service | ||
portNumber: 9002 | ||
--- | ||
apiVersion: inference.networking.x-k8s.io/v1alpha2 | ||
kind: InferencePool | ||
metadata: | ||
name: secondary-pool | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: "inference-model-2" | ||
|
||
targetPortNumber: 3000 | ||
extensionRef: | ||
name: secondary-pool-epp-service | ||
portNumber: 9002 | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: route-for-primary-gateway | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
parentRefs: | ||
- kind: Gateway | ||
name: conformance-gateway | ||
namespace: gateway-conformance-infra | ||
rules: | ||
- backendRefs: | ||
- group: inference.networking.x-k8s.io | ||
kind: InferencePool | ||
name: primary-pool | ||
port: 80 | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
matches: | ||
- path: | ||
value: /test-primary-gateway | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: route-for-secondary-gateway | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
parentRefs: | ||
- kind: Gateway | ||
name: conformance-secondary-gateway | ||
namespace: gateway-conformance-infra | ||
hostnames: | ||
- "secondary.example.com" | ||
rules: | ||
- backendRefs: | ||
- group: inference.networking.x-k8s.io | ||
kind: InferencePool | ||
name: secondary-pool | ||
port: 80 | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
matches: | ||
- path: | ||
value: /test-secondary-gateway |
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.