@@ -30,6 +30,7 @@ import (
30
30
corev1 "k8s.io/api/core/v1"
31
31
rbacv1 "k8s.io/api/rbac/v1"
32
32
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
33
+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
33
34
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
34
35
"k8s.io/apimachinery/pkg/runtime"
35
36
"k8s.io/apimachinery/pkg/runtime/serializer"
@@ -55,9 +56,8 @@ const (
55
56
defaultInterval = time .Millisecond * 250
56
57
// defaultCurlInterval is the default interval to run the test curl command.
57
58
defaultCurlInterval = time .Second * 5
58
- // nsName is the name of the Namespace used for tests.
59
- // TODO [danehans]: Must be "default" until https://github.com/kubernetes-sigs/gateway-api-inference-extension/issues/227 is fixed
60
- nsName = "default"
59
+ // defaultNsName is the default name of the Namespace used for tests. Can override using the E2E_NS environment variable.
60
+ defaultNsName = "inf-ext-e2e"
61
61
// modelServerName is the name of the model server test resources.
62
62
modelServerName = "vllm-llama3-8b-instruct"
63
63
// modelName is the test model name.
@@ -77,7 +77,7 @@ const (
77
77
// inferModelManifest is the manifest for the inference model CRD.
78
78
inferModelManifest = "../../../config/crd/bases/inference.networking.x-k8s.io_inferencemodels.yaml"
79
79
// inferExtManifest is the manifest for the inference extension test resources.
80
- inferExtManifest = "../../../config/manifests/ inferencepool-resources .yaml"
80
+ inferExtManifest = "../../testdata/ inferencepool-e2e .yaml"
81
81
// envoyManifest is the manifest for the envoy proxy test resources.
82
82
envoyManifest = "../../testdata/envoy.yaml"
83
83
// modelServerManifestFilepathEnvVar is the env var that holds absolute path to the manifest for the model server test resource.
91
91
kubeCli * kubernetes.Clientset
92
92
scheme = runtime .NewScheme ()
93
93
cfg = config .GetConfigOrDie ()
94
+ nsName string
94
95
)
95
96
96
97
func TestAPIs (t * testing.T ) {
@@ -101,6 +102,11 @@ func TestAPIs(t *testing.T) {
101
102
}
102
103
103
104
var _ = ginkgo .BeforeSuite (func () {
105
+ nsName = os .Getenv ("E2E_NS" )
106
+ if nsName == "" {
107
+ nsName = defaultNsName
108
+ }
109
+
104
110
ginkgo .By ("Setting up the test suite" )
105
111
setupSuite ()
106
112
@@ -109,6 +115,8 @@ var _ = ginkgo.BeforeSuite(func() {
109
115
})
110
116
111
117
func setupInfra () {
118
+ createNamespace (cli , nsName )
119
+
112
120
modelServerManifestPath := readModelServerManifestPath ()
113
121
modelServerManifestArray := getYamlsFromModelServerManifest (modelServerManifestPath )
114
122
if strings .Contains (modelServerManifestArray [0 ], "hf-token" ) {
@@ -118,6 +126,7 @@ func setupInfra() {
118
126
"inferencepools.inference.networking.x-k8s.io" : inferPoolManifest ,
119
127
"inferencemodels.inference.networking.x-k8s.io" : inferModelManifest ,
120
128
}
129
+
121
130
createCRDs (cli , crds )
122
131
createInferExt (cli , inferExtManifest )
123
132
createClient (cli , clientManifest )
@@ -182,6 +191,17 @@ var (
182
191
curlInterval = defaultCurlInterval
183
192
)
184
193
194
+ func createNamespace (k8sClient client.Client , ns string ) {
195
+ ginkgo .By ("Creating e2e namespace: " + ns )
196
+ obj := & corev1.Namespace {
197
+ ObjectMeta : v1.ObjectMeta {
198
+ Name : ns ,
199
+ },
200
+ }
201
+ err := k8sClient .Create (ctx , obj )
202
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred (), "Failed to create e2e test namespace" )
203
+ }
204
+
185
205
// namespaceExists ensures that a specified namespace exists and is ready for use.
186
206
func namespaceExists (k8sClient client.Client , ns string ) {
187
207
ginkgo .By ("Ensuring namespace exists: " + ns )
@@ -276,8 +296,15 @@ func createHfSecret(k8sClient client.Client, secretPath string) {
276
296
277
297
// createEnvoy creates the envoy proxy resources used for testing from the given filePath.
278
298
func createEnvoy (k8sClient client.Client , filePath string ) {
299
+ inManifests := readYaml (filePath )
300
+ ginkgo .By ("Replacing placeholder namespace with E2E_NS environment variable" )
301
+ outManifests := []string {}
302
+ for _ , m := range inManifests {
303
+ outManifests = append (outManifests , strings .ReplaceAll (m , "$E2E_NS" , nsName ))
304
+ }
305
+
279
306
ginkgo .By ("Creating envoy proxy resources from manifest: " + filePath )
280
- applyYAMLFile (k8sClient , filePath )
307
+ createObjsFromYaml (k8sClient , outManifests )
281
308
282
309
// Wait for the configmap to exist before proceeding with test.
283
310
cfgMap := & corev1.ConfigMap {}
@@ -302,8 +329,15 @@ func createEnvoy(k8sClient client.Client, filePath string) {
302
329
303
330
// createInferExt creates the inference extension resources used for testing from the given filePath.
304
331
func createInferExt (k8sClient client.Client , filePath string ) {
332
+ inManifests := readYaml (filePath )
333
+ ginkgo .By ("Replacing placeholder namespace with E2E_NS environment variable" )
334
+ outManifests := []string {}
335
+ for _ , m := range inManifests {
336
+ outManifests = append (outManifests , strings .ReplaceAll (m , "$E2E_NS" , nsName ))
337
+ }
338
+
305
339
ginkgo .By ("Creating inference extension resources from manifest: " + filePath )
306
- applyYAMLFile (k8sClient , filePath )
340
+ createObjsFromYaml (k8sClient , outManifests )
307
341
308
342
// Wait for the clusterrole to exist.
309
343
testutils .EventuallyExists (ctx , func () error {
0 commit comments