Skip to content

Commit a1c95a5

Browse files
authored
added support for testing cpu example in e2e tests (#485)
* added support for testing cpu example in e2e tests Signed-off-by: Nir Rozenbaum <[email protected]> * minor change in e2e test Signed-off-by: Nir Rozenbaum <[email protected]> * fixed linter error Signed-off-by: Nir Rozenbaum <[email protected]> * fixed a typo Signed-off-by: Nir Rozenbaum <[email protected]> --------- Signed-off-by: Nir Rozenbaum <[email protected]>
1 parent 28ea321 commit a1c95a5

File tree

3 files changed

+41
-22
lines changed

3 files changed

+41
-22
lines changed

Diff for: Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ IMAGE_REGISTRY ?= us-central1-docker.pkg.dev/k8s-staging-images/gateway-api-infe
3232
IMAGE_NAME := epp
3333
IMAGE_REPO ?= $(IMAGE_REGISTRY)/$(IMAGE_NAME)
3434
IMAGE_TAG ?= $(IMAGE_REPO):$(GIT_TAG)
35+
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
36+
E2E_MANIFEST_PATH ?= config/manifests/vllm/gpu-deployment.yaml
3537

3638
SYNCER_IMAGE_NAME := lora-syncer
3739
SYNCER_IMAGE_REPO ?= $(IMAGE_REGISTRY)/$(SYNCER_IMAGE_NAME)
@@ -126,8 +128,8 @@ test-integration: manifests generate fmt vet envtest ## Run tests.
126128
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./test/integration/epp/... -race -coverprofile cover.out
127129

128130
.PHONY: test-e2e
129-
test-e2e: ## Run end-to-end tests against an existing Kubernetes cluster with at least 3 available GPUs.
130-
go test ./test/e2e/epp -v -ginkgo.v
131+
test-e2e: ## Run end-to-end tests against an existing Kubernetes cluster. When using default configuration, the tests need at least 3 available GPUs.
132+
MANIFEST_PATH=$(ROOT_DIR)/$(E2E_MANIFEST_PATH) go test ./test/e2e/epp/ -v -ginkgo.v
131133

132134
.PHONY: lint
133135
lint: golangci-lint ## Run golangci-lint linter

Diff for: test/e2e/epp/e2e_suite_test.go

+36-15
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ const (
6868
inferExtName = "inference-gateway-ext-proc"
6969
// clientManifest is the manifest for the client test resources.
7070
clientManifest = "../../testdata/client.yaml"
71-
// modelServerManifest is the manifest for the model server test resources.
72-
modelServerManifest = "../../../config/manifests/vllm/gpu-deployment.yaml"
7371
// modelServerSecretManifest is the manifest for the model server secret resource.
7472
modelServerSecretManifest = "../../testdata/model-secret.yaml"
7573
// inferPoolManifest is the manifest for the inference pool CRD.
@@ -80,6 +78,8 @@ const (
8078
inferExtManifest = "../../../config/manifests/ext_proc.yaml"
8179
// envoyManifest is the manifest for the envoy proxy test resources.
8280
envoyManifest = "../../testdata/envoy.yaml"
81+
// modelServerManifestFilepathEnvVar is the env var that holds absolute path to the manifest for the model server test resource.
82+
modelServerManifestFilepathEnvVar = "MANIFEST_PATH"
8383
)
8484

8585
var (
@@ -107,6 +107,7 @@ var _ = ginkgo.BeforeSuite(func() {
107107
})
108108

109109
func setupInfra() {
110+
modelServerManifest := readModelServerManifestPath()
110111
crds := map[string]string{
111112
"inferencepools.inference.networking.x-k8s.io": inferPoolManifest,
112113
"inferencemodels.inference.networking.x-k8s.io": inferModelManifest,
@@ -145,6 +146,7 @@ func setupSuite() {
145146

146147
kubeCli, err = kubernetes.NewForConfig(cfg)
147148
gomega.Expect(err).NotTo(gomega.HaveOccurred())
149+
gomega.Expect(kubeCli).NotTo(gomega.BeNil())
148150
}
149151

150152
func cleanupResources() {
@@ -181,6 +183,14 @@ func namespaceExists(k8sClient client.Client, ns string) {
181183
}, existsTimeout, interval)
182184
}
183185

186+
// readModelServerManifestPath reads from env var the absolute filepath to model server deployment for testing.
187+
func readModelServerManifestPath() string {
188+
ginkgo.By(fmt.Sprintf("Ensuring %s environment variable is set", modelServerManifestFilepathEnvVar))
189+
modelServerManifestFilepath := os.Getenv(modelServerManifestFilepathEnvVar)
190+
gomega.Expect(modelServerManifestFilepath).NotTo(gomega.BeEmpty(), modelServerManifestFilepathEnvVar+" is not set")
191+
return modelServerManifestFilepath
192+
}
193+
184194
// createCRDs creates the Inference Extension CRDs used for testing.
185195
func createCRDs(k8sClient client.Client, crds map[string]string) {
186196
for name, path := range crds {
@@ -215,6 +225,29 @@ func createClient(k8sClient client.Client, filePath string) {
215225

216226
// createModelServer creates the model server resources used for testing from the given filePaths.
217227
func createModelServer(k8sClient client.Client, secretPath, deployPath string) {
228+
ginkgo.By("Ensuring the model server manifest points to an existing file")
229+
modelServerManifestArray := readYaml(deployPath)
230+
gomega.Expect(modelServerManifestArray).NotTo(gomega.BeEmpty())
231+
modelServerManifestYaml := modelServerManifestArray[0]
232+
if strings.Contains(modelServerManifestYaml, "hf-token") {
233+
createHfSecret(k8sClient, secretPath)
234+
}
235+
236+
ginkgo.By("Creating model server resources from manifest: " + deployPath)
237+
createObjsFromYaml(k8sClient, modelServerManifestArray)
238+
239+
// Wait for the deployment to exist.
240+
deploy := &appsv1.Deployment{}
241+
testutils.EventuallyExists(ctx, func() error {
242+
return k8sClient.Get(ctx, types.NamespacedName{Namespace: nsName, Name: modelServerName}, deploy)
243+
}, existsTimeout, interval)
244+
245+
// Wait for the deployment to be available.
246+
testutils.DeploymentAvailable(ctx, k8sClient, deploy, modelReadyTimeout, interval)
247+
}
248+
249+
// createHfSecret read HF_TOKEN from env var and creates a secret that contains the access token.
250+
func createHfSecret(k8sClient client.Client, secretPath string) {
218251
ginkgo.By("Ensuring the HF_TOKEN environment variable is set")
219252
token := os.Getenv("HF_TOKEN")
220253
gomega.Expect(token).NotTo(gomega.BeEmpty(), "HF_TOKEN is not set")
@@ -226,25 +259,13 @@ func createModelServer(k8sClient client.Client, secretPath, deployPath string) {
226259
outManifests = append(outManifests, strings.Replace(m, "$HF_TOKEN", token, 1))
227260
}
228261

229-
ginkgo.By("Creating model server secret resource from manifest: " + deployPath)
262+
ginkgo.By("Creating model server secret resource")
230263
createObjsFromYaml(k8sClient, outManifests)
231264

232265
// Wait for the secret to exist before proceeding with test.
233266
testutils.EventuallyExists(ctx, func() error {
234267
return k8sClient.Get(ctx, types.NamespacedName{Namespace: nsName, Name: "hf-token"}, &corev1.Secret{})
235268
}, existsTimeout, interval)
236-
237-
ginkgo.By("Creating model server resources from manifest: " + deployPath)
238-
applyYAMLFile(k8sClient, deployPath)
239-
240-
// Wait for the deployment to exist.
241-
deploy := &appsv1.Deployment{}
242-
testutils.EventuallyExists(ctx, func() error {
243-
return k8sClient.Get(ctx, types.NamespacedName{Namespace: nsName, Name: modelServerName}, deploy)
244-
}, existsTimeout, interval)
245-
246-
// Wait for the deployment to be available.
247-
testutils.DeploymentAvailable(ctx, k8sClient, deploy, modelReadyTimeout, interval)
248269
}
249270

250271
// createEnvoy creates the envoy proxy resources used for testing from the given filePath.

Diff for: test/e2e/epp/e2e_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ var _ = ginkgo.Describe("InferencePool", func() {
4949

5050
ginkgo.By("Ensuring the InferenceModel resource exists in the namespace")
5151
gomega.Eventually(func() error {
52-
err := cli.Get(ctx, types.NamespacedName{Namespace: infModel.Namespace, Name: infModel.Name}, infModel)
53-
if err != nil {
54-
return err
55-
}
56-
return nil
52+
return cli.Get(ctx, types.NamespacedName{Namespace: infModel.Namespace, Name: infModel.Name}, infModel)
5753
}, existsTimeout, interval).Should(gomega.Succeed())
5854

5955
ginkgo.By("Verifying connectivity through the inference extension")

0 commit comments

Comments
 (0)