Skip to content

Commit 26a1276

Browse files
committed
Generate AppWrapper name to provide unique workloads
1 parent 03d5bee commit 26a1276

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

Diff for: test/e2e/mnist_pytorch_appwrapper_test.go

+21-13
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,20 @@ func runMnistPyTorchAppWrapper(t *testing.T, accelerator string) {
7575
Kind: "Job",
7676
},
7777
ObjectMeta: metav1.ObjectMeta{
78-
Name: "mnist",
79-
Namespace: namespace.Name,
78+
GenerateName: "mnist",
79+
Namespace: namespace.Name,
8080
},
8181
Spec: batchv1.JobSpec{
8282
Completions: Ptr(int32(1)),
8383
Parallelism: Ptr(int32(1)),
8484
Template: corev1.PodTemplateSpec{
8585
Spec: corev1.PodSpec{
86+
Tolerations: []corev1.Toleration{
87+
{
88+
Key: "nvidia.com/gpu",
89+
Operator: corev1.TolerationOpExists,
90+
},
91+
},
8692
Containers: []corev1.Container{
8793
{
8894
Name: "job",
@@ -139,9 +145,9 @@ func runMnistPyTorchAppWrapper(t *testing.T, accelerator string) {
139145
Kind: "AppWrapper",
140146
},
141147
ObjectMeta: metav1.ObjectMeta{
142-
Name: "mnist",
143-
Namespace: namespace.Name,
144-
Labels: map[string]string{"kueue.x-k8s.io/queue-name": localQueue.Name},
148+
GenerateName: "mnist",
149+
Namespace: namespace.Name,
150+
Labels: map[string]string{"kueue.x-k8s.io/queue-name": localQueue.Name},
145151
},
146152
Spec: mcadv1beta2.AppWrapperSpec{
147153
Components: []mcadv1beta2.AppWrapperComponent{
@@ -158,16 +164,18 @@ func runMnistPyTorchAppWrapper(t *testing.T, accelerator string) {
158164
unstruct := unstructured.Unstructured{Object: awMap}
159165
_, err = test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Create(test.Ctx(), &unstruct, metav1.CreateOptions{})
160166
test.Expect(err).NotTo(HaveOccurred())
161-
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.Name)
167+
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.GenerateName)
162168

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

167173
test.T().Logf("Waiting for AppWrapper %s/%s to complete", job.Namespace, job.Name)
168-
test.Eventually(AppWrapper(test, namespace, aw.Name), TestTimeoutLong).Should(
169-
Or(
170-
WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperSucceeded)),
171-
WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperFailed)),
174+
test.Eventually(AppWrappers(test, namespace), TestTimeoutLong).Should(
175+
ContainElement(
176+
Or(
177+
WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperSucceeded)),
178+
WithTransform(AppWrapperPhase, Equal(mcadv1beta2.AppWrapperFailed)),
179+
),
172180
))
173181
}

Diff for: test/e2e/mnist_rayjob_raycluster_test.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ func runMnistRayJobRayClusterAppWrapper(t *testing.T, accelerator string, number
127127
Kind: "AppWrapper",
128128
},
129129
ObjectMeta: metav1.ObjectMeta{
130-
Name: rayCluster.Name,
131-
Namespace: namespace.Name,
132-
Labels: map[string]string{"kueue.x-k8s.io/queue-name": localQueue.Name},
130+
GenerateName: rayCluster.Name,
131+
Namespace: namespace.Name,
132+
Labels: map[string]string{"kueue.x-k8s.io/queue-name": localQueue.Name},
133133
},
134134
Spec: mcadv1beta2.AppWrapperSpec{
135135
Components: []mcadv1beta2.AppWrapperComponent{
@@ -145,11 +145,11 @@ func runMnistRayJobRayClusterAppWrapper(t *testing.T, accelerator string, number
145145
unstruct := unstructured.Unstructured{Object: awMap}
146146
_, err = test.Client().Dynamic().Resource(appWrapperResource).Namespace(namespace.Name).Create(test.Ctx(), &unstruct, metav1.CreateOptions{})
147147
test.Expect(err).NotTo(HaveOccurred())
148-
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.Name)
148+
test.T().Logf("Created AppWrapper %s/%s successfully", aw.Namespace, aw.GenerateName)
149149

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

154154
test.T().Logf("Waiting for RayCluster %s/%s to be running", rayCluster.Namespace, rayCluster.Name)
155155
test.Eventually(RayCluster(test, namespace.Name, rayCluster.Name), TestTimeoutMedium).
@@ -266,6 +266,12 @@ func constructRayCluster(_ Test, namespace *corev1.Namespace, mnist *corev1.Conf
266266
RayStartParams: map[string]string{},
267267
Template: corev1.PodTemplateSpec{
268268
Spec: corev1.PodSpec{
269+
Tolerations: []corev1.Toleration{
270+
{
271+
Key: "nvidia.com/gpu",
272+
Operator: corev1.TolerationOpExists,
273+
},
274+
},
269275
Containers: []corev1.Container{
270276
{
271277
Name: "ray-worker",

0 commit comments

Comments
 (0)