@@ -20,6 +20,7 @@ import (
20
20
"bytes"
21
21
"fmt"
22
22
"testing"
23
+ "time"
23
24
24
25
. "github.com/onsi/gomega"
25
26
. "github.com/project-codeflare/codeflare-common/support"
@@ -77,11 +78,11 @@ func mnistRay(t *testing.T, numGpus int) {
77
78
}
78
79
clusterQueue := CreateKueueClusterQueue (test , cqSpec )
79
80
defer test .Client ().Kueue ().KueueV1beta1 ().ClusterQueues ().Delete (test .Ctx (), clusterQueue .Name , metav1.DeleteOptions {})
80
- localQueue := CreateKueueLocalQueue (test , namespace .Name , clusterQueue .Name )
81
+ CreateKueueLocalQueue (test , namespace .Name , clusterQueue .Name , AsDefaultQueue )
81
82
82
83
// Test configuration
83
84
jupyterNotebookConfigMapFileName := "mnist_ray_mini.ipynb"
84
- mnist := readMnistPy (test )
85
+ mnist := readMnistPy (test , "resources/mnist.py" )
85
86
if numGpus > 0 {
86
87
mnist = bytes .Replace (mnist , []byte ("accelerator=\" has to be specified\" " ), []byte ("accelerator=\" gpu\" " ), 1 )
87
88
} else {
@@ -91,7 +92,7 @@ func mnistRay(t *testing.T, numGpus int) {
91
92
// MNIST Ray Notebook
92
93
jupyterNotebookConfigMapFileName : ReadFile (test , "resources/mnist_ray_mini.ipynb" ),
93
94
"mnist.py" : mnist ,
94
- "requirements.txt" : readRequirementsTxt (test ),
95
+ "requirements.txt" : ReadFile (test , "resources/requirements.txt" ),
95
96
})
96
97
97
98
// Define the regular(non-admin) user
@@ -102,7 +103,7 @@ func mnistRay(t *testing.T, numGpus int) {
102
103
CreateUserRoleBindingWithClusterRole (test , userName , namespace .Name , "admin" )
103
104
104
105
// Create Notebook CR
105
- createNotebook (test , namespace , userToken , localQueue . Name , config .Name , jupyterNotebookConfigMapFileName , numGpus )
106
+ createNotebook (test , namespace , userToken , config .Name , jupyterNotebookConfigMapFileName , numGpus )
106
107
107
108
// Gracefully cleanup Notebook
108
109
defer func () {
@@ -111,7 +112,7 @@ func mnistRay(t *testing.T, numGpus int) {
111
112
}()
112
113
113
114
// Make sure the RayCluster is created and running
114
- test .Eventually (rayClusters (test , namespace ), TestTimeoutLong ).
115
+ test .Eventually (RayClusters (test , namespace . Name ), TestTimeoutLong ).
115
116
Should (
116
117
And (
117
118
HaveLen (1 ),
@@ -128,32 +129,20 @@ func mnistRay(t *testing.T, numGpus int) {
128
129
),
129
130
)
130
131
131
- // Make sure the RayCluster finishes and is deleted
132
- test .Eventually (rayClusters (test , namespace ), TestTimeoutLong ).
133
- Should (HaveLen (0 ))
134
- }
135
-
136
- func readRequirementsTxt (test Test ) []byte {
137
- // Read the requirements.txt from resources and perform replacements for custom values using go template
138
- props := struct {
139
- PipIndexUrl string
140
- PipTrustedHost string
141
- }{
142
- PipIndexUrl : "--index " + string (GetPipIndexURL ()),
143
- }
132
+ time .Sleep (30 * time .Second )
144
133
145
- // Provide trusted host only if defined
146
- if len (GetPipTrustedHost ()) > 0 {
147
- props .PipTrustedHost = "--trusted-host " + GetPipTrustedHost ()
148
- }
134
+ rayCluster , err := test .Client ().Ray ().RayV1 ().RayClusters (namespace .Name ).Get (test .Ctx (), "mnisttest" , metav1.GetOptions {})
135
+ test .Expect (err ).ToNot (HaveOccurred ())
149
136
150
- template , err := files . ReadFile ( "resources/requirements.txt" )
151
- test .Expect (err ). NotTo ( HaveOccurred ( ))
137
+ jobStatus := ReadJobLogs ( test , namespace , rayCluster )
138
+ test .Expect (jobStatus ). To ( Equal ( "SUCCEEDED" ))
152
139
153
- return ParseTemplate (test , template , props )
140
+ // Make sure the RayCluster finishes and is deleted
141
+ test .Eventually (RayClusters (test , namespace .Name ), TestTimeoutLong ).
142
+ Should (HaveLen (0 ))
154
143
}
155
144
156
- func readMnistPy (test Test ) []byte {
145
+ func readMnistPy (test Test , filePath string ) []byte {
157
146
// Read the mnist.py from resources and perform replacements for custom values using go template
158
147
storage_bucket_endpoint , storage_bucket_endpoint_exists := GetStorageBucketDefaultEndpoint ()
159
148
storage_bucket_access_key_id , storage_bucket_access_key_id_exists := GetStorageBucketAccessKeyId ()
@@ -184,7 +173,7 @@ func readMnistPy(test Test) []byte {
184
173
StorageBucketMnistDir : storage_bucket_mnist_dir ,
185
174
StorageBucketMnistDirExists : storage_bucket_mnist_dir_exists ,
186
175
}
187
- template , err := files .ReadFile ("resources/mnist.py" )
176
+ template , err := files .ReadFile (filePath )
188
177
test .Expect (err ).NotTo (HaveOccurred ())
189
178
190
179
return ParseTemplate (test , template , props )
0 commit comments