Skip to content

Commit 8a58a0c

Browse files
authored
refactor restructure the conformance tests. (#1232)
1 parent b1b43dc commit 8a58a0c

24 files changed

+220
-265
lines changed

conformance/conformance.go

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
apierrors "k8s.io/apimachinery/pkg/api/errors"
3232
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3333

34-
// Import runtime package for scheme creation
3534
"k8s.io/apimachinery/pkg/runtime"
3635
"k8s.io/apimachinery/pkg/types"
3736
"k8s.io/apimachinery/pkg/util/sets"
@@ -41,41 +40,22 @@ import (
4140
"sigs.k8s.io/controller-runtime/pkg/client"
4241
k8sconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
4342

44-
// Import necessary types and utilities from the core Gateway API conformance suite.
45-
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" // Import core Gateway API types
46-
// Report struct definition
43+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
4744
confflags "sigs.k8s.io/gateway-api/conformance/utils/flags"
4845
apikubernetes "sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
4946
confsuite "sigs.k8s.io/gateway-api/conformance/utils/suite"
5047
"sigs.k8s.io/gateway-api/conformance/utils/tlog"
5148
"sigs.k8s.io/gateway-api/pkg/features"
5249

53-
// Import the Inference Extension API types
5450
inferencev1 "sigs.k8s.io/gateway-api-inference-extension/api/v1"
5551
inferencev1alpha2 "sigs.k8s.io/gateway-api-inference-extension/apix/v1alpha2"
5652

57-
// Import the test definitions package to access the ConformanceTests slice
53+
"sigs.k8s.io/gateway-api-inference-extension/conformance/resources"
5854
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
59-
// Import test packages using blank identifier
60-
// This triggers the init() functions in these packages, which register the tests
61-
// by appending them to the tests.ConformanceTests slice.
62-
_ "sigs.k8s.io/gateway-api-inference-extension/conformance/tests/basic"
6355
inferenceconfig "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/config"
6456
"sigs.k8s.io/gateway-api-inference-extension/version"
6557
)
6658

67-
const (
68-
infraNameSpace = "gateway-conformance-infra"
69-
appBackendNameSpace = "gateway-conformance-app-backend"
70-
primaryGatewayName = "conformance-primary-gateway"
71-
secondaryGatewayName = "conformance-secondary-gateway"
72-
)
73-
74-
var (
75-
primaryGatewayNN = types.NamespacedName{Name: primaryGatewayName, Namespace: infraNameSpace}
76-
secondaryGatewayNN = types.NamespacedName{Name: secondaryGatewayName, Namespace: infraNameSpace}
77-
)
78-
7959
// GatewayLayerProfileName defines the name for the conformance profile that tests
8060
// the Gateway API layer aspects of the Inference Extension (e.g., InferencePool, InferenceObjective CRDs).
8161
// Future profiles will cover EPP and ModelServer layers.
@@ -161,7 +141,7 @@ func DefaultOptions(t *testing.T) confsuite.ConformanceOptions {
161141
inferenceExtensionVersion := "v0.3.0"
162142
_ = inferenceExtensionVersion // Avoid unused variable error until implemented
163143

164-
baseManifestsValue := "resources/manifests/manifests.yaml"
144+
baseManifestsValue := "resources/base.yaml"
165145

166146
opts := confsuite.ConformanceOptions{
167147
Client: c,
@@ -275,13 +255,13 @@ func SetupConformanceTestSuite(t *testing.T, suite *confsuite.ConformanceTestSui
275255

276256
tlog.Logf(t, "Test Setup: Ensuring Gateways and Pods from base manifests are ready")
277257
namespaces := []string{
278-
infraNameSpace,
279-
appBackendNameSpace,
258+
resources.InfraNamespace,
259+
resources.AppBackendNamespace,
280260
}
281261
apikubernetes.NamespacesMustBeReady(t, suite.Client, suite.TimeoutConfig, namespaces)
282262

283-
ensureGatewayAvailableAndReady(t, suite.Client, opts, primaryGatewayNN)
284-
ensureGatewayAvailableAndReady(t, suite.Client, opts, secondaryGatewayNN)
263+
ensureGatewayAvailableAndReady(t, suite.Client, opts, resources.PrimaryGatewayNN)
264+
ensureGatewayAvailableAndReady(t, suite.Client, opts, resources.SecondaryGatewayNN)
285265
}
286266

287267
// ensureGatewayAvailableAndReady polls for the specified Gateway to exist and become ready

conformance/resources/manifests/manifests.yaml renamed to conformance/resources/base.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ metadata:
2323
apiVersion: gateway.networking.k8s.io/v1
2424
kind: Gateway
2525
metadata:
26-
name: conformance-primary-gateway
26+
name: conformance-primary
2727
namespace: gateway-conformance-infra
2828
spec:
2929
gatewayClassName: "{GATEWAY_CLASS_NAME}"
@@ -41,7 +41,7 @@ spec:
4141
apiVersion: gateway.networking.k8s.io/v1
4242
kind: Gateway
4343
metadata:
44-
name: conformance-secondary-gateway
44+
name: conformance-secondary
4545
namespace: gateway-conformance-infra
4646
spec:
4747
gatewayClassName: "{GATEWAY_CLASS_NAME}"

conformance/resources/resourcename.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
package resources
18+
19+
import "k8s.io/apimachinery/pkg/types"
20+
21+
const (
22+
AppBackendNamespace = "gateway-conformance-app-backend"
23+
InfraNamespace = "gateway-conformance-infra"
24+
PrimaryGatewayName = "conformance-primary"
25+
SecondaryGatewayName = "conformance-secondary"
26+
27+
PrimaryInferencePoolName = "primary-inference-pool"
28+
SecondaryInferencePoolName = "secondary-inference-pool"
29+
30+
PrimaryModelServerAppLabel = "primary-inference-model-server"
31+
SecondaryModelServerAppLabel = "secondary-inference-model-server"
32+
PrimaryModelServerDeploymentName = "primary-inference-model-server-deployment"
33+
SecondaryModelServerDeploymentName = "secondary-inference-model-server-deployment"
34+
35+
ModelServerPodReplicas = 3
36+
)
37+
38+
var (
39+
PrimaryGatewayNN = types.NamespacedName{Name: PrimaryGatewayName, Namespace: InfraNamespace}
40+
SecondaryGatewayNN = types.NamespacedName{Name: SecondaryGatewayName, Namespace: InfraNamespace}
41+
42+
PrimaryInferencePoolNN = types.NamespacedName{Name: PrimaryInferencePoolName, Namespace: AppBackendNamespace}
43+
SecondaryInferencePoolNN = types.NamespacedName{Name: SecondaryInferencePoolName, Namespace: AppBackendNamespace}
44+
45+
PrimaryEppDeploymentNN = types.NamespacedName{Name: "primary-app-endpoint-picker", Namespace: AppBackendNamespace}
46+
SecondaryEppDeploymentNN = types.NamespacedName{Name: "secondary-app-endpoint-picker", Namespace: AppBackendNamespace}
47+
)

conformance/tests/basic/httproute_invalid_inferencepool_ref.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

conformance/tests/basic/epp_unavailable_fail_open.go renamed to conformance/tests/epp_unavailable_fail_open.go

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,56 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package basic
17+
package tests
1818

1919
import (
2020
"net/http"
2121
"testing"
2222

2323
"github.com/stretchr/testify/require"
2424
"k8s.io/apimachinery/pkg/types"
25+
testfilter "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/test/filter"
2526
"sigs.k8s.io/gateway-api/conformance/utils/suite"
2627
"sigs.k8s.io/gateway-api/pkg/features"
2728

28-
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
29+
"sigs.k8s.io/gateway-api-inference-extension/conformance/resources"
2930
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
3031
trafficutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
3132
)
3233

3334
func init() {
34-
tests.ConformanceTests = append(tests.ConformanceTests, EppUnAvailableFailOpen)
35+
ConformanceTests = append(ConformanceTests, EppUnAvailableFailOpen)
3536
}
3637

3738
var EppUnAvailableFailOpen = suite.ConformanceTest{
3839
ShortName: "EppUnAvailableFailOpen",
3940
Description: "Inference gateway should send traffic to backends even when the EPP is unavailable (fail-open)",
40-
Manifests: []string{"tests/basic/epp_unavailable_fail_open.yaml"},
41+
Manifests: []string{"tests/epp_unavailable_fail_open.yaml"},
4142
Features: []features.FeatureName{
4243
features.FeatureName("SupportInferencePool"),
4344
features.SupportGateway,
4445
},
4546
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
4647
const (
47-
appBackendNamespace = "gateway-conformance-app-backend"
48-
infraNamespace = "gateway-conformance-infra"
49-
hostname = "secondary.example.com"
50-
path = "/failopen-pool-test"
51-
expectedPodReplicas = 3
52-
eppSelectionHeaderName = "test-epp-endpoint-selection"
53-
appPodBackendPrefix = "secondary-inference-model-server"
54-
requestBody = `{
48+
hostname = "secondary.example.com"
49+
path = "/failopen-pool-test"
50+
appPodBackendPrefix = "secondary-inference-model-server"
51+
requestBody = `{
5552
"model": "conformance-fake-model",
5653
"prompt": "Write as if you were a critic: San Francisco"
5754
}`
5855
)
5956

60-
httpRouteNN := types.NamespacedName{Name: "httproute-for-failopen-pool-gw", Namespace: appBackendNamespace}
61-
gatewayNN := types.NamespacedName{Name: "conformance-secondary-gateway", Namespace: infraNamespace}
62-
poolNN := types.NamespacedName{Name: "secondary-inference-pool", Namespace: appBackendNamespace}
63-
eppDeploymentNN := types.NamespacedName{Name: "secondary-app-endpoint-picker", Namespace: appBackendNamespace}
64-
backendPodLabels := map[string]string{"app": "secondary-inference-model-server"}
65-
57+
httpRouteNN := types.NamespacedName{Name: "httproute-for-failopen-pool-gw", Namespace: resources.AppBackendNamespace}
58+
gatewayNN := resources.SecondaryGatewayNN
6659
k8sutils.HTTPRouteMustBeAcceptedAndResolved(t, s.Client, s.TimeoutConfig, httpRouteNN, gatewayNN)
67-
k8sutils.InferencePoolMustBeAcceptedByParent(t, s.Client, poolNN)
60+
k8sutils.InferencePoolMustBeAcceptedByParent(t, s.Client, resources.SecondaryInferencePoolNN)
6861
gwAddr := k8sutils.GetGatewayEndpoint(t, s.Client, s.TimeoutConfig, gatewayNN)
6962

70-
pods, err := k8sutils.GetPodsWithLabel(t, s.Client, appBackendNamespace, backendPodLabels, s.TimeoutConfig)
63+
pods, err := k8sutils.GetPodsWithLabel(t, s.Client, resources.AppBackendNamespace,
64+
map[string]string{"app": resources.SecondaryModelServerAppLabel}, s.TimeoutConfig)
7165
require.NoError(t, err, "Failed to get backend pods")
72-
require.Len(t, pods, expectedPodReplicas, "Expected to find %d backend pod, but found %d.", expectedPodReplicas, len(pods))
66+
require.Len(t, pods, resources.ModelServerPodReplicas, "Expected to find %d backend pod, but found %d.", resources.ModelServerPodReplicas, len(pods))
7367

7468
targetPodIP := pods[0].Status.PodIP
7569
t.Run("Phase 1: Verify baseline connectivity with EPP available", func(t *testing.T) {
@@ -82,18 +76,18 @@ var EppUnAvailableFailOpen = suite.ConformanceTest{
8276
trafficutils.Request{
8377
Host: hostname,
8478
Path: path,
85-
Headers: map[string]string{eppSelectionHeaderName: targetPodIP},
79+
Headers: map[string]string{testfilter.HeaderTestEppEndPointSelectionKey: targetPodIP},
8680
Method: http.MethodPost,
8781
Body: requestBody,
8882
Backend: pods[0].Name, // Make sure the request is from the targetPod when the EPP is alive.
89-
Namespace: appBackendNamespace,
83+
Namespace: resources.AppBackendNamespace,
9084
},
9185
)
9286
})
9387

9488
t.Run("Phase 2: Verify fail-open behavior after EPP becomes unavailable", func(t *testing.T) {
9589
t.Log("Simulating an EPP failure by deleting its deployment...")
96-
deleteErr := k8sutils.DeleteDeployment(t, s.Client, s.TimeoutConfig, eppDeploymentNN)
90+
deleteErr := k8sutils.DeleteDeployment(t, s.Client, s.TimeoutConfig, resources.SecondaryEppDeploymentNN)
9791
require.NoError(t, deleteErr, "Failed to delete the EPP deployment")
9892

9993
t.Log("Sending request again, expecting success to verify fail-open...")
@@ -105,11 +99,11 @@ var EppUnAvailableFailOpen = suite.ConformanceTest{
10599
trafficutils.Request{
106100
Host: hostname,
107101
Path: path,
108-
Headers: map[string]string{eppSelectionHeaderName: targetPodIP},
102+
Headers: map[string]string{testfilter.HeaderTestEppEndPointSelectionKey: targetPodIP},
109103
Method: http.MethodPost,
110104
Body: requestBody,
111105
Backend: appPodBackendPrefix, // Only checks the prefix since the EPP is not alive and the response can return from any Pod.
112-
Namespace: appBackendNamespace,
106+
Namespace: resources.AppBackendNamespace,
113107
},
114108
)
115109
})

conformance/tests/basic/epp_unavailable_fail_open.yaml renamed to conformance/tests/epp_unavailable_fail_open.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
parentRefs:
2121
- group: gateway.networking.k8s.io
2222
kind: Gateway
23-
name: conformance-secondary-gateway
23+
name: conformance-secondary
2424
namespace: gateway-conformance-infra
2525
sectionName: http
2626
hostnames:

0 commit comments

Comments
 (0)