Skip to content

Commit 98e361d

Browse files
committed
MAF-19232: fix(e2e): Enhance image parsing and improve error handling
- Updated the ParseImage function to return an error if the image format is invalid, ensuring better validation. - Modified the createInferencePerfJob function to handle parsing errors gracefully, improving robustness in performance tests. - Reorganized the deletion of Heimdall in quality tests for better clarity and consistency.
1 parent 906fc90 commit 98e361d

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

test/e2e/performance/performance_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ func waitForInferenceService(namespace string, name string) error {
151151
}
152152

153153
func createInferencePerfJob(namespace string, baseURL string, image string, isKind bool) (string, error) {
154-
_, imageTag := utils.ParseImage(image)
154+
_, imageTag, err := utils.ParseImage(image)
155+
if err != nil {
156+
return "", fmt.Errorf("failed to parse image: %w", err)
157+
}
155158

156159
type jobTemplateData struct {
157160
Namespace string

test/e2e/quality/quality_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ var _ = Describe("Quality Benchmark", Label("quality"), Ordered, func() {
103103
utils.DeleteInferenceService(envs.WorkloadNamespace, prefillServiceName)
104104
utils.DeleteInferenceService(envs.WorkloadNamespace, decodeServiceName)
105105

106-
By("deleting Heimdall")
107-
utils.UninstallHeimdall(envs.WorkloadNamespace)
108-
109106
if envs.SkipKind {
110107
By("deleting model PVC")
111108
utils.DeleteModelPVC(envs.WorkloadNamespace, pvcName)
@@ -114,6 +111,9 @@ var _ = Describe("Quality Benchmark", Label("quality"), Ordered, func() {
114111
utils.DeleteModelPV(pvName)
115112
}
116113

114+
By("deleting Heimdall")
115+
utils.UninstallHeimdall(envs.WorkloadNamespace)
116+
117117
By("deleting Gateway resources")
118118
utils.DeleteGatewayResource(envs.WorkloadNamespace, envs.GatewayClassName)
119119

test/utils/common.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,17 @@ func hasAllCRDs(output string, required []string) bool {
146146
}
147147

148148
// ParseImage parses a container image reference
149-
func ParseImage(image string) (repo, tag string) {
149+
func ParseImage(image string) (repo, tag string, err error) {
150150
lastColon := strings.LastIndex(image, ":")
151+
if lastColon == -1 {
152+
return image, "", fmt.Errorf("invalid image: %s", image)
153+
}
154+
if lastColon == len(image)-1 {
155+
return image[:lastColon], "", fmt.Errorf("invalid image: %s", image)
156+
}
157+
151158
repo = image[:lastColon]
152159
tag = image[lastColon+1:]
153160

154-
return repo, tag
161+
return repo, tag, nil
155162
}

0 commit comments

Comments
 (0)