Skip to content

Commit 9986552

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

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-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

+26
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ package e2e
1818

1919
import (
2020
"embed"
21+
"fmt"
2122

2223
"github.com/onsi/gomega"
2324
"github.com/project-codeflare/codeflare-common/support"
25+
26+
corev1 "k8s.io/api/core/v1"
27+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
29+
"k8s.io/apimachinery/pkg/runtime"
30+
"sigs.k8s.io/controller-runtime/pkg/client"
31+
kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
2432
)
2533

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

0 commit comments

Comments
 (0)