Skip to content

Commit 4c02282

Browse files
authored
Merge pull request #218 from sutaakar/test-fix
e2e tests: List Notebooks using Gomega function
2 parents ab43009 + f5b80db commit 4c02282

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

tests/common/notebook.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,16 @@ func DeleteNotebook(test Test, namespace *corev1.Namespace) {
189189
test.Expect(err).NotTo(gomega.HaveOccurred())
190190
}
191191

192-
func ListNotebooks(test Test, namespace *corev1.Namespace) []*unstructured.Unstructured {
193-
ntbs, err := test.Client().Dynamic().Resource(notebookResource).Namespace(namespace.Name).List(test.Ctx(), metav1.ListOptions{})
194-
test.Expect(err).NotTo(gomega.HaveOccurred())
192+
func Notebooks(test Test, namespace *corev1.Namespace) func(g gomega.Gomega) []*unstructured.Unstructured {
193+
return func(g gomega.Gomega) []*unstructured.Unstructured {
194+
ntbs, err := test.Client().Dynamic().Resource(notebookResource).Namespace(namespace.Name).List(test.Ctx(), metav1.ListOptions{})
195+
g.Expect(err).NotTo(gomega.HaveOccurred())
196+
197+
ntbsp := []*unstructured.Unstructured{}
198+
for _, v := range ntbs.Items {
199+
ntbsp = append(ntbsp, &v)
200+
}
195201

196-
ntbsp := []*unstructured.Unstructured{}
197-
for _, v := range ntbs.Items {
198-
ntbsp = append(ntbsp, &v)
202+
return ntbsp
199203
}
200-
201-
return ntbsp
202204
}

tests/kfto/kfto_mnist_sdk_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func runMnistSDK(t *testing.T, trainingImage string) {
120120
// Gracefully cleanup Notebook
121121
defer func() {
122122
DeleteNotebook(test, namespace)
123-
test.Eventually(ListNotebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
123+
test.Eventually(Notebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
124124
}()
125125

126126
// Make sure pytorch job is created

tests/kfto/kfto_sft_llm_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func kftoSftLlm(t *testing.T, image string, gpu Accelerator, modelName string) {
178178
// Gracefully cleanup Notebook
179179
defer func() {
180180
DeleteNotebook(test, namespace)
181-
test.Eventually(ListNotebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
181+
test.Eventually(Notebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
182182
}()
183183

184184
test.T().Logf("Wait for pytorch job to start running ...")

tests/odh/mnist_ray_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func mnistRay(t *testing.T, numGpus int, gpuResourceName string, rayImage string
136136
// Gracefully cleanup Notebook
137137
defer func() {
138138
DeleteNotebook(test, namespace)
139-
test.Eventually(ListNotebooks(test, namespace), TestTimeoutMedium).Should(HaveLen(0))
139+
test.Eventually(Notebooks(test, namespace), TestTimeoutMedium).Should(HaveLen(0))
140140
}()
141141

142142
// Make sure the RayCluster is created and running

tests/odh/mnist_raytune_hpo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func mnistRayTuneHpo(t *testing.T, numGpus int) {
119119
// Gracefully cleanup Notebook
120120
defer func() {
121121
DeleteNotebook(test, namespace)
122-
test.Eventually(ListNotebooks(test, namespace), TestTimeoutMedium).Should(HaveLen(0))
122+
test.Eventually(Notebooks(test, namespace), TestTimeoutMedium).Should(HaveLen(0))
123123
}()
124124

125125
// Make sure the RayCluster is created and running

tests/odh/ray_finetune_llm_deepspeed_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func rayFinetuneLlmDeepspeed(t *testing.T, numGpus int, modelName string, modelC
118118
// Gracefully cleanup Notebook
119119
defer func() {
120120
DeleteNotebook(test, namespace)
121-
test.Eventually(ListNotebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
121+
test.Eventually(Notebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
122122
}()
123123

124124
// Make sure the RayCluster is created and running

tests/odh/raytune_oai_mr_grpc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func raytuneHpo(t *testing.T, numGpus int) {
128128
// Gracefully cleanup Notebook
129129
defer func() {
130130
DeleteNotebook(test, namespace)
131-
test.Eventually(ListNotebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
131+
test.Eventually(Notebooks(test, namespace), TestTimeoutGpuProvisioning).Should(HaveLen(0))
132132
}()
133133

134134
// Make sure the RayCluster is created and running

0 commit comments

Comments
 (0)