Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions conformance/tests/basic/inferencepool_invalid_epp_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
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 (
"net/http"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"

"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
conformancehttp "sigs.k8s.io/gateway-api/conformance/utils/http"
)

func init() {
tests.ConformanceTests = append(tests.ConformanceTests, InferencePoolInvalidEPPService)
}

var InferencePoolInvalidEPPService = suite.ConformanceTest{
ShortName: "InferencePoolInvalidEPPService",
Description: "An HTTPRoute that references an InferencePool with a non-existent EPP service should have a ResolvedRefs condition with a status of False and a reason of BackendNotFound.",
Manifests: []string{"tests/basic/inferencepool_invalid_epp_service.yaml"},
Features: []features.FeatureName{
features.SupportGateway,
features.SupportHTTPRoute,
features.FeatureName("SupportInferencePool"),
},
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
const (
routePath = "/invalid-epp-test"
infraNamespace = "gateway-conformance-infra"
appNamespace = "gateway-conformance-app-backend"
)

routeNN := types.NamespacedName{Name: "httproute-for-invalid-epp-pool", Namespace: appNamespace}
gwNN := types.NamespacedName{Name: "conformance-gateway", Namespace: infraNamespace}

gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, s.Client, s.TimeoutConfig, s.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)

t.Run("HTTPRoute has a ResolvedRefs Condition with status False and Reason BackendNotFound", func(t *testing.T) {
resolvedRefsCond := metav1.Condition{
Type: string(gatewayv1.RouteConditionResolvedRefs),
Status: metav1.ConditionFalse,
Reason: string(gatewayv1.RouteReasonBackendNotFound),
}
kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, routeNN, gwNN, resolvedRefsCond)
})

t.Run("Request to a route with an invalid backend reference receives a 500 response", func(t *testing.T) {
conformancehttp.MakeRequestAndExpectEventuallyConsistentResponse(t, s.RoundTripper, s.TimeoutConfig, gwAddr, conformancehttp.ExpectedResponse{
Request: conformancehttp.Request{
Path: routePath,
},
Response: conformancehttp.Response{
StatusCode: http.StatusInternalServerError,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind including a change to the corresponding API spec for this?

https://github.com/kubernetes-sigs/gateway-api-inference-extension/blob/main/api/v1alpha2/inferencepool_types.go#L75

I'd recommend adding something along the lines of:

"When an ExtensionRef is invalid, such as pointing to a Service that does not exist, 500 status codes MUST be returned for requests that would have otherwise been routed to the InferencePool"

This is similar to https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1/httproute_types.go#L265C5-L266C73.

cc @danehans @shaneutt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SinaChavoshi @robscott I pushed #991 to resolve this comment, PTAL.

},
})
})
},
}
31 changes: 31 additions & 0 deletions conformance/tests/basic/inferencepool_invalid_epp_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: inference.networking.x-k8s.io/v1alpha2
kind: InferencePool
metadata:
name: pool-with-invalid-epp
namespace: gateway-conformance-app-backend
spec:
selector:
app: "inference-model-1"
targetPortNumber: 3000
extensionRef:
name: non-existent-epp-svc
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: httproute-for-invalid-epp-pool
namespace: gateway-conformance-app-backend
spec:
parentRefs:
- name: conformance-gateway
namespace: gateway-conformance-infra
rules:
- backendRefs:
- name: pool-with-invalid-epp
kind: InferencePool
group: inference.networking.x-k8s.io
port: 80
matches:
- path:
type: PathPrefix
value: /invalid-epp-test