Skip to content
Merged
Show file tree
Hide file tree
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 May 1, 2025
404f522
Resolve setup issues and enable InferencePool test
SinaChavoshi May 2, 2025
d396ecb
correct Lint error Multiplication of durations
SinaChavoshi May 5, 2025
0455c47
Fix missing containerPort, is missing
SinaChavoshi May 5, 2025
b531e66
change gateway name from "gateway-conformance-app" to "conformance-ga…
SinaChavoshi May 5, 2025
5510e69
clarify why K8s types are needed.
SinaChavoshi May 5, 2025
04c9798
Update conformance/conformance.go
SinaChavoshi May 5, 2025
9427f31
Update conformance/conformance.go
SinaChavoshi May 5, 2025
093d3ad
remove for loop when adding SupportedFeatures
SinaChavoshi May 5, 2025
e3c8381
remove exessive logging
SinaChavoshi May 5, 2025
c9a8f77
Update conformance/conformance.go
SinaChavoshi May 5, 2025
5ac19ff
move excess debug logs behind debug flag.
SinaChavoshi May 5, 2025
3b8df3b
remove CONFORMANCE.GO prefix from logs.
SinaChavoshi May 5, 2025
bde61b8
change the pull logic and use default value from GatewayMustHaveAddress
SinaChavoshi May 5, 2025
57d68fd
fix mt.Sprintf can be replaced with string concatenation
SinaChavoshi May 6, 2025
fa93b15
add a function for logDebug
SinaChavoshi May 7, 2025
06f29cc
factor out ensureGatewayAvailableAndReady
SinaChavoshi May 7, 2025
da2e9ef
removed todo comment in helper.go
SinaChavoshi May 7, 2025
5e1d8e9
remove CONFORMANCE.GO from log
SinaChavoshi May 7, 2025
f424464
Add InferencePoolLifecycle test
SinaChavoshi May 8, 2025
84d1ba2
update comments in helper.go
SinaChavoshi May 8, 2025
5ad31cb
Initial commit for InferencePoolNoMatchingPodsRouteStatus test
SinaChavoshi May 9, 2025
738089b
resolve lint issue.
SinaChavoshi May 9, 2025
d8577b0
error messages, should not be capitalized or end with punctuation
SinaChavoshi May 9, 2025
0af3cb6
Merge branch 'inf_pool_tests' into inf_pool_tests_3
SinaChavoshi May 9, 2025
63a82ed
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi May 9, 2025
fc3ee1e
Add inferencepool_lifecycle test.
SinaChavoshi May 1, 2025
ba677ac
Resolve setup issues and enable InferencePool test
SinaChavoshi May 2, 2025
3ff24a1
removed todo comment in helper.go
SinaChavoshi May 7, 2025
2dad18d
Add InferencePoolLifecycle test
SinaChavoshi May 8, 2025
0052a23
update comments in helper.go
SinaChavoshi May 8, 2025
ebfe6df
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi May 9, 2025
b419259
remove Conformanc.go from log message
SinaChavoshi May 12, 2025
08ca992
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi May 12, 2025
f54b575
Remove lifecycle test.
SinaChavoshi May 12, 2025
731f734
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi May 12, 2025
91b053b
Removed unused helper methods ( inference pool must have selector & m…
SinaChavoshi May 12, 2025
d441791
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi May 12, 2025
3a98b84
add back HTTPRouteMustHaveParentStatusConditions
SinaChavoshi May 12, 2025
e4c18d5
Set timeout values as constant
SinaChavoshi May 12, 2025
a07874b
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi May 12, 2025
36073dd
Merge branch 'main' into inf_pool_tests_3
SinaChavoshi May 12, 2025
cd042fe
change timeout.go to timing.go
SinaChavoshi May 13, 2025
c99b24c
Merge branch 'inf_pool_tests_3' into inf_pool_tests_5
SinaChavoshi May 13, 2025
8c7470c
Merge branch 'main' into inf_pool_tests_5
SinaChavoshi May 13, 2025
482103c
remove duplicate log
SinaChavoshi May 13, 2025
3259e0f
remove excess comments and logs
SinaChavoshi May 13, 2025
8f3c119
add comment / todo for Reconciled
SinaChavoshi May 15, 2025
9324f23
Update conformance/utils/kubernetes/helpers.go
SinaChavoshi May 16, 2025
50130f1
change test to HTTPRouteInvalidInferencePoolRef
SinaChavoshi May 17, 2025
53325d9
Merge branch 'inf_pool_tests_5' of https://github.com/SinaChavoshi/ga…
SinaChavoshi May 17, 2025
63c80aa
use TODO: instead of TODO()
SinaChavoshi May 19, 2025
851f989
yaml and todos based on code review
SinaChavoshi May 22, 2025
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
17 changes: 10 additions & 7 deletions conformance/conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"io/fs"
"os"
"testing"
"time"

"github.com/stretchr/testify/require"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -64,6 +63,7 @@ import (

// Import the Inference Extension API types
inferencev1alpha2 "sigs.k8s.io/gateway-api-inference-extension/api/v1alpha2"
inferenceconfig "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/config"
)

// Constants for the shared Gateway
Expand Down Expand Up @@ -185,6 +185,9 @@ func DefaultOptions(t *testing.T) confsuite.ConformanceOptions {
logDebugf(t, opts.Debug, "Removing ExemptFeatures from SupportedFeatures: %v", opts.ExemptFeatures.UnsortedList())
opts.SupportedFeatures = opts.SupportedFeatures.Delete(opts.ExemptFeatures.UnsortedList()...)
}
t.Logf("CONFORMANCE.GO: Final opts.SupportedFeatures: %v", opts.SupportedFeatures.UnsortedList())

logDebugf(t, opts.Debug, "Final opts.SupportedFeatures: %v", opts.SupportedFeatures.UnsortedList())

logDebugf(t, opts.Debug, "Final opts.SupportedFeatures: %v", opts.SupportedFeatures.UnsortedList())

Expand Down Expand Up @@ -245,16 +248,16 @@ func ensureGatewayAvailableAndReady(t *testing.T, k8sClient client.Client, opts
t.Logf("Attempting to fetch Gateway %s/%s.", gatewayNN.Namespace, gatewayNN.Name)
gw := &gatewayv1.Gateway{} // This gw instance will be populated by the poll function

// Define polling interval
// TODO: Make this configurable using a local TimeoutConfig (from ConformanceOptions perhaps)
pollingInterval := 5 * time.Second
// Use the GatewayMustHaveAddress timeout from the suite's TimeoutConfig for the Gateway object to appear
waitForGatewayCreationTimeout := opts.TimeoutConfig.GatewayMustHaveAddress
// Use extension-specific config for the polling interval defined in timeout.go.
extTimeoutConf := inferenceconfig.DefaultInferenceExtensionTimeoutConfig()

// Use the GatewayMustHaveAddress timeout from the suite's base TimeoutConfig for the Gateway object to appear.
waitForGatewayCreationTimeout := extTimeoutConf.TimeoutConfig.GatewayMustHaveAddress

logDebugf(t, opts.Debug, "Waiting up to %v for Gateway object %s/%s to appear after manifest application...", waitForGatewayCreationTimeout, gatewayNN.Namespace, gatewayNN.Name)

ctx := context.TODO()
pollErr := wait.PollUntilContextTimeout(ctx, pollingInterval, waitForGatewayCreationTimeout, true, func(pollCtx context.Context) (bool, error) {
pollErr := wait.PollUntilContextTimeout(ctx, extTimeoutConf.GatewayObjectPollInterval, waitForGatewayCreationTimeout, true, func(pollCtx context.Context) (bool, error) {
fetchErr := k8sClient.Get(pollCtx, gatewayNN, gw)
if fetchErr == nil {
t.Logf("Successfully fetched Gateway %s/%s. Spec.GatewayClassName: %s",
Expand Down
2 changes: 1 addition & 1 deletion conformance/tests/basic/inferencepool_accepted.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var InferencePoolAccepted = suite.ConformanceTest{
Status: metav1.ConditionTrue,
Reason: "", // "" means we don't strictly check the Reason for this basic test.
}
infrakubernetes.InferencePoolMustHaveCondition(t, s.Client, s.TimeoutConfig, poolNN, acceptedCondition)
infrakubernetes.InferencePoolMustHaveCondition(t, s.Client, poolNN, acceptedCondition)
})
},
}
120 changes: 120 additions & 0 deletions conformance/tests/basic/inferencepool_lifecycle.go
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{
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)
})
},
}
95 changes: 95 additions & 0 deletions conformance/tests/basic/inferencepool_lifecycle.yaml
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
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
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
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
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.
*/

package basic

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"
)

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

ShortName: "InferencePoolNoMatchingPodsRouteStatus",
Description: "Tests HTTPRoute and Gateway status when an HTTPRoute references an InferencePool whose modelServerSelector does not match any running pods.",
Manifests: []string{"tests/basic/inferencepool_no_matching_pods_route_status.yaml"},
Features: []features.FeatureName{},
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.")
},
}
Loading