Skip to content

Commit 4b0d6af

Browse files
committed
Adjust e2e tests to verify deletion of resources
1 parent 26a1276 commit 4b0d6af

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

test/e2e/mnist_pytorch_appwrapper_test.go

+18-5
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func runMnistPyTorchAppWrapper(t *testing.T, accelerator string) {
145145
Kind: "AppWrapper",
146146
},
147147
ObjectMeta: metav1.ObjectMeta{
148-
GenerateName: "mnist",
148+
GenerateName: "mnist-",
149149
Namespace: namespace.Name,
150150
Labels: map[string]string{"kueue.x-k8s.io/queue-name": localQueue.Name},
151151
},
@@ -162,20 +162,33 @@ func runMnistPyTorchAppWrapper(t *testing.T, accelerator string) {
162162
awMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(aw)
163163
test.Expect(err).NotTo(HaveOccurred())
164164
unstruct := unstructured.Unstructured{Object: awMap}
165-
_, err = test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Create(test.Ctx(), &unstruct, metav1.CreateOptions{})
165+
unstructp, err := test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Create(test.Ctx(), &unstruct, metav1.CreateOptions{})
166+
test.Expect(err).NotTo(HaveOccurred())
167+
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructp.Object, aw)
166168
test.Expect(err).NotTo(HaveOccurred())
167-
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.GenerateName)
169+
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.Name)
168170

169-
test.T().Logf("Waiting for AppWrapper %s/%s to be running", aw.Namespace, aw.GenerateName)
171+
test.T().Logf("Waiting for AppWrapper %s/%s to be running", aw.Namespace, aw.Name)
170172
test.Eventually(AppWrappers(test, namespace), TestTimeoutMedium).
171173
Should(ContainElement(WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperRunning))))
172174

173-
test.T().Logf("Waiting for AppWrapper %s/%s to complete", job.Namespace, job.Name)
175+
test.T().Logf("Waiting for AppWrapper %s/%s to complete", aw.Namespace, aw.Name)
174176
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).Should(
175177
ContainElement(
176178
Or(
177179
WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperSucceeded)),
178180
WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperFailed)),
179181
),
180182
))
183+
184+
// Assert the AppWrapper has completed successfully
185+
test.Expect(AppWrappers(test, namespace)(test)).
186+
To(ContainElement(WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperSucceeded))))
187+
188+
test.T().Logf("Deleting AppWrapper %s/%s", aw.Namespace, aw.Name)
189+
err = test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Delete(test.Ctx(), aw.Name, metav1.DeleteOptions{})
190+
test.Expect(err).NotTo(HaveOccurred())
191+
192+
test.T().Logf("Waiting for AppWrapper %s/%s to be deleted", aw.Namespace, aw.Name)
193+
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).Should(BeEmpty())
181194
}

test/e2e/mnist_rayjob_raycluster_test.go

+23-3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ func runMnistRayJobRayCluster(t *testing.T, accelerator string, numberOfGpus int
9595
// Assert the Ray job has completed successfully
9696
test.Expect(GetRayJob(test, rayJob.Namespace, rayJob.Name)).
9797
To(WithTransform(RayJobStatus, Equal(rayv1.JobStatusSucceeded)))
98+
99+
test.T().Logf("Deleting RayCluster %s/%s", rayCluster.Namespace, rayCluster.Name)
100+
err = test.Client().Ray().RayV1().RayClusters(namespace.Name).Delete(test.Ctx(), rayCluster.Name, metav1.DeleteOptions{})
101+
test.Expect(err).NotTo(HaveOccurred())
102+
103+
test.T().Logf("Waiting for RayCluster %s/%s to be deleted", rayCluster.Namespace, rayCluster.Name)
104+
test.Eventually(RayClusters(test, namespace.Name), TestTimeoutLong).Should(BeEmpty())
98105
}
99106

100107
func TestMnistRayJobRayClusterAppWrapperCpu(t *testing.T) {
@@ -143,11 +150,13 @@ func runMnistRayJobRayClusterAppWrapper(t *testing.T, accelerator string, number
143150
awMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(aw)
144151
test.Expect(err).NotTo(HaveOccurred())
145152
unstruct := unstructured.Unstructured{Object: awMap}
146-
_, err = test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Create(test.Ctx(), &unstruct, metav1.CreateOptions{})
153+
unstructp, err := test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Create(test.Ctx(), &unstruct, metav1.CreateOptions{})
154+
test.Expect(err).NotTo(HaveOccurred())
155+
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructp.Object, aw)
147156
test.Expect(err).NotTo(HaveOccurred())
148-
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.GenerateName)
157+
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.Name)
149158

150-
test.T().Logf("Waiting for AppWrapper %s/%s to be running", aw.Namespace, aw.GenerateName)
159+
test.T().Logf("Waiting for AppWrapper %s/%s to be running", aw.Namespace, aw.Name)
151160
test.Eventually(AppWrappers(test, namespace), TestTimeoutMedium).
152161
Should(ContainElement(WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperRunning))))
153162

@@ -180,6 +189,17 @@ func runMnistRayJobRayClusterAppWrapper(t *testing.T, accelerator string, number
180189
// Assert the Ray job has completed successfully
181190
test.Expect(GetRayJob(test, rayJob.Namespace, rayJob.Name)).
182191
To(WithTransform(RayJobStatus, Equal(rayv1.JobStatusSucceeded)))
192+
193+
// Assert the AppWrapper has completed successfully
194+
test.Expect(AppWrappers(test, namespace)(test)).
195+
To(ContainElement(WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperSucceeded))))
196+
197+
test.T().Logf("Deleting AppWrapper %s/%s", aw.Namespace, aw.Name)
198+
err = test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Delete(test.Ctx(), aw.Name, metav1.DeleteOptions{})
199+
test.Expect(err).NotTo(HaveOccurred())
200+
201+
test.T().Logf("Waiting for AppWrapper %s/%s to be deleted", aw.Namespace, aw.Name)
202+
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).Should(BeEmpty())
183203
}
184204

185205
func constructMNISTConfigMap(test Test, namespace *corev1.Namespace) *corev1.ConfigMap {

0 commit comments

Comments
 (0)