Skip to content

Commit 2bcff4e

Browse files
committed
Kueue-enable e2e test cases
1 parent 3766549 commit 2bcff4e

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

test/e2e/mnist_pytorch_mcad_job_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ func TestMNISTPyTorchMCAD(t *testing.T) {
3535
test := With(t)
3636
test.T().Parallel()
3737

38-
// Create a namespace
38+
// Create a namespace and localqueue in that namespace
3939
namespace := test.NewTestNamespace()
40+
localQueue := EnsureLocalQueue(test, namespace)
4041

4142
// Test configuration
4243
config := &corev1.ConfigMap{
@@ -130,8 +131,9 @@ func TestMNISTPyTorchMCAD(t *testing.T) {
130131
Kind: "AppWrapper",
131132
},
132133
ObjectMeta: metav1.ObjectMeta{
133-
Name: "mnist",
134-
Namespace: namespace.Name,
134+
Name: "mnist",
135+
Namespace: namespace.Name,
136+
Annotations: map[string]string{"kueue.x-k8s.io/queue-name": localQueue.Name},
135137
},
136138
Spec: mcadv1beta2.AppWrapperSpec{
137139
Components: []mcadv1beta2.AppWrapperComponent{

test/e2e/mnist_rayjob_mcad_raycluster_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ func TestMNISTRayJobMCADRayCluster(t *testing.T) {
3737
test := With(t)
3838
test.T().Parallel()
3939

40-
// Create a namespace
40+
// Create a namespace and localqueue in that namespace
4141
namespace := test.NewTestNamespace()
42+
localQueue := EnsureLocalQueue(test, namespace)
4243

4344
// MNIST training script
4445
mnist := &corev1.ConfigMap{
@@ -181,8 +182,9 @@ func TestMNISTRayJobMCADRayCluster(t *testing.T) {
181182
Kind: "AppWrapper",
182183
},
183184
ObjectMeta: metav1.ObjectMeta{
184-
Name: "ray-cluster",
185-
Namespace: namespace.Name,
185+
Name: "ray-cluster",
186+
Namespace: namespace.Name,
187+
Annotations: map[string]string{"kueue.x-k8s.io/queue-name": localQueue.Name},
186188
},
187189
Spec: mcadv1beta2.AppWrapperSpec{
188190
Components: []mcadv1beta2.AppWrapperComponent{

test/e2e/setup.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ metadata:
6767
spec:
6868
namespaceSelector: {} # match all.
6969
resourceGroups:
70-
- coveredResources: ["cpu"]
70+
- coveredResources: ["cpu","memory"]
7171
flavors:
7272
- name: "default-flavor"
7373
resources:
7474
- name: "cpu"
7575
nominalQuota: 4
76+
- name: "memory"
77+
nominalQuota: "4G"
7678
EOF

test/e2e/support.go

+25
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ import (
2121

2222
"github.com/onsi/gomega"
2323
"github.com/project-codeflare/codeflare-common/support"
24+
25+
corev1 "k8s.io/api/core/v1"
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
28+
"k8s.io/apimachinery/pkg/runtime"
29+
"sigs.k8s.io/controller-runtime/pkg/client"
30+
kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
2431
)
2532

2633
//go:embed *.py *.txt *.sh
@@ -32,3 +39,21 @@ func ReadFile(t support.Test, fileName string) []byte {
3239
t.Expect(err).NotTo(gomega.HaveOccurred())
3340
return file
3441
}
42+
43+
func EnsureLocalQueue(t support.Test, namespace *corev1.Namespace) *kueue.LocalQueue {
44+
t.T().Helper()
45+
46+
lq := &kueue.LocalQueue{
47+
TypeMeta: metav1.TypeMeta{APIVersion: kueue.GroupVersion.String(), Kind: "LocalQueue"},
48+
ObjectMeta: metav1.ObjectMeta{Name: "e2e-test-queue", Namespace: namespace.Name},
49+
Spec: kueue.LocalQueueSpec{ClusterQueue: kueue.ClusterQueueReference("e2e-cluster-queue")},
50+
}
51+
localQueueResource := kueue.GroupVersion.WithResource("localqueues")
52+
lqMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(lq)
53+
t.Expect(err).NotTo(gomega.HaveOccurred())
54+
unstruct := unstructured.Unstructured{Object: lqMap}
55+
_, err = t.Client().Dynamic().Resource(localQueueResource).Namespace(namespace.Name).Create(t.Ctx(), &unstruct, metav1.CreateOptions{})
56+
t.Expect(client.IgnoreAlreadyExists(err)).NotTo(gomega.HaveOccurred())
57+
58+
return lq
59+
}

0 commit comments

Comments
 (0)