Skip to content

Commit 922dd7a

Browse files
astefanuttiopenshift-merge-robot
authored andcommitted
test: Print RayJob logs
1 parent fb4b7b4 commit 922dd7a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

test/e2e/mcad_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,14 @@ func TestJobSubmissionInRayCluster(t *testing.T) {
269269
ShutdownAfterJobFinishes: false,
270270
},
271271
}
272-
_, err = test.Client().Ray().RayV1alpha1().RayJobs(namespace.Name).Create(test.Ctx(), rayJob, metav1.CreateOptions{})
272+
rayJob, err = test.Client().Ray().RayV1alpha1().RayJobs(namespace.Name).Create(test.Ctx(), rayJob, metav1.CreateOptions{})
273273
test.Expect(err).NotTo(HaveOccurred())
274274

275275
test.Eventually(RayJob(test, namespace, rayJob.Name), TestTimeoutLong).
276276
Should(WithTransform(RayJobStatus, Equal(rayv1alpha1.JobStatusSucceeded)))
277+
278+
rayJob, err = test.Client().Ray().RayV1alpha1().RayJobs(namespace.Name).Get(test.Ctx(), rayJob.Name, metav1.GetOptions{})
279+
test.Expect(err).NotTo(HaveOccurred())
280+
281+
test.T().Log(GetRayJobLogs(test, rayJob))
277282
}

test/support/ray.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package support
22

33
import (
4+
"encoding/json"
5+
46
"github.com/onsi/gomega"
57

68
corev1 "k8s.io/api/core/v1"
@@ -22,3 +24,18 @@ func RayJob(t Test, namespace *corev1.Namespace, name string) func(g gomega.Gome
2224
func RayJobStatus(job *rayv1alpha1.RayJob) rayv1alpha1.JobStatus {
2325
return job.Status.JobStatus
2426
}
27+
28+
func GetRayJobLogs(t Test, job *rayv1alpha1.RayJob) string {
29+
t.T().Helper()
30+
response := t.Client().Core().CoreV1().RESTClient().
31+
Get().
32+
AbsPath("/api/v1/namespaces", job.Namespace, "services", "http:"+job.Status.RayClusterName+"-head-svc:dashboard", "proxy", "api", "jobs", job.Status.JobId, "logs").Do(t.Ctx())
33+
t.Expect(response.Error()).NotTo(gomega.HaveOccurred())
34+
35+
body := map[string]string{}
36+
bytes, _ := response.Raw()
37+
t.Expect(json.Unmarshal(bytes, &body)).To(gomega.Succeed())
38+
t.Expect(body).To(gomega.HaveKey("logs"))
39+
40+
return body["logs"]
41+
}

0 commit comments

Comments
 (0)