diff --git a/tests/odh/mnist_ray_test.go b/tests/odh/mnist_ray_test.go index 5ec3c4b9..0d88e6e6 100644 --- a/tests/odh/mnist_ray_test.go +++ b/tests/odh/mnist_ray_test.go @@ -19,8 +19,6 @@ package odh import ( "bytes" "fmt" - "log" - "os/exec" "testing" "time" @@ -35,22 +33,22 @@ import ( ) func TestMnistRayCpu(t *testing.T) { - mnistDefaultRayImage(t, 0) + mnistRay(t, 0) } func TestMnistRayGpu(t *testing.T) { - mnistDefaultRayImage(t, 1) + mnistRay(t, 1) } func TestMnistCustomRayImageCpu(t *testing.T) { - mnistCustomRayImage(t, 0) + mnistRay(t, 0) } func TestMnistCustomRayImageGpu(t *testing.T) { - mnistCustomRayImage(t, 1) + mnistRay(t, 1) } -func mnistDefaultRayImage(t *testing.T, numGpus int) { +func mnistRay(t *testing.T, numGpus int) { test := With(t) // Create a namespace @@ -59,26 +57,6 @@ func mnistDefaultRayImage(t *testing.T, numGpus int) { // Get ray image rayImage := GetRayImage() - mnistRay(test, numGpus, namespace, rayImage) -} - -func mnistCustomRayImage(t *testing.T, numGpus int) { - test := With(t) - - // Create a namespace - namespace := test.NewTestNamespace() - - // Build and Push custom ray image - image := "ray-torch-cuda" - buildAndPushRayImage(test, namespace.Name, image) - - // Get custom ray image - rayImage := getCustomRayImage(test, namespace.Name, image) - - mnistRay(test, numGpus, namespace, rayImage) -} - -func mnistRay(test Test, numGpus int, namespace *corev1.Namespace, rayImage string) { // Create Kueue resources resourceFlavor := CreateKueueResourceFlavor(test, v1beta1.ResourceFlavorSpec{}) defer test.Client().Kueue().KueueV1beta1().ResourceFlavors().Delete(test.Ctx(), resourceFlavor.Name, metav1.DeleteOptions{}) @@ -248,25 +226,3 @@ func readMnistScriptTemplate(test Test, filePath string) []byte { return ParseTemplate(test, template, props) } - -func buildAndPushRayImage(test Test, namespace string, image string) { - cmd := exec.Command("resources/custom_image.sh", namespace, image, "-c", "echo stdout; echo 1>&2 stderr") - - stdoutStderr, err := cmd.CombinedOutput() - if err != nil { - log.Fatal("Error executing custom_image script :", err) - } - test.Expect(err).NotTo(HaveOccurred()) - - fmt.Printf("Logs of build and custom ray image . . .\n %s", stdoutStderr) -} - -func getCustomRayImage(test Test, namespace string, image string) string { - tag := "latest" - name := image + ":" + tag - - imageStreamTag := GetImageStreamTag(test, namespace, name) - imageReference := imageStreamTag.Image.DockerImageReference - - return imageReference -} diff --git a/tests/odh/resources/custom_image.sh b/tests/odh/resources/custom_image.sh deleted file mode 100755 index 1088e462..00000000 --- a/tests/odh/resources/custom_image.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -namespace=$1 -image=$2 - -echo "switch to current project . . ." -oc project $namespace - -echo "Build custom container image using podman . . ." -cd ./../../images/runtime/examples -cd $image -podman build -t $image -f Dockerfile - -echo "Expose the integrated container registry . . ." -oc patch configs.imageregistry.operator.openshift.io/cluster --patch '{"spec":{"defaultRoute":true}}' --type=merge - -echo "Wait for the route to the container registry to be admitted . . ." -oc wait -n openshift-image-registry route/default-route --for=jsonpath='{.status.ingress[0].conditions[0].status}'=True - -echo "Login to the container registry . . ." -podman login -u $(oc whoami) -p $(oc whoami -t) $(oc registry info) - -echo "Push the image to the integrated container registry . . ." -podman tag $image $(oc registry info)/$namespace/$image -podman push $(oc registry info)/$namespace/$image - -echo "Custom Ray Image is . . . " -oc get is $image -o jsonpath='{.status.tags[?(@.tag=="latest")].items[0].dockerImageReference}'