From bb257fd878223333b3565caf840328369cf02dd4 Mon Sep 17 00:00:00 2001 From: Sina Chavoshi Date: Wed, 28 May 2025 21:59:39 +0000 Subject: [PATCH 1/3] fix boilerplate header --- .../inferencepool_resolvedrefs_condition.go | 4 ++-- conformance/utils/traffic/traffic.go | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/conformance/tests/basic/inferencepool_resolvedrefs_condition.go b/conformance/tests/basic/inferencepool_resolvedrefs_condition.go index 25d67f89a..1bb8c7fae 100644 --- a/conformance/tests/basic/inferencepool_resolvedrefs_condition.go +++ b/conformance/tests/basic/inferencepool_resolvedrefs_condition.go @@ -110,8 +110,8 @@ var InferencePoolParentStatus = suite.ConformanceTest{ t.Logf("Deleting HTTPRoute %s", httpRoutePrimaryNN.String()) require.NoError(t, s.Client.Delete(context.TODO(), httpRoutePrimary), "failed to delete httproute-for-primary-gw") - t.Logf("Waiting for %v for Gateway conditions to update after deleting HTTPRoute %s", inferenceTimeoutConfig.HTTPRouteDeletionReconciliationTimeout, httpRoutePrimaryNN.String()) // - time.Sleep(inferenceTimeoutConfig.HTTPRouteDeletionReconciliationTimeout) // + t.Logf("Waiting for %v for Gateway conditions to update after deleting HTTPRoute %s", inferenceTimeoutConfig.HTTPRouteDeletionReconciliationTimeout, httpRoutePrimaryNN.String()) + time.Sleep(inferenceTimeoutConfig.HTTPRouteDeletionReconciliationTimeout) k8sutils.InferencePoolMustBeAcceptedByParent(t, s.Client, poolNN) t.Logf("InferencePool %s still has parent status Accepted:True as expected with one reference remaining.", poolNN.String()) diff --git a/conformance/utils/traffic/traffic.go b/conformance/utils/traffic/traffic.go index 21b4b4bdf..e65f45fb9 100644 --- a/conformance/utils/traffic/traffic.go +++ b/conformance/utils/traffic/traffic.go @@ -1,4 +1,18 @@ -// Add these functions to conformance/utils/traffic/traffic.go +/* +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 traffic From f7d8cbd4380126c03ca82443392ee9858465e6ae Mon Sep 17 00:00:00 2001 From: Sina Chavoshi Date: Tue, 10 Jun 2025 21:35:27 +0000 Subject: [PATCH 2/3] add tests for InferencePoolInvalidEPPService --- .../inferencepool_invalid_epp_service.go | 63 +++++++++++++++++++ .../inferencepool_invalid_epp_service.yaml | 33 ++++++++++ 2 files changed, 96 insertions(+) create mode 100644 conformance/tests/basic/inferencepool_invalid_epp_service.go create mode 100644 conformance/tests/basic/inferencepool_invalid_epp_service.yaml diff --git a/conformance/tests/basic/inferencepool_invalid_epp_service.go b/conformance/tests/basic/inferencepool_invalid_epp_service.go new file mode 100644 index 000000000..adff1432a --- /dev/null +++ b/conformance/tests/basic/inferencepool_invalid_epp_service.go @@ -0,0 +1,63 @@ +/* +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" + + 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" +) + +func init() { + tests.ConformanceTests = append(tests.ConformanceTests, InferencePoolInvalidEPPService) +} + +var InferencePoolInvalidEPPService = suite.ConformanceTest{ + ShortName: "InferencePoolInvalidEPPService", + Description: "Validate that a Gateway reports a failure status when an HTTPRoute references an InferencePool whose EPP service reference does not exist.", + 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 ( + infraNamespace = "gateway-conformance-infra" + gatewayName = "conformance-gateway" + ) + + gatewayNN := types.NamespacedName{Name: gatewayName, Namespace: infraNamespace} + + t.Run("Verify Gateway reports Programmed:Invalid backend reference", func(t *testing.T) { + expectedCondition := metav1.Condition{ + Type: string(gatewayv1.GatewayConditionProgrammed), + Status: metav1.ConditionFalse, + Reason: string(gatewayv1.GatewayReasonInvalid), + } + + kubernetes.GatewayMustHaveCondition(t, s.Client, s.TimeoutConfig, gatewayNN, expectedCondition) + }) + }, +} diff --git a/conformance/tests/basic/inferencepool_invalid_epp_service.yaml b/conformance/tests/basic/inferencepool_invalid_epp_service.yaml new file mode 100644 index 000000000..bd442f8dd --- /dev/null +++ b/conformance/tests/basic/inferencepool_invalid_epp_service.yaml @@ -0,0 +1,33 @@ +apiVersion: inference.networking.x-k8s.io/v1alpha2 +kind: InferencePool +metadata: + name: pool-non-existent-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-pool-non-existent-epp + namespace: gateway-conformance-app-backend +spec: + parentRefs: + - group: gateway.networking.k8s.io + kind: Gateway + name: conformance-gateway + namespace: gateway-conformance-infra + rules: + - backendRefs: + - group: inference.networking.x-k8s.io + kind: InferencePool + name: pool-non-existent-epp + port: 80 + matches: + - path: + type: PathPrefix + value: /non-existent-epp-pool-test From 4413509ef09f3907e4593db0a8f94d3a54f90ec5 Mon Sep 17 00:00:00 2001 From: Sina Chavoshi Date: Thu, 12 Jun 2025 00:26:57 +0000 Subject: [PATCH 3/3] change to expect error on httproute refcond --- .../inferencepool_invalid_epp_service.go | 32 ++++++++++++++----- .../inferencepool_invalid_epp_service.yaml | 14 ++++---- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/conformance/tests/basic/inferencepool_invalid_epp_service.go b/conformance/tests/basic/inferencepool_invalid_epp_service.go index adff1432a..cfbeb2840 100644 --- a/conformance/tests/basic/inferencepool_invalid_epp_service.go +++ b/conformance/tests/basic/inferencepool_invalid_epp_service.go @@ -17,6 +17,7 @@ limitations under the License. package basic import ( + "net/http" "testing" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,6 +28,7 @@ import ( "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() { @@ -35,7 +37,7 @@ func init() { var InferencePoolInvalidEPPService = suite.ConformanceTest{ ShortName: "InferencePoolInvalidEPPService", - Description: "Validate that a Gateway reports a failure status when an HTTPRoute references an InferencePool whose EPP service reference does not exist.", + 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, @@ -44,20 +46,34 @@ var InferencePoolInvalidEPPService = suite.ConformanceTest{ }, Test: func(t *testing.T, s *suite.ConformanceTestSuite) { const ( + routePath = "/invalid-epp-test" infraNamespace = "gateway-conformance-infra" - gatewayName = "conformance-gateway" + appNamespace = "gateway-conformance-app-backend" ) - gatewayNN := types.NamespacedName{Name: gatewayName, Namespace: infraNamespace} + routeNN := types.NamespacedName{Name: "httproute-for-invalid-epp-pool", Namespace: appNamespace} + gwNN := types.NamespacedName{Name: "conformance-gateway", Namespace: infraNamespace} - t.Run("Verify Gateway reports Programmed:Invalid backend reference", func(t *testing.T) { - expectedCondition := metav1.Condition{ - Type: string(gatewayv1.GatewayConditionProgrammed), + 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.GatewayReasonInvalid), + Reason: string(gatewayv1.RouteReasonBackendNotFound), } + kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, routeNN, gwNN, resolvedRefsCond) + }) - kubernetes.GatewayMustHaveCondition(t, s.Client, s.TimeoutConfig, gatewayNN, expectedCondition) + 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, + }, + }) }) }, } diff --git a/conformance/tests/basic/inferencepool_invalid_epp_service.yaml b/conformance/tests/basic/inferencepool_invalid_epp_service.yaml index bd442f8dd..00941bb32 100644 --- a/conformance/tests/basic/inferencepool_invalid_epp_service.yaml +++ b/conformance/tests/basic/inferencepool_invalid_epp_service.yaml @@ -1,7 +1,7 @@ apiVersion: inference.networking.x-k8s.io/v1alpha2 kind: InferencePool metadata: - name: pool-non-existent-epp + name: pool-with-invalid-epp namespace: gateway-conformance-app-backend spec: selector: @@ -13,21 +13,19 @@ spec: apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: httproute-for-pool-non-existent-epp + name: httproute-for-invalid-epp-pool namespace: gateway-conformance-app-backend spec: parentRefs: - - group: gateway.networking.k8s.io - kind: Gateway - name: conformance-gateway + - name: conformance-gateway namespace: gateway-conformance-infra rules: - backendRefs: - - group: inference.networking.x-k8s.io + - name: pool-with-invalid-epp kind: InferencePool - name: pool-non-existent-epp + group: inference.networking.x-k8s.io port: 80 matches: - path: type: PathPrefix - value: /non-existent-epp-pool-test + value: /invalid-epp-test