From df40a5fe3951484db086e8e96d3527e2fe45f3e2 Mon Sep 17 00:00:00 2001 From: Jiri Petrlik Date: Wed, 15 Nov 2023 09:12:07 +0100 Subject: [PATCH] Do not save logs when RayJob status is missing --- tests/integration/ray_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/integration/ray_test.go b/tests/integration/ray_test.go index 41a35581..996331d9 100644 --- a/tests/integration/ray_test.go +++ b/tests/integration/ray_test.go @@ -22,6 +22,7 @@ import ( "net/url" "testing" + "github.com/onsi/gomega" . "github.com/onsi/gomega" support "github.com/project-codeflare/codeflare-operator/test/support" rayv1alpha1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1alpha1" @@ -114,7 +115,13 @@ func TestRayCluster(t *testing.T) { dashboardHostname := dashboard.Status.Ingress[0].Host rayClient := support.NewRayClusterClient(url.URL{Scheme: "http", Host: dashboardHostname}) - defer support.WriteRayJobLogs(test, rayClient, rayJob.Namespace, rayJob.Name) + defer func() { + job, err := test.Client().Ray().RayV1alpha1().RayJobs(rayJob.Namespace).Get(test.Ctx(), rayJob.Name, metav1.GetOptions{}) + test.Expect(err).NotTo(gomega.HaveOccurred()) + if job.Status.JobId != "" { + support.WriteRayJobLogs(test, rayClient, rayJob.Namespace, rayJob.Name) + } + }() test.T().Logf("Waiting for RayJob %s/%s to complete", rayJob.Namespace, rayJob.Name) // Will be removed when RHODS-12857 is fixed