-
Notifications
You must be signed in to change notification settings - Fork 180
feat(conformance): Add HTTPRouteMultipleRulesDifferentPools test #834
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 all commits
87d1756
a9dcb62
c36e5f8
aaf23e2
2a67e7d
8ac7d72
66f325d
fd0fa10
59b1f9c
8a078dc
c55a803
c6bacb4
271b7a8
c92a402
bb257fd
5a61a70
6fa352d
5f1bcad
e5fc860
62791b5
2f08131
fc2a410
d34457a
753917a
f4bcc9a
d5530dc
0ce459c
3b884d6
d90eae0
73731e3
b57fb8a
6ee73d5
b239930
66b8426
9432280
ad82e88
04f52f3
d6b588e
112d878
120feb3
8214cdf
76cb644
5dca67b
f2c0602
daeb8e6
f1ab79f
81562a2
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 |
---|---|---|
|
@@ -4,57 +4,45 @@ | |
# individual test files or other resource directories (e.g., sample_backends). | ||
|
||
--- | ||
# Namespace for core infrastructure like Gateways. | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: gateway-conformance-infra | ||
labels: | ||
gateway-conformance: infra | ||
--- | ||
# Namespace for application backends (potentially simulating model servers | ||
# or where InferencePools might reside in some tests). | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: gateway-conformance-app-backend | ||
labels: | ||
gateway-conformance: backend | ||
--- | ||
# Namespace for simple web server backends. This is expected by | ||
# the upstream conformance suite's Setup method. | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: gateway-conformance-web-backend | ||
labels: | ||
gateway-conformance: web-backend | ||
--- | ||
# A basic Gateway resource that allows HTTPRoutes from the same namespace. | ||
# Tests can use this as a parent reference for routes that target InferencePools. | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: conformance-gateway | ||
namespace: gateway-conformance-infra | ||
spec: | ||
# The conformance suite runner will replace this placeholder | ||
# with the actual GatewayClass name provided via flags. | ||
gatewayClassName: "{GATEWAY_CLASS_NAME}" | ||
listeners: | ||
- name: http # Standard listener name | ||
- name: http | ||
port: 80 | ||
protocol: HTTP | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
kinds: | ||
# Allows HTTPRoutes to attach, which can then reference InferencePools. | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
--- | ||
# --- Conformance Secondary Gateway Definition --- | ||
# A second generic Gateway resource for tests requiring multiple Gateways. | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
|
@@ -66,7 +54,95 @@ spec: | |
- name: http | ||
port: 80 | ||
protocol: HTTP | ||
hostname: "secondary.example.com" # Distinct hostname to differentiate from conformance-gateway | ||
hostname: "secondary.example.com" | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: inference-model-1 | ||
namespace: gateway-conformance-app-backend | ||
labels: | ||
app: inference-model-1 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: inference-model-1 | ||
template: | ||
metadata: | ||
labels: | ||
app: inference-model-1 | ||
spec: | ||
containers: | ||
- name: echo-basic-1 | ||
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd | ||
ports: | ||
- name: http | ||
containerPort: 3000 | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: 3000 | ||
initialDelaySeconds: 3 | ||
periodSeconds: 5 | ||
failureThreshold: 2 | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
Comment on lines
+93
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Is POD_NAME being used? If not, stick with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is used in traffic.go There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ is my understanding as well. As you state, pod labels and pod name are being used and not the |
||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: inference-model-2 | ||
namespace: gateway-conformance-app-backend | ||
labels: | ||
app: inference-model-2 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: inference-model-2 | ||
template: | ||
metadata: | ||
labels: | ||
app: inference-model-2 | ||
spec: | ||
containers: | ||
- name: echo-basic-2 | ||
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd | ||
ports: | ||
- name: http | ||
containerPort: 3000 | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: 3000 | ||
initialDelaySeconds: 3 | ||
periodSeconds: 5 | ||
failureThreshold: 2 | ||
env: | ||
- name: POD_NAME | ||
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
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 | ||
|
||
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/pkg/features" | ||
|
||
"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, HTTPRouteMultipleRulesDifferentPools) | ||
} | ||
|
||
var HTTPRouteMultipleRulesDifferentPools = suite.ConformanceTest{ | ||
ShortName: "HTTPRouteMultipleRulesDifferentPools", | ||
Description: "An HTTPRoute with two rules routing to two different InferencePools", | ||
Manifests: []string{"tests/basic/inferencepool_multiple_rules_different_pools.yaml"}, | ||
Features: []features.FeatureName{ | ||
features.SupportGateway, | ||
features.SupportHTTPRoute, | ||
features.FeatureName("SupportInferencePool"), | ||
}, | ||
Test: func(t *testing.T, s *suite.ConformanceTestSuite) { | ||
const ( | ||
appBackendNamespace = "gateway-conformance-app-backend" | ||
infraNamespace = "gateway-conformance-infra" | ||
|
||
poolPrimaryName = "pool-primary" | ||
poolSecondaryName = "pool-secondary" | ||
routeName = "httproute-multiple-rules-different-pools" | ||
gatewayName = "conformance-gateway" | ||
|
||
backendPrimaryLabelValue = "inference-model-1" | ||
backendSecondaryLabelValue = "inference-model-2" | ||
backendAppLabelKey = "app" | ||
|
||
primaryPath = "/primary" | ||
secondaryPath = "/secondary" | ||
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
primaryPoolNN := types.NamespacedName{Name: poolPrimaryName, Namespace: appBackendNamespace} | ||
secondaryPoolNN := types.NamespacedName{Name: poolSecondaryName, Namespace: appBackendNamespace} | ||
routeNN := types.NamespacedName{Name: routeName, Namespace: appBackendNamespace} | ||
gatewayNN := types.NamespacedName{Name: gatewayName, Namespace: infraNamespace} | ||
|
||
t.Run("Wait for resources to be accepted", func(t *testing.T) { | ||
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(t, s.Client, routeNN, gatewayNN, primaryPoolNN) | ||
k8sutils.HTTPRouteAndInferencePoolMustBeAcceptedAndRouteAccepted(t, s.Client, routeNN, gatewayNN, secondaryPoolNN) | ||
}) | ||
|
||
t.Run("Traffic should be routed to the correct pool based on path", func(t *testing.T) { | ||
primarySelector := labels.SelectorFromSet(labels.Set{backendAppLabelKey: backendPrimaryLabelValue}) | ||
secondarySelector := labels.SelectorFromSet(labels.Set{backendAppLabelKey: backendSecondaryLabelValue}) | ||
|
||
primaryPod := k8sutils.GetPod(t, s.Client, appBackendNamespace, primarySelector, s.TimeoutConfig.RequestTimeout) | ||
secondaryPod := k8sutils.GetPod(t, s.Client, appBackendNamespace, secondarySelector, s.TimeoutConfig.RequestTimeout) | ||
|
||
gwAddr := k8sutils.GetGatewayEndpoint(t, s.Client, s.TimeoutConfig, gatewayNN) | ||
|
||
t.Run("request to primary pool", func(t *testing.T) { | ||
trafficutils.MakeRequestAndExpectResponseFromPod(t, s.RoundTripper, s.TimeoutConfig, gwAddr, primaryPath, primaryPod) | ||
}) | ||
|
||
t.Run("request to secondary pool", func(t *testing.T) { | ||
trafficutils.MakeRequestAndExpectResponseFromPod(t, s.RoundTripper, s.TimeoutConfig, gwAddr, secondaryPath, secondaryPod) | ||
}) | ||
}) | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: pool-primary-epp | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: pool-primary-epp | ||
ports: | ||
- name: grpc | ||
port: 9002 | ||
targetPort: 9002 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: pool-primary-epp | ||
namespace: gateway-conformance-app-backend | ||
labels: | ||
app: pool-primary-epp | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: pool-primary-epp | ||
template: | ||
metadata: | ||
labels: | ||
app: pool-primary-epp | ||
spec: | ||
containers: | ||
- name: epp | ||
# TODO(#996) Switch to use a released version of the image instead of epp:main | ||
image: us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-inference-extension/epp:main | ||
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
imagePullPolicy: Always | ||
env: | ||
- name: ENABLE_REQ_HEADER_BASED_SCHEDULER_FOR_TESTING | ||
value: "true" | ||
args: | ||
- "-poolName" | ||
- "pool-primary" | ||
- "-poolNamespace" | ||
- "gateway-conformance-app-backend" | ||
- -grpcPort | ||
- "9002" | ||
- -grpcHealthPort | ||
- "9003" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
SinaChavoshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
metadata: | ||
name: pool-secondary-epp | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: pool-secondary-epp | ||
ports: | ||
- name: grpc | ||
port: 9002 | ||
targetPort: 9002 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: pool-secondary-epp | ||
namespace: gateway-conformance-app-backend | ||
labels: | ||
app: pool-secondary-epp | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: pool-secondary-epp | ||
template: | ||
metadata: | ||
labels: | ||
app: pool-secondary-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" | ||
- "pool-secondary" | ||
- "-poolNamespace" | ||
- "gateway-conformance-app-backend" | ||
- -grpcPort | ||
- "9002" | ||
- -grpcHealthPort | ||
- "9003" | ||
--- | ||
apiVersion: inference.networking.x-k8s.io/v1alpha2 | ||
kind: InferencePool | ||
metadata: | ||
name: pool-primary | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: inference-model-1 | ||
targetPortNumber: 3000 | ||
extensionRef: | ||
name: pool-primary-epp | ||
portNumber: 9002 | ||
--- | ||
apiVersion: inference.networking.x-k8s.io/v1alpha2 | ||
kind: InferencePool | ||
metadata: | ||
name: pool-secondary | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
selector: | ||
app: inference-model-2 | ||
targetPortNumber: 3000 | ||
extensionRef: | ||
name: pool-secondary-epp | ||
portNumber: 9002 | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: httproute-multiple-rules-different-pools | ||
namespace: gateway-conformance-app-backend | ||
spec: | ||
parentRefs: | ||
- name: conformance-gateway | ||
namespace: gateway-conformance-infra | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /primary | ||
backendRefs: | ||
- name: pool-primary | ||
kind: InferencePool | ||
group: inference.networking.x-k8s.io | ||
port: 80 | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /secondary | ||
backendRefs: | ||
- name: pool-secondary | ||
kind: InferencePool | ||
group: inference.networking.x-k8s.io | ||
port: 80 |
Uh oh!
There was an error while loading. Please reload this page.