Skip to content

Commit 8e82964

Browse files
committed
Kueue-enable e2e test cases
1 parent 2537d07 commit 8e82964

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
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

+27
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,30 @@ roleRef:
5656
kind: ClusterRole
5757
name: mcad-controller-rayclusters
5858
EOF
59+
60+
61+
echo Creating Kueue ResourceFlavor and ClusterQueue
62+
cat <<EOF | kubectl apply -f -
63+
apiVersion: kueue.x-k8s.io/v1beta1
64+
kind: ResourceFlavor
65+
metadata:
66+
name: "default-flavor"
67+
EOF
68+
69+
cat <<EOF | kubectl apply -f -
70+
apiVersion: kueue.x-k8s.io/v1beta1
71+
kind: ClusterQueue
72+
metadata:
73+
name: "e2e-cluster-queue"
74+
spec:
75+
namespaceSelector: {} # match all.
76+
resourceGroups:
77+
- coveredResources: ["cpu","memory"]
78+
flavors:
79+
- name: "default-flavor"
80+
resources:
81+
- name: "cpu"
82+
nominalQuota: 4
83+
- name: "memory"
84+
nominalQuota: "4G"
85+
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)