diff --git a/test/e2e/mnist_pytorch_mcad_job_test.go b/test/e2e/mnist_pytorch_mcad_job_test.go index 23ad30955..adbf11bc5 100644 --- a/test/e2e/mnist_pytorch_mcad_job_test.go +++ b/test/e2e/mnist_pytorch_mcad_job_test.go @@ -145,9 +145,6 @@ func TestMNISTPyTorchMCAD(t *testing.T) { test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutMedium). Should(WithTransform(AppWrapperState, Equal(mcadv1beta1.AppWrapperStateActive))) - // Retrieving the job logs once it has completed or timed out - defer WriteJobLogs(test, job.Namespace, job.Name) - test.T().Logf("Waiting for Job %s/%s to complete", job.Namespace, job.Name) test.Eventually(Job(test, job.Namespace, job.Name), TestTimeoutLong).Should( Or( diff --git a/test/e2e/mnist_raycluster_sdk_test.go b/test/e2e/mnist_raycluster_sdk_test.go index 1b59eac01..0089dccab 100644 --- a/test/e2e/mnist_raycluster_sdk_test.go +++ b/test/e2e/mnist_raycluster_sdk_test.go @@ -192,9 +192,6 @@ func TestMNISTRayClusterSDK(t *testing.T) { test.Expect(err).NotTo(HaveOccurred()) test.T().Logf("Created Job %s/%s successfully", job.Namespace, job.Name) - // Retrieving the job logs once it has completed or timed out - defer WriteJobLogs(test, job.Namespace, job.Name) - test.T().Logf("Waiting for Job %s/%s to complete", job.Namespace, job.Name) test.Eventually(Job(test, job.Namespace, job.Name), TestTimeoutLong).Should( Or( diff --git a/test/e2e/setup.sh b/test/e2e/setup.sh index 95a505d8b..d5c99cbf8 100755 --- a/test/e2e/setup.sh +++ b/test/e2e/setup.sh @@ -18,11 +18,9 @@ set -euo pipefail : "${KUBERAY_VERSION}" echo Deploying KubeRay "${KUBERAY_VERSION}" -kubectl apply --server-side -k "github.com/ray-project/kuberay/ray-operator/config/default?ref=${KUBERAY_VERSION}&timeout=90s" +kubectl apply --server-side -k "github.com/ray-project/kuberay/ray-operator/config/default?ref=${KUBERAY_VERSION}&timeout=180s" -kubectl create ns codeflare-system --dry-run=client -o yaml | kubectl apply -f - - -cat < maxSize { + maxSize = len(dataMap[key]) + } + } + maxStringSizeMap[key] = maxSize + } + + // Write headers + for _, header := range keys { + if _, err := content.WriteString(header); err != nil { + return nil, fmt.Errorf("error in writing the header: %v", err) + } + if _, err := content.WriteString(getWhitespaceStr(maxStringSizeMap[header] - len(header) + 1)); err != nil { + return nil, fmt.Errorf("error in writing headers: %v", err) + } + if _, err := content.WriteString(" | "); err != nil { + return nil, fmt.Errorf("error in writing headers : %v", err) + } + } + if _, err := content.WriteString("\n"); err != nil { + return nil, fmt.Errorf("error in writing headers '|': %v", err) + + } + + // Write events + for _, dataMap := range dataMaps { + for _, key := range keys { + if _, err := content.WriteString(dataMap[key]); err != nil { + return nil, fmt.Errorf("error in writing events: %v", err) + } + if _, err := content.WriteString(getWhitespaceStr(maxStringSizeMap[key] - len(dataMap[key]) + 1)); err != nil { + return nil, fmt.Errorf("error in writing events: %v", err) + } + if _, err := content.WriteString(" | "); err != nil { + return nil, fmt.Errorf("error in writing events: %v", err) + } + } + if _, err := content.WriteString("\n"); err != nil { + return nil, fmt.Errorf("error in writing events: %v", err) + } + } + return content.Bytes(), nil +} + +func getWhitespaceStr(size int) string { + whiteSpaceStr := "" + for i := 0; i < size; i++ { + whiteSpaceStr += " " + } + return whiteSpaceStr +} diff --git a/test/support/ray_api.go b/test/support/ray_api.go index 9004d92ed..1f04f6dda 100644 --- a/test/support/ray_api.go +++ b/test/support/ray_api.go @@ -29,7 +29,7 @@ func WriteRayJobAPILogs(t Test, rayClient RayClusterClient, jobID string) { t.T().Helper() logs, err := rayClient.GetJobLogs(jobID) t.Expect(err).NotTo(gomega.HaveOccurred()) - WriteToOutputDir(t, jobID, Log, []byte(logs)) + WriteToOutputDir(t, "ray-job-log-"+jobID, Log, []byte(logs)) } func RayJobAPIDetails(t Test, rayClient RayClusterClient, jobID string) func(g gomega.Gomega) *RayJobDetailsResponse { diff --git a/test/support/test.go b/test/support/test.go index 75556ca40..683b0f214 100644 --- a/test/support/test.go +++ b/test/support/test.go @@ -131,6 +131,8 @@ func (t *T) NewTestNamespace(options ...Option[*corev1.Namespace]) *corev1.Names t.T().Helper() namespace := createTestNamespace(t, options...) t.T().Cleanup(func() { + storeAllPodLogs(t, namespace) + storeEvents(t, namespace) deleteTestNamespace(t, namespace) }) return namespace