Skip to content

Commit ea5f667

Browse files
authored
feat(conformance): Add test for invalid EPP service reference (#959)
* fix boilerplate header * add tests for InferencePoolInvalidEPPService * change to expect error on httproute refcond
1 parent 9c1a72a commit ea5f667

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
"net/http"
21+
"testing"
22+
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
"k8s.io/apimachinery/pkg/types"
25+
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
26+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
27+
"sigs.k8s.io/gateway-api/pkg/features"
28+
29+
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
30+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
31+
conformancehttp "sigs.k8s.io/gateway-api/conformance/utils/http"
32+
)
33+
34+
func init() {
35+
tests.ConformanceTests = append(tests.ConformanceTests, InferencePoolInvalidEPPService)
36+
}
37+
38+
var InferencePoolInvalidEPPService = suite.ConformanceTest{
39+
ShortName: "InferencePoolInvalidEPPService",
40+
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.",
41+
Manifests: []string{"tests/basic/inferencepool_invalid_epp_service.yaml"},
42+
Features: []features.FeatureName{
43+
features.SupportGateway,
44+
features.SupportHTTPRoute,
45+
features.FeatureName("SupportInferencePool"),
46+
},
47+
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
48+
const (
49+
routePath = "/invalid-epp-test"
50+
infraNamespace = "gateway-conformance-infra"
51+
appNamespace = "gateway-conformance-app-backend"
52+
)
53+
54+
routeNN := types.NamespacedName{Name: "httproute-for-invalid-epp-pool", Namespace: appNamespace}
55+
gwNN := types.NamespacedName{Name: "conformance-gateway", Namespace: infraNamespace}
56+
57+
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, s.Client, s.TimeoutConfig, s.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
58+
59+
t.Run("HTTPRoute has a ResolvedRefs Condition with status False and Reason BackendNotFound", func(t *testing.T) {
60+
resolvedRefsCond := metav1.Condition{
61+
Type: string(gatewayv1.RouteConditionResolvedRefs),
62+
Status: metav1.ConditionFalse,
63+
Reason: string(gatewayv1.RouteReasonBackendNotFound),
64+
}
65+
kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, routeNN, gwNN, resolvedRefsCond)
66+
})
67+
68+
t.Run("Request to a route with an invalid backend reference receives a 500 response", func(t *testing.T) {
69+
conformancehttp.MakeRequestAndExpectEventuallyConsistentResponse(t, s.RoundTripper, s.TimeoutConfig, gwAddr, conformancehttp.ExpectedResponse{
70+
Request: conformancehttp.Request{
71+
Path: routePath,
72+
},
73+
Response: conformancehttp.Response{
74+
StatusCode: http.StatusInternalServerError,
75+
},
76+
})
77+
})
78+
},
79+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: inference.networking.x-k8s.io/v1alpha2
2+
kind: InferencePool
3+
metadata:
4+
name: pool-with-invalid-epp
5+
namespace: gateway-conformance-app-backend
6+
spec:
7+
selector:
8+
app: "inference-model-1"
9+
targetPortNumber: 3000
10+
extensionRef:
11+
name: non-existent-epp-svc
12+
---
13+
apiVersion: gateway.networking.k8s.io/v1
14+
kind: HTTPRoute
15+
metadata:
16+
name: httproute-for-invalid-epp-pool
17+
namespace: gateway-conformance-app-backend
18+
spec:
19+
parentRefs:
20+
- name: conformance-gateway
21+
namespace: gateway-conformance-infra
22+
rules:
23+
- backendRefs:
24+
- name: pool-with-invalid-epp
25+
kind: InferencePool
26+
group: inference.networking.x-k8s.io
27+
port: 80
28+
matches:
29+
- path:
30+
type: PathPrefix
31+
value: /invalid-epp-test

0 commit comments

Comments
 (0)