Skip to content

Commit c98a5e6

Browse files
committed
fix: e2e tests not passing
1 parent f3660db commit c98a5e6

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

test/e2e/mnist_pytorch_mcad_job_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,23 @@ func TestMNISTPyTorchMCAD(t *testing.T) {
7777
Spec: corev1.PodSpec{
7878
Containers: []corev1.Container{
7979
{
80-
Name: "job",
81-
Image: GetPyTorchImage(),
80+
Name: "job",
81+
Image: GetPyTorchImage(),
82+
Env: []corev1.EnvVar{
83+
corev1.EnvVar{Name: "PYTHONUSERBASE", Value: "/test2"},
84+
},
8285
Command: []string{"/bin/sh", "-c", "pip install -r /test/requirements.txt && torchrun /test/mnist.py"},
8386
VolumeMounts: []corev1.VolumeMount{
8487
{
8588
Name: "test",
8689
MountPath: "/test",
8790
},
91+
{
92+
Name: "test2",
93+
MountPath: "/test2",
94+
},
8895
},
96+
WorkingDir: "/test2",
8997
},
9098
},
9199
Volumes: []corev1.Volume{
@@ -99,6 +107,12 @@ func TestMNISTPyTorchMCAD(t *testing.T) {
99107
},
100108
},
101109
},
110+
{
111+
Name: "test2",
112+
VolumeSource: corev1.VolumeSource{
113+
EmptyDir: &corev1.EmptyDirVolumeSource{},
114+
},
115+
},
102116
},
103117
RestartPolicy: corev1.RestartPolicyNever,
104118
},

test/e2e/mnist_raycluster_sdk_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,22 @@ func TestMNISTRayClusterSDK(t *testing.T) {
160160
Name: "test",
161161
// FIXME: switch to base Python image once the dependency on OpenShift CLI is removed
162162
// See https://github.com/project-codeflare/codeflare-sdk/pull/146
163-
Image: "quay.io/opendatahub/notebooks:jupyter-minimal-ubi8-python-3.8-4c8f26e",
163+
Image: "quay.io/opendatahub/notebooks:jupyter-minimal-ubi8-python-3.8-4c8f26e",
164+
Env: []corev1.EnvVar{
165+
corev1.EnvVar{Name: "PYTHONUSERBASE", Value: "/test2"},
166+
},
164167
Command: []string{"/bin/sh", "-c", "pip install codeflare-sdk==" + GetCodeFlareSDKVersion() + " && cp /test/* . && python mnist_raycluster_sdk.py" + " " + namespace.Name},
165168
VolumeMounts: []corev1.VolumeMount{
166169
{
167170
Name: "test",
168171
MountPath: "/test",
169172
},
173+
{
174+
Name: "test2",
175+
MountPath: "/test2",
176+
},
170177
},
178+
WorkingDir: "/test2",
171179
},
172180
},
173181
Volumes: []corev1.Volume{
@@ -181,6 +189,12 @@ func TestMNISTRayClusterSDK(t *testing.T) {
181189
},
182190
},
183191
},
192+
{
193+
Name: "test2",
194+
VolumeSource: corev1.VolumeSource{
195+
EmptyDir: &corev1.EmptyDirVolumeSource{},
196+
},
197+
},
184198
},
185199
RestartPolicy: corev1.RestartPolicyNever,
186200
ServiceAccountName: serviceAccount.Name,

test/support/utils.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ const (
3636

3737
func WriteToOutputDir(t Test, fileName string, fileType OutputType, data []byte) {
3838
t.T().Helper()
39-
t.Expect(os.WriteFile(path.Join(t.OutputDir(), fileName+"."+string(fileType)), data, fs.ModePerm)).
40-
To(gomega.Succeed())
39+
40+
// Get output directory and create the directory if it doesn't exist
41+
outputDir := t.OutputDir()
42+
err := os.MkdirAll(outputDir, os.ModePerm)
43+
if err != nil {
44+
t.T().Logf("Error creating directory %s: %v", outputDir, err)
45+
t.Expect(err).NotTo(gomega.HaveOccurred())
46+
return
47+
}
48+
49+
// Construct file path and write to it
50+
fullFilePath := path.Join(outputDir, fileName+"."+string(fileType))
51+
t.T().Logf("Writing to file: %s", fullFilePath)
52+
err = os.WriteFile(fullFilePath, data, fs.ModePerm)
53+
if err != nil {
54+
t.T().Logf("Error writing to file %s: %v", fullFilePath, err)
55+
t.Expect(err).NotTo(gomega.HaveOccurred())
56+
} else {
57+
t.T().Logf("Successfully wrote to file: %s", fullFilePath)
58+
}
4159
}

0 commit comments

Comments
 (0)