Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions test/e2e/epp/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
defaultReadyTimeout = 3 * time.Minute
// defaultModelReadyTimeout is the default timeout for the model server deployment to report a ready state.
defaultModelReadyTimeout = 10 * time.Minute
// defaultCurlTimeout is the default timeout for the curl command to get a response.
defaultCurlTimeout = 30 * time.Second
// defaultInterval is the default interval to check if a resource exists or ready conditions.
defaultInterval = time.Millisecond * 250
// defaultCurlInterval is the default interval to run the test curl command.
Expand Down Expand Up @@ -107,7 +109,11 @@ var _ = ginkgo.BeforeSuite(func() {
})

func setupInfra() {
modelServerManifest := readModelServerManifestPath()
modelServerManifestPath := readModelServerManifestPath()
modelServerManifestArray := getYamlsFromModelServerManifest(modelServerManifestPath)
if strings.Contains(modelServerManifestArray[0], "hf-token") {
createHfSecret(cli, modelServerSecretManifest)
}
crds := map[string]string{
"inferencepools.inference.networking.x-k8s.io": inferPoolManifest,
"inferencemodels.inference.networking.x-k8s.io": inferModelManifest,
Expand All @@ -117,7 +123,7 @@ func setupInfra() {
createClient(cli, clientManifest)
createEnvoy(cli, envoyManifest)
// Run this step last, as it requires additional time for the model server to become ready.
createModelServer(cli, modelServerSecretManifest, modelServerManifest)
createModelServer(cli, modelServerManifestArray, modelServerManifestPath)
}

var _ = ginkgo.AfterSuite(func() {
Expand All @@ -137,7 +143,7 @@ func setupSuite() {
err = apiextv1.AddToScheme(scheme)
gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())

err = infextv1a2.AddToScheme(scheme)
err = infextv1a2.Install(scheme)
gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())

cli, err = client.New(cfg, client.Options{Scheme: scheme})
Expand Down Expand Up @@ -171,6 +177,7 @@ var (
existsTimeout = getTimeout("EXISTS_TIMEOUT", defaultExistsTimeout)
readyTimeout = getTimeout("READY_TIMEOUT", defaultReadyTimeout)
modelReadyTimeout = getTimeout("MODEL_READY_TIMEOUT", defaultModelReadyTimeout)
curlTimeout = getTimeout("CURL_TIMEOUT", defaultCurlTimeout)
interval = defaultInterval
curlInterval = defaultCurlInterval
)
Expand All @@ -191,6 +198,13 @@ func readModelServerManifestPath() string {
return modelServerManifestFilepath
}

func getYamlsFromModelServerManifest(modelServerManifestPath string) []string {
ginkgo.By("Ensuring the model server manifest points to an existing file")
modelServerManifestArray := readYaml(modelServerManifestPath)
gomega.Expect(modelServerManifestArray).NotTo(gomega.BeEmpty())
return modelServerManifestArray
}

// createCRDs creates the Inference Extension CRDs used for testing.
func createCRDs(k8sClient client.Client, crds map[string]string) {
for name, path := range crds {
Expand Down Expand Up @@ -224,15 +238,7 @@ func createClient(k8sClient client.Client, filePath string) {
}

// createModelServer creates the model server resources used for testing from the given filePaths.
func createModelServer(k8sClient client.Client, secretPath, deployPath string) {
ginkgo.By("Ensuring the model server manifest points to an existing file")
modelServerManifestArray := readYaml(deployPath)
gomega.Expect(modelServerManifestArray).NotTo(gomega.BeEmpty())
modelServerManifestYaml := modelServerManifestArray[0]
if strings.Contains(modelServerManifestYaml, "hf-token") {
createHfSecret(k8sClient, secretPath)
}

func createModelServer(k8sClient client.Client, modelServerManifestArray []string, deployPath string) {
ginkgo.By("Creating model server resources from manifest: " + deployPath)
createObjsFromYaml(k8sClient, modelServerManifestArray)

Expand Down
8 changes: 6 additions & 2 deletions test/e2e/epp/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package epp

import (
"fmt"
"strconv"
"strings"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -53,7 +55,7 @@ var _ = ginkgo.Describe("InferencePool", func() {
}, existsTimeout, interval).Should(gomega.Succeed())

ginkgo.By("Verifying connectivity through the inference extension")
curlCmd := getCurlCommand(envoyName, nsName, envoyPort, modelName)
curlCmd := getCurlCommand(envoyName, nsName, envoyPort, modelName, curlTimeout)

// Ensure the expected responses include the inferencemodel target model names.
var expected []string
Expand Down Expand Up @@ -112,10 +114,12 @@ func newInferenceModel(ns string) *v1alpha2.InferenceModel {

// getCurlCommand returns the command, as a slice of strings, for curl'ing
// the test model server at the given name, namespace, port, and model name.
func getCurlCommand(name, ns, port, model string) []string {
func getCurlCommand(name, ns, port, model string, timeout time.Duration) []string {
return []string{
"curl",
"-i",
"--max-time",
strconv.Itoa((int)(timeout.Seconds())),
fmt.Sprintf("%s.%s.svc:%s/v1/completions", name, ns, port),
"-H",
"Content-Type: application/json",
Expand Down