Skip to content

Commit 48b6c97

Browse files
SinaChavoshiLiorLiebermanrobscott
authored
feat(conformance): Add test for HTTPRouteInvalidInferencePoolRef (#807)
* Add inferencepool_lifecycle test. * Resolve setup issues and enable InferencePool test * correct Lint error Multiplication of durations * Fix missing containerPort, is missing * change gateway name from "gateway-conformance-app" to "conformance-gateway" * clarify why K8s types are needed. * Update conformance/conformance.go Co-authored-by: Lior Lieberman <[email protected]> * Update conformance/conformance.go Co-authored-by: Lior Lieberman <[email protected]> * remove for loop when adding SupportedFeatures * remove exessive logging * Update conformance/conformance.go Co-authored-by: Lior Lieberman <[email protected]> * move excess debug logs behind debug flag. * remove CONFORMANCE.GO prefix from logs. * change the pull logic and use default value from GatewayMustHaveAddress * fix mt.Sprintf can be replaced with string concatenation * add a function for logDebug * factor out ensureGatewayAvailableAndReady * removed todo comment in helper.go * remove CONFORMANCE.GO from log * Add InferencePoolLifecycle test * update comments in helper.go * Initial commit for InferencePoolNoMatchingPodsRouteStatus test * resolve lint issue. * error messages, should not be capitalized or end with punctuation * Add inferencepool_lifecycle test. * Resolve setup issues and enable InferencePool test * removed todo comment in helper.go * Add InferencePoolLifecycle test * update comments in helper.go * remove Conformanc.go from log message * Remove lifecycle test. * Removed unused helper methods ( inference pool must have selector & must be deleted) * add back HTTPRouteMustHaveParentStatusConditions * Set timeout values as constant * change timeout.go to timing.go * remove duplicate log * remove excess comments and logs * add comment / todo for Reconciled * Update conformance/utils/kubernetes/helpers.go Co-authored-by: Rob Scott <[email protected]> * change test to HTTPRouteInvalidInferencePoolRef * use TODO: instead of TODO() * yaml and todos based on code review --------- Co-authored-by: Lior Lieberman <[email protected]> Co-authored-by: Rob Scott <[email protected]>
1 parent 5bc7425 commit 48b6c97

File tree

4 files changed

+115
-2
lines changed

4 files changed

+115
-2
lines changed

conformance/conformance.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,18 @@ const (
7777
// Future profiles will cover EPP and ModelServer layers.
7878
const GatewayLayerProfileName confsuite.ConformanceProfileName = "Gateway"
7979

80+
// TODO(#863) Create a dedicated share location for feature names similar to
81+
// sigs.k8s.io/gateway-api/pkg/features and change the tests from
82+
// string casting the feature name to referencing the shared feature names.
83+
84+
// Conformance specific features
85+
const SupportInferencePool features.FeatureName = "SupportInferencePool"
86+
8087
// InferenceCoreFeatures defines the core features that implementations
8188
// of the "Gateway" profile for the Inference Extension MUST support.
8289
var InferenceCoreFeatures = sets.New(
8390
features.SupportGateway, // This is needed to ensure manifest gets applied during setup.
91+
SupportInferencePool,
8492
)
8593

8694
var GatewayLayerProfile = confsuite.ConformanceProfile{
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
// TODO(#864) refactor the structure to put all tests directly under tests instead of creating subfolders.
18+
package basic
19+
20+
import (
21+
"testing"
22+
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
"k8s.io/apimachinery/pkg/types"
25+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
26+
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
27+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
28+
"sigs.k8s.io/gateway-api/pkg/features"
29+
30+
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
31+
)
32+
33+
func init() {
34+
tests.ConformanceTests = append(tests.ConformanceTests, HTTPRouteInvalidInferencePoolRef)
35+
}
36+
37+
var HTTPRouteInvalidInferencePoolRef = suite.ConformanceTest{
38+
ShortName: "HTTPRouteInvalidInferencePoolRef",
39+
Description: "Tests HTTPRoute status when it references an InferencePool that does not exist.",
40+
Manifests: []string{"tests/basic/httproute_invalid_inferencepool_ref.yaml"},
41+
Features: []features.FeatureName{
42+
features.FeatureName("SupportInferencePool"),
43+
features.SupportGateway,
44+
},
45+
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
46+
const (
47+
appBackendNamespace = "gateway-conformance-app-backend"
48+
infraNamespace = "gateway-conformance-infra"
49+
routeName = "httproute-to-non-existent-pool"
50+
gatewayName = "conformance-gateway"
51+
)
52+
routeNN := types.NamespacedName{Name: routeName, Namespace: appBackendNamespace}
53+
gatewayNN := types.NamespacedName{Name: gatewayName, Namespace: infraNamespace}
54+
55+
t.Run("HTTPRoute should have Accepted=True and ResolvedRefs=False for non-existent InferencePool", func(t *testing.T) {
56+
acceptedCondition := metav1.Condition{
57+
Type: string(gatewayv1.RouteConditionAccepted),
58+
Status: metav1.ConditionTrue,
59+
Reason: string(gatewayv1.RouteReasonAccepted),
60+
}
61+
kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, routeNN, gatewayNN, acceptedCondition)
62+
63+
resolvedRefsCondition := metav1.Condition{
64+
Type: string(gatewayv1.RouteConditionResolvedRefs),
65+
Status: metav1.ConditionFalse,
66+
Reason: string(gatewayv1.RouteReasonBackendNotFound),
67+
}
68+
kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, routeNN, gatewayNN, resolvedRefsCondition)
69+
70+
t.Logf("Successfully verified HTTPRoute %s has conditions: Accepted=True and ResolvedRefs=False (Reason: BackendNotFound) for Gateway %s",
71+
routeNN.String(), gatewayNN.String())
72+
})
73+
},
74+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# httproute_invalid_inferencepool_ref.yaml
2+
# This manifest defines an HTTPRoute that references an InferencePool
3+
# by name ("non-existent-inference-pool") which is intentionally NOT defined.
4+
# The test will verify that the HTTPRoute reflects an appropriate
5+
# failure status because the referenced InferencePool backend cannot be found.
6+
7+
apiVersion: gateway.networking.k8s.io/v1
8+
kind: HTTPRoute
9+
metadata:
10+
# This name must match the 'routeNN.Name' in the Go test file.
11+
name: httproute-to-non-existent-pool
12+
# This namespace should be one created by the base manifests,
13+
# typically where backend applications and their routes reside.
14+
namespace: gateway-conformance-app-backend
15+
spec:
16+
parentRefs:
17+
- group: gateway.networking.k8s.io
18+
kind: Gateway
19+
name: conformance-gateway # Name of the shared Gateway from base manifests
20+
namespace: gateway-conformance-infra # Namespace of the shared Gateway
21+
sectionName: http
22+
rules:
23+
- backendRefs:
24+
- group: inference.networking.x-k8s.io
25+
kind: InferencePool
26+
name: non-existent-inference-pool # Intentionally Non-Existing
27+
port: 8080
28+
matches:
29+
- path:
30+
type: PathPrefix
31+
value: /test-non-existent-pool

conformance/tests/basic/inferencepool_accepted.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// Import the tests package to append to ConformanceTests
2929
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
30-
infrakubernetes "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
30+
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
3131
)
3232

3333
func init() {
@@ -54,7 +54,7 @@ var InferencePoolAccepted = suite.ConformanceTest{
5454
Status: metav1.ConditionTrue,
5555
Reason: "", // "" means we don't strictly check the Reason for this basic test.
5656
}
57-
infrakubernetes.InferencePoolMustHaveCondition(t, s.Client, poolNN, acceptedCondition)
57+
k8sutils.InferencePoolMustHaveCondition(t, s.Client, poolNN, acceptedCondition)
5858
})
5959
},
6060
}

0 commit comments

Comments
 (0)