Skip to content

Commit 2c0a637

Browse files
authored
fix some issues in e2e tests (#621)
* added timeout to curl command which may otherwise hang Signed-off-by: Nir Rozenbaum <[email protected]> * check HF_TOKEN set at the beginning of the test Signed-off-by: Nir Rozenbaum <[email protected]> --------- Signed-off-by: Nir Rozenbaum <[email protected]>
1 parent 6d7655b commit 2c0a637

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

test/e2e/epp/e2e_suite_test.go

+18-12
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const (
4949
defaultReadyTimeout = 3 * time.Minute
5050
// defaultModelReadyTimeout is the default timeout for the model server deployment to report a ready state.
5151
defaultModelReadyTimeout = 10 * time.Minute
52+
// defaultCurlTimeout is the default timeout for the curl command to get a response.
53+
defaultCurlTimeout = 30 * time.Second
5254
// defaultInterval is the default interval to check if a resource exists or ready conditions.
5355
defaultInterval = time.Millisecond * 250
5456
// defaultCurlInterval is the default interval to run the test curl command.
@@ -107,7 +109,11 @@ var _ = ginkgo.BeforeSuite(func() {
107109
})
108110

109111
func setupInfra() {
110-
modelServerManifest := readModelServerManifestPath()
112+
modelServerManifestPath := readModelServerManifestPath()
113+
modelServerManifestArray := getYamlsFromModelServerManifest(modelServerManifestPath)
114+
if strings.Contains(modelServerManifestArray[0], "hf-token") {
115+
createHfSecret(cli, modelServerSecretManifest)
116+
}
111117
crds := map[string]string{
112118
"inferencepools.inference.networking.x-k8s.io": inferPoolManifest,
113119
"inferencemodels.inference.networking.x-k8s.io": inferModelManifest,
@@ -117,7 +123,7 @@ func setupInfra() {
117123
createClient(cli, clientManifest)
118124
createEnvoy(cli, envoyManifest)
119125
// Run this step last, as it requires additional time for the model server to become ready.
120-
createModelServer(cli, modelServerSecretManifest, modelServerManifest)
126+
createModelServer(cli, modelServerManifestArray, modelServerManifestPath)
121127
}
122128

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

140-
err = infextv1a2.AddToScheme(scheme)
146+
err = infextv1a2.Install(scheme)
141147
gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())
142148

143149
cli, err = client.New(cfg, client.Options{Scheme: scheme})
@@ -171,6 +177,7 @@ var (
171177
existsTimeout = getTimeout("EXISTS_TIMEOUT", defaultExistsTimeout)
172178
readyTimeout = getTimeout("READY_TIMEOUT", defaultReadyTimeout)
173179
modelReadyTimeout = getTimeout("MODEL_READY_TIMEOUT", defaultModelReadyTimeout)
180+
curlTimeout = getTimeout("CURL_TIMEOUT", defaultCurlTimeout)
174181
interval = defaultInterval
175182
curlInterval = defaultCurlInterval
176183
)
@@ -191,6 +198,13 @@ func readModelServerManifestPath() string {
191198
return modelServerManifestFilepath
192199
}
193200

201+
func getYamlsFromModelServerManifest(modelServerManifestPath string) []string {
202+
ginkgo.By("Ensuring the model server manifest points to an existing file")
203+
modelServerManifestArray := readYaml(modelServerManifestPath)
204+
gomega.Expect(modelServerManifestArray).NotTo(gomega.BeEmpty())
205+
return modelServerManifestArray
206+
}
207+
194208
// createCRDs creates the Inference Extension CRDs used for testing.
195209
func createCRDs(k8sClient client.Client, crds map[string]string) {
196210
for name, path := range crds {
@@ -224,15 +238,7 @@ func createClient(k8sClient client.Client, filePath string) {
224238
}
225239

226240
// createModelServer creates the model server resources used for testing from the given filePaths.
227-
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-
241+
func createModelServer(k8sClient client.Client, modelServerManifestArray []string, deployPath string) {
236242
ginkgo.By("Creating model server resources from manifest: " + deployPath)
237243
createObjsFromYaml(k8sClient, modelServerManifestArray)
238244

test/e2e/epp/e2e_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ package epp
1818

1919
import (
2020
"fmt"
21+
"strconv"
2122
"strings"
23+
"time"
2224

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

5557
ginkgo.By("Verifying connectivity through the inference extension")
56-
curlCmd := getCurlCommand(envoyName, nsName, envoyPort, modelName)
58+
curlCmd := getCurlCommand(envoyName, nsName, envoyPort, modelName, curlTimeout)
5759

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

113115
// getCurlCommand returns the command, as a slice of strings, for curl'ing
114116
// the test model server at the given name, namespace, port, and model name.
115-
func getCurlCommand(name, ns, port, model string) []string {
117+
func getCurlCommand(name, ns, port, model string, timeout time.Duration) []string {
116118
return []string{
117119
"curl",
118120
"-i",
121+
"--max-time",
122+
strconv.Itoa((int)(timeout.Seconds())),
119123
fmt.Sprintf("%s.%s.svc:%s/v1/completions", name, ns, port),
120124
"-H",
121125
"Content-Type: application/json",

0 commit comments

Comments
 (0)