generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 205
feat(conformance): Add test for HTTPRouteInvalidInferencePoolRef #807
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
k8s-ci-robot
merged 53 commits into
kubernetes-sigs:main
from
SinaChavoshi:inf_pool_tests_5
May 27, 2025
Merged
Changes from 32 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
eae4c99
Add inferencepool_lifecycle test.
SinaChavoshi 404f522
Resolve setup issues and enable InferencePool test
SinaChavoshi d396ecb
correct Lint error Multiplication of durations
SinaChavoshi 0455c47
Fix missing containerPort, is missing
SinaChavoshi b531e66
change gateway name from "gateway-conformance-app" to "conformance-ga…
SinaChavoshi 5510e69
clarify why K8s types are needed.
SinaChavoshi 04c9798
Update conformance/conformance.go
SinaChavoshi 9427f31
Update conformance/conformance.go
SinaChavoshi 093d3ad
remove for loop when adding SupportedFeatures
SinaChavoshi e3c8381
remove exessive logging
SinaChavoshi c9a8f77
Update conformance/conformance.go
SinaChavoshi 5ac19ff
move excess debug logs behind debug flag.
SinaChavoshi 3b8df3b
remove CONFORMANCE.GO prefix from logs.
SinaChavoshi bde61b8
change the pull logic and use default value from GatewayMustHaveAddress
SinaChavoshi 57d68fd
fix mt.Sprintf can be replaced with string concatenation
SinaChavoshi fa93b15
add a function for logDebug
SinaChavoshi 06f29cc
factor out ensureGatewayAvailableAndReady
SinaChavoshi da2e9ef
removed todo comment in helper.go
SinaChavoshi 5e1d8e9
remove CONFORMANCE.GO from log
SinaChavoshi f424464
Add InferencePoolLifecycle test
SinaChavoshi 84d1ba2
update comments in helper.go
SinaChavoshi 5ad31cb
Initial commit for InferencePoolNoMatchingPodsRouteStatus test
SinaChavoshi 738089b
resolve lint issue.
SinaChavoshi d8577b0
error messages, should not be capitalized or end with punctuation
SinaChavoshi 0af3cb6
Merge branch 'inf_pool_tests' into inf_pool_tests_3
SinaChavoshi 63a82ed
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi fc3ee1e
Add inferencepool_lifecycle test.
SinaChavoshi ba677ac
Resolve setup issues and enable InferencePool test
SinaChavoshi 3ff24a1
removed todo comment in helper.go
SinaChavoshi 2dad18d
Add InferencePoolLifecycle test
SinaChavoshi 0052a23
update comments in helper.go
SinaChavoshi ebfe6df
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi b419259
remove Conformanc.go from log message
SinaChavoshi 08ca992
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi f54b575
Remove lifecycle test.
SinaChavoshi 731f734
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi 91b053b
Removed unused helper methods ( inference pool must have selector & m…
SinaChavoshi d441791
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi 3a98b84
add back HTTPRouteMustHaveParentStatusConditions
SinaChavoshi e4c18d5
Set timeout values as constant
SinaChavoshi a07874b
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi 36073dd
Merge branch 'main' into inf_pool_tests_3
SinaChavoshi cd042fe
change timeout.go to timing.go
SinaChavoshi c99b24c
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi 8c7470c
Merge branch 'main' into inf_pool_tests_5
SinaChavoshi 482103c
remove duplicate log
SinaChavoshi 3259e0f
remove excess comments and logs
SinaChavoshi 8f3c119
add comment / todo for Reconciled
SinaChavoshi 9324f23
Update conformance/utils/kubernetes/helpers.go
SinaChavoshi 50130f1
change test to HTTPRouteInvalidInferencePoolRef
SinaChavoshi 53325d9
Merge branch 'inf_pool_tests_5' of https://github.com/SinaChavoshi/ga…
SinaChavoshi 63c80aa
use TODO: instead of TODO()
SinaChavoshi 851f989
yaml and todos based on code review
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
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
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
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,120 @@ | ||
| /* | ||
| 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, | ||
| WITHOUTHOUT 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 ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/types" | ||
|
|
||
| gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" | ||
| "sigs.k8s.io/gateway-api/conformance/utils/suite" | ||
| "sigs.k8s.io/gateway-api/pkg/features" | ||
|
|
||
| inferenceapi "sigs.k8s.io/gateway-api-inference-extension/api/v1alpha2" | ||
| "sigs.k8s.io/gateway-api-inference-extension/conformance/tests" | ||
| infrakubernetes "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes" | ||
| ) | ||
|
|
||
| func init() { | ||
| tests.ConformanceTests = append(tests.ConformanceTests, InferencePoolLifecycle) | ||
| } | ||
|
|
||
| var InferencePoolLifecycle = suite.ConformanceTest{ | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ShortName: "InferencePoolLifecycle", | ||
| Description: "Tests basic CRUD (Create, Read, Update, Delete) operations for an InferencePool resource, assuming current API definition.", | ||
| Manifests: []string{"tests/basic/inferencepool_lifecycle.yaml"}, | ||
| Features: []features.FeatureName{}, | ||
| Test: func(t *testing.T, s *suite.ConformanceTestSuite) { | ||
| poolName := "inferencepool-lifecycle" | ||
|
|
||
| const hardcodedNamespace = "gateway-conformance-app-backend" | ||
| poolNN := types.NamespacedName{ | ||
| Name: poolName, | ||
| Namespace: hardcodedNamespace, | ||
| } | ||
|
|
||
| acceptedCondition := metav1.Condition{ | ||
| Type: string(gatewayv1.GatewayConditionAccepted), | ||
| Status: metav1.ConditionTrue, | ||
| Reason: "", | ||
| } | ||
|
|
||
| t.Run("Step 1 & 2: Create and Read InferencePool", func(t *testing.T) { | ||
| infrakubernetes.InferencePoolMustHaveCondition(t, s.Client, poolNN, acceptedCondition) | ||
|
|
||
| createdPool := &inferenceapi.InferencePool{} | ||
| err := s.Client.Get(context.Background(), poolNN, createdPool) | ||
| require.NoErrorf(t, err, "Failed to get InferencePool %s/%s", poolNN.Namespace, poolNN.Name) | ||
|
|
||
| // Verify fields based on the current API (using .Spec.Selector) | ||
| // TODO: https://github.com/kubernetes-sigs/gateway-api-inference-extension/issues/766 | ||
| // API Discrepancy: InferencePoolSpec pod selector field name mismatch between API | ||
| // Proposal 002 and current Go type definition | ||
| require.NotNil(t, createdPool.Spec.Selector, "Selector should not be nil") | ||
| require.Equal(t, inferenceapi.LabelValue("infra-backend-v1"), createdPool.Spec.Selector[inferenceapi.LabelKey("app")], | ||
| "Selector 'app' label does not match manifest") | ||
|
|
||
| t.Logf("Successfully created and read InferencePool %s/%s", poolNN.Namespace, poolNN.Name) | ||
| }) | ||
|
|
||
| t.Run("Step 3: Update InferencePool", func(t *testing.T) { | ||
| originalPool := &inferenceapi.InferencePool{} | ||
| err := s.Client.Get(context.Background(), poolNN, originalPool) | ||
| require.NoErrorf(t, err, "Failed to get InferencePool %s for update", poolNN.String()) | ||
|
|
||
| updatedPool := originalPool.DeepCopy() | ||
| newSelector := map[inferenceapi.LabelKey]inferenceapi.LabelValue{ | ||
| inferenceapi.LabelKey("app"): inferenceapi.LabelValue("lifecycle-test-app-updated"), | ||
| } | ||
| updatedPool.Spec.Selector = newSelector | ||
|
|
||
| err = s.Client.Update(context.Background(), updatedPool) | ||
| require.NoErrorf(t, err, "Failed to update InferencePool %s", poolNN.String()) | ||
| infrakubernetes.InferencePoolMustHaveSelector(t, s.Client, poolNN, newSelector) | ||
|
|
||
| fetchedAfterUpdate := &inferenceapi.InferencePool{} | ||
| err = s.Client.Get(context.Background(), poolNN, fetchedAfterUpdate) | ||
| require.NoErrorf(t, err, "Failed to get InferencePool %s after update verification", poolNN.String()) | ||
| require.NotNil(t, fetchedAfterUpdate.Spec.Selector, "Updated Selector should not be nil") | ||
| require.Equal(t, inferenceapi.LabelValue("lifecycle-test-app-updated"), fetchedAfterUpdate.Spec.Selector[inferenceapi.LabelKey("app")], | ||
| "Selector 'app' label was not updated as expected") | ||
| t.Logf("Successfully updated InferencePool %s/%s", poolNN.Namespace, poolNN.Name) | ||
| }) | ||
|
|
||
| t.Run("Step 4: Delete InferencePool", func(t *testing.T) { | ||
| t.Logf("Attempting to explicitly delete InferencePool %s/%s for verification", poolNN.Namespace, poolNN.Name) | ||
| poolToDelete := &inferenceapi.InferencePool{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: poolName, | ||
| Namespace: hardcodedNamespace, | ||
| }, | ||
| } | ||
| err := s.Client.Delete(context.Background(), poolToDelete) | ||
| if err != nil && !apierrors.IsNotFound(err) { | ||
| require.NoErrorf(t, err, "Failed to delete InferencePool %s", poolNN.String()) | ||
| } | ||
|
|
||
| infrakubernetes.InferencePoolMustBeDeleted(t, s.Client, poolNN) | ||
| t.Logf("Successfully verified deletion of InferencePool %s/%s", poolNN.Namespace, poolNN.Name) | ||
| }) | ||
| }, | ||
| } | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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,95 @@ | ||
| # Basic InferencePool lifecycle test. | ||
| # This manifest defines the minimal required fields to create valid | ||
| # InferencePool and HTTPRoute resources, which the lifecycle test | ||
| # will use to verify that the controller recognizes and accepts the resource. | ||
|
|
||
| # --- Minimal Backend Deployment (using agnhost echo server) --- | ||
| # This Deployment provides Pods for the InferencePool to select. | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: infra-backend-v1-deployment | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| namespace: gateway-conformance-app-backend | ||
| labels: | ||
| app: infra-backend-v1 | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: infra-backend-v1 | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: infra-backend-v1 | ||
| spec: | ||
| containers: | ||
| - name: agnhost-echo | ||
| image: k8s.gcr.io/e2e-test-images/agnhost:2.39 | ||
| args: | ||
| - serve-hostname | ||
| - --http-port=8080 | ||
| ports: | ||
| - name: http | ||
| containerPort: 8080 | ||
| readinessProbe: | ||
| httpGet: | ||
| path: / | ||
| port: 8080 | ||
| initialDelaySeconds: 3 | ||
| periodSeconds: 5 | ||
| failureThreshold: 2 | ||
|
|
||
| --- | ||
| # --- InferencePool Definition for Lifecycle Test --- | ||
| apiVersion: inference.networking.x-k8s.io/v1alpha2 | ||
| kind: InferencePool | ||
| metadata: | ||
| # This name must match the 'poolNN' variable defined in the | ||
| # conformance/tests/basic/inferencepool_lifecycle.go test file. | ||
| name: inferencepool-lifecycle | ||
| # This namespace should be one created by the base manifests. | ||
| namespace: gateway-conformance-app-backend | ||
| spec: | ||
| # --- Selector (Required) --- | ||
| # Selects the Pods belonging to this pool. | ||
| selector: | ||
| app: "infra-backend-v1" | ||
|
|
||
| # --- Target Port (Required) --- | ||
| # The port the model server container (agnhost in this case) listens on. | ||
| targetPortNumber: 8080 # Matches agnhost's http-port | ||
|
|
||
| # --- Extension Reference --- | ||
| # GKE-specific configuration reference. | ||
| extensionRef: | ||
| # group: "" # Optional | ||
| # kind: Service # Optional | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name: infra-backend-v1-epp | ||
|
|
||
| --- | ||
| # --- HTTPRoute Definition for Lifecycle Test --- | ||
| # This HTTPRoute links the InferencePool to the shared Gateway, | ||
| # allowing the InferencePool to receive an "Accepted" status condition. | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: | ||
| name: httproute-for-inferencepool-lifecycle | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| namespace: gateway-conformance-app-backend | ||
| spec: | ||
| parentRefs: | ||
| - group: gateway.networking.k8s.io | ||
| kind: Gateway | ||
| name: conformance-gateway # Name of the shared Gateway from manifests.yaml | ||
| namespace: gateway-conformance-infra # Namespace of the shared Gateway | ||
| sectionName: http | ||
| rules: | ||
| - backendRefs: | ||
| - group: inference.networking.x-k8s.io # InferencePool API group | ||
| kind: InferencePool | ||
| name: inferencepool-lifecycle # Name of the InferencePool this route points to | ||
| # namespace: gateway-conformance-app-backend - is omitted since it is in the same namespace as HTTPRoute | ||
| port: 8080 # Matching the InferencePool's targetPortNumber | ||
| matches: | ||
| - path: | ||
| type: PathPrefix | ||
| value: /lifecycle-pool-test | ||
95 changes: 95 additions & 0 deletions
95
conformance/tests/basic/inferencepool_no_matching_pods_route_status.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,95 @@ | ||
| /* | ||
| 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. | ||
| */ | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| package basic | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" | ||
| "sigs.k8s.io/gateway-api/conformance/utils/suite" | ||
| "sigs.k8s.io/gateway-api/pkg/features" | ||
|
|
||
| "sigs.k8s.io/gateway-api-inference-extension/conformance/tests" | ||
| infrakubernetes "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes" | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| func init() { | ||
| tests.ConformanceTests = append(tests.ConformanceTests, InferencePoolNoMatchingPodsRouteStatus) | ||
| } | ||
|
|
||
| var InferencePoolNoMatchingPodsRouteStatus = suite.ConformanceTest{ | ||
| // TODO: Update based on the outcome of https://github.com/kubernetes-sigs/gateway-api-inference-extension/issues/806 | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ShortName: "InferencePoolNoMatchingPodsRouteStatus", | ||
| Description: "Tests HTTPRoute and Gateway status when an HTTPRoute references an InferencePool whose modelServerSelector does not match any running pods.", | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Manifests: []string{"tests/basic/inferencepool_no_matching_pods_route_status.yaml"}, | ||
| Features: []features.FeatureName{}, | ||
SinaChavoshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Test: func(t *testing.T, s *suite.ConformanceTestSuite) { | ||
| const ( | ||
| appBackendNamespace = "gateway-conformance-app-backend" | ||
| infraNamespace = "gateway-conformance-infra" | ||
| poolName = "pool-no-pods" | ||
| httpRouteName = "httproute-for-pool-no-pods" | ||
| gatewayName = "conformance-gateway" | ||
| expectedRouteReason = "ReconciliationFailed" | ||
| expectedGatewayReason = "Invalid" | ||
| ) | ||
|
|
||
| poolNN := types.NamespacedName{Name: poolName, Namespace: appBackendNamespace} | ||
| routeNN := types.NamespacedName{Name: httpRouteName, Namespace: appBackendNamespace} | ||
| gatewayNN := types.NamespacedName{Name: gatewayName, Namespace: infraNamespace} | ||
|
|
||
| t.Logf("Manifests applied. Waiting for controllers to process InferencePool %s and HTTPRoute %s", poolNN.String(), routeNN.String()) | ||
|
|
||
| // Step 1: Verify initial acceptance of the InferencePool by the Gateway (via the HTTPRoute) | ||
| // The InferencePool's .status.parent field should show it's Accepted by the Gateway. | ||
| t.Logf("Verifying InferencePool %s is initially accepted by Gateway %s (via HTTPRoute %s)", poolNN.String(), gatewayNN.String(), routeNN.String()) | ||
| acceptedCondition := metav1.Condition{ | ||
| Type: string(gatewayv1.RouteConditionAccepted), // For the route parent status on InferencePool | ||
| Status: metav1.ConditionTrue, | ||
| Reason: string(gatewayv1.RouteReasonAccepted), | ||
| } | ||
| infrakubernetes.InferencePoolMustHaveCondition(t, s.Client, poolNN, acceptedCondition) | ||
| t.Logf("InferencePool %s parent status shows Accepted by Gateway %s", poolNN.String(), gatewayNN.String()) | ||
|
|
||
| // Step 2: Observe the status of the HTTPRoute | ||
| // Expect the HTTPRoute to be Accepted but fail Reconciliation due to backend issues. | ||
| t.Logf("Polling for HTTPRoute %s status to reflect backend issues...", routeNN.String()) | ||
|
|
||
| expectedAcceptedRouteCond := metav1.Condition{ | ||
| Type: string(gatewayv1.RouteConditionAccepted), | ||
| Status: metav1.ConditionTrue, | ||
| } | ||
|
|
||
| expectedFailureRouteCond := metav1.Condition{ | ||
| Type: string(gatewayv1.RouteConditionType("Reconciled")), // As observed in POC logs | ||
| Status: metav1.ConditionFalse, | ||
| Reason: expectedRouteReason, | ||
| } | ||
|
|
||
| expectedFailureMessageSubstrings := []string{ | ||
| "missing Service", // As observed in POC logs | ||
| fmt.Sprintf("%s/%s-epp", appBackendNamespace, poolName), | ||
| } | ||
|
|
||
| infrakubernetes.HTTPRouteMustHaveParentStatusConditions(t, s.Client, routeNN, gatewayNN, s.ControllerName, | ||
| expectedAcceptedRouteCond, expectedFailureRouteCond, expectedFailureMessageSubstrings) | ||
|
|
||
| t.Logf("TestInferencePoolNoMatchingPodsRouteStatus completed.") | ||
| }, | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.