@@ -14,62 +14,56 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- package basic
17+ package tests
1818
1919import (
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
3334func init () {
34- tests . ConformanceTests = append (tests . ConformanceTests , EppUnAvailableFailOpen )
35+ ConformanceTests = append (ConformanceTests , EppUnAvailableFailOpen )
3536}
3637
3738var 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 })
0 commit comments