generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 180
feat(conformance): Add test for invalid EPP service reference #959
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bb257fd
fix boilerplate header
SinaChavoshi fc2a410
Merge remote-tracking branch 'upstream/main'
SinaChavoshi d34457a
Merge remote-tracking branch 'upstream/main'
SinaChavoshi 753917a
Merge remote-tracking branch 'upstream/main'
SinaChavoshi d5530dc
Merge remote-tracking branch 'upstream/main'
SinaChavoshi b57fb8a
Merge remote-tracking branch 'upstream/main'
SinaChavoshi f7d8cbd
add tests for InferencePoolInvalidEPPService
SinaChavoshi 4413509
change to expect error on httproute refcond
SinaChavoshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
conformance/tests/basic/inferencepool_invalid_epp_service.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}) | ||
}) | ||
}, | ||
} |
31 changes: 31 additions & 0 deletions
31
conformance/tests/basic/inferencepool_invalid_epp_service.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.