@@ -14,62 +14,56 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- package basic
17
+ package tests
18
18
19
19
import (
20
20
"net/http"
21
21
"testing"
22
22
23
23
"github.com/stretchr/testify/require"
24
24
"k8s.io/apimachinery/pkg/types"
25
+ testfilter "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/test/filter"
25
26
"sigs.k8s.io/gateway-api/conformance/utils/suite"
26
27
"sigs.k8s.io/gateway-api/pkg/features"
27
28
28
- "sigs.k8s.io/gateway-api-inference-extension/conformance/tests "
29
+ "sigs.k8s.io/gateway-api-inference-extension/conformance/resources "
29
30
k8sutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/kubernetes"
30
31
trafficutils "sigs.k8s.io/gateway-api-inference-extension/conformance/utils/traffic"
31
32
)
32
33
33
34
func init () {
34
- tests . ConformanceTests = append (tests . ConformanceTests , EppUnAvailableFailOpen )
35
+ ConformanceTests = append (ConformanceTests , EppUnAvailableFailOpen )
35
36
}
36
37
37
38
var EppUnAvailableFailOpen = suite.ConformanceTest {
38
39
ShortName : "EppUnAvailableFailOpen" ,
39
40
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" },
41
42
Features : []features.FeatureName {
42
43
features .FeatureName ("SupportInferencePool" ),
43
44
features .SupportGateway ,
44
45
},
45
46
Test : func (t * testing.T , s * suite.ConformanceTestSuite ) {
46
47
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 = `{
55
52
"model": "conformance-fake-model",
56
53
"prompt": "Write as if you were a critic: San Francisco"
57
54
}`
58
55
)
59
56
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
66
59
k8sutils .HTTPRouteMustBeAcceptedAndResolved (t , s .Client , s .TimeoutConfig , httpRouteNN , gatewayNN )
67
- k8sutils .InferencePoolMustBeAcceptedByParent (t , s .Client , poolNN )
60
+ k8sutils .InferencePoolMustBeAcceptedByParent (t , s .Client , resources . SecondaryInferencePoolNN )
68
61
gwAddr := k8sutils .GetGatewayEndpoint (t , s .Client , s .TimeoutConfig , gatewayNN )
69
62
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 )
71
65
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 ))
73
67
74
68
targetPodIP := pods [0 ].Status .PodIP
75
69
t .Run ("Phase 1: Verify baseline connectivity with EPP available" , func (t * testing.T ) {
@@ -82,18 +76,18 @@ var EppUnAvailableFailOpen = suite.ConformanceTest{
82
76
trafficutils.Request {
83
77
Host : hostname ,
84
78
Path : path ,
85
- Headers : map [string ]string {eppSelectionHeaderName : targetPodIP },
79
+ Headers : map [string ]string {testfilter . HeaderTestEppEndPointSelectionKey : targetPodIP },
86
80
Method : http .MethodPost ,
87
81
Body : requestBody ,
88
82
Backend : pods [0 ].Name , // Make sure the request is from the targetPod when the EPP is alive.
89
- Namespace : appBackendNamespace ,
83
+ Namespace : resources . AppBackendNamespace ,
90
84
},
91
85
)
92
86
})
93
87
94
88
t .Run ("Phase 2: Verify fail-open behavior after EPP becomes unavailable" , func (t * testing.T ) {
95
89
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 )
97
91
require .NoError (t , deleteErr , "Failed to delete the EPP deployment" )
98
92
99
93
t .Log ("Sending request again, expecting success to verify fail-open..." )
@@ -105,11 +99,11 @@ var EppUnAvailableFailOpen = suite.ConformanceTest{
105
99
trafficutils.Request {
106
100
Host : hostname ,
107
101
Path : path ,
108
- Headers : map [string ]string {eppSelectionHeaderName : targetPodIP },
102
+ Headers : map [string ]string {testfilter . HeaderTestEppEndPointSelectionKey : targetPodIP },
109
103
Method : http .MethodPost ,
110
104
Body : requestBody ,
111
105
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 ,
113
107
},
114
108
)
115
109
})
0 commit comments