@@ -26,16 +26,15 @@ import (
2626
2727 rbacv1 "k8s.io/api/rbac/v1"
2828 apierrors "k8s.io/apimachinery/pkg/api/errors"
29- "k8s.io/apimachinery/pkg/api/resource "
29+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured "
3030 "k8s.io/apimachinery/pkg/runtime"
3131 "k8s.io/apimachinery/pkg/types"
3232 "k8s.io/apimachinery/pkg/util/wait"
3333 clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3434 "k8s.io/client-go/rest"
3535 ctrl "sigs.k8s.io/controller-runtime"
3636 "sigs.k8s.io/controller-runtime/pkg/client"
37- kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
38- kc "sigs.k8s.io/kueue/pkg/controller/constants"
37+ "sigs.k8s.io/yaml"
3938
4039 v1 "k8s.io/api/core/v1"
4140 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -45,9 +44,8 @@ import (
4544)
4645
4746const (
48- testNamespace = "e2e-test"
49- testFlavorName = "e2e-test-flavor"
50- testQueueName = "e2e-test-queue"
47+ testNamespace = "e2e-test"
48+ testQueueName = "e2e-test-queue"
5149)
5250
5351type myKey struct {
@@ -69,7 +67,6 @@ func extendContextWithClient(ctx context.Context) context.Context {
6967 scheme := runtime .NewScheme ()
7068 Expect (clientgoscheme .AddToScheme (scheme )).To (Succeed ())
7169 Expect (awv1beta2 .AddToScheme (scheme )).To (Succeed ())
72- Expect (kueue .AddToScheme (scheme )).To (Succeed ())
7370
7471 // Create a client with full permissions
7572 k8sClient , err := client .New (baseConfig , client.Options {Scheme : scheme })
@@ -115,34 +112,52 @@ func extendContextWithLimitedClient(ctx context.Context) context.Context {
115112 return context .WithValue (ctx , myKey {key : "kubelimitedclient" }, limitedClient )
116113}
117114
118- func ensureTestQueuesExist (ctx context.Context ) {
119- rf := & kueue.ResourceFlavor {ObjectMeta : metav1.ObjectMeta {Name : testFlavorName }}
120- err := getClient (ctx ).Create (ctx , rf )
121- Expect (client .IgnoreAlreadyExists (err )).To (Succeed ())
122- cq := & kueue.ClusterQueue {
123- ObjectMeta : metav1.ObjectMeta {Name : testQueueName },
124- Spec : kueue.ClusterQueueSpec {
125- NamespaceSelector : & metav1.LabelSelector {},
126- ResourceGroups : []kueue.ResourceGroup {{
127- CoveredResources : []v1.ResourceName {v1 .ResourceCPU , "nvidia.com/gpu" },
128- Flavors : []kueue.FlavorQuotas {{
129- Name : testFlavorName ,
130- Resources : []kueue.ResourceQuota {{Name : v1 .ResourceCPU , NominalQuota : * resource .NewMilliQuantity (2000 , resource .DecimalSI )},
131- {Name : "nvidia.com/gpu" , NominalQuota : * resource .NewQuantity (2 , resource .DecimalSI )}},
132- }},
133- },
134- },
135- },
136- }
137- err = getClient (ctx ).Create (ctx , cq )
115+ const flavorYAML = `
116+ apiVersion: kueue.x-k8s.io/v1beta1
117+ kind: ResourceFlavor
118+ metadata:
119+ name: e2e-test-flavor
120+ `
121+ const clusterQueueYAML = `
122+ apiVersion: kueue.x-k8s.io/v1beta1
123+ kind: ClusterQueue
124+ metadata:
125+ name: ` + testQueueName + `
126+ spec:
127+ namespaceSelector: {}
128+ resourceGroups:
129+ - coveredResources: [cpu, nvidia.com/gpu]
130+ flavors:
131+ - name: e2e-test-flavor
132+ resources:
133+ - name: cpu
134+ nominalQuota: 2000m
135+ - name: nvidia.com/gpu
136+ nominalQuota: 2
137+ `
138+ const localQueueYAML = `
139+ apiVersion: kueue.x-k8s.io/v1beta1
140+ kind: LocalQueue
141+ metadata:
142+ namespace: ` + testNamespace + `
143+ name: ` + testQueueName + `
144+ spec:
145+ clusterQueue: ` + testQueueName
146+
147+ func createFromYaml (ctx context.Context , yamlString string ) {
148+ jsonBytes , err := yaml .YAMLToJSON ([]byte (yamlString ))
149+ Expect (err ).NotTo (HaveOccurred ())
150+ obj := & unstructured.Unstructured {}
151+ _ , _ , err = unstructured .UnstructuredJSONScheme .Decode (jsonBytes , nil , obj )
152+ Expect (err ).NotTo (HaveOccurred ())
153+ err = getClient (ctx ).Create (ctx , obj )
138154 Expect (client .IgnoreAlreadyExists (err )).To (Succeed ())
155+ }
139156
140- lq := & kueue.LocalQueue {
141- ObjectMeta : metav1.ObjectMeta {Name : testQueueName , Namespace : testNamespace },
142- Spec : kueue.LocalQueueSpec {ClusterQueue : kueue .ClusterQueueReference (testQueueName )},
143- }
144- err = getClient (ctx ).Create (ctx , lq )
145- Expect (client .IgnoreAlreadyExists (err )).To (Succeed ())
157+ func ensureTestQueuesExist (ctx context.Context ) {
158+ createFromYaml (ctx , flavorYAML )
159+ createFromYaml (ctx , clusterQueueYAML )
160+ createFromYaml (ctx , localQueueYAML )
146161}
147162
148163func cleanupTestObjects (ctx context.Context , appwrappers []* awv1beta2.AppWrapper ) {
@@ -181,7 +196,7 @@ func toAppWrapper(components ...awv1beta2.AppWrapperComponent) *awv1beta2.AppWra
181196 ObjectMeta : metav1.ObjectMeta {
182197 Name : randName ("aw" ),
183198 Namespace : testNamespace ,
184- Labels : map [string ]string {kc . QueueLabel : testQueueName },
199+ Labels : map [string ]string {"kueue.x-k8s.io/queue-name" : testQueueName },
185200 },
186201 Spec : awv1beta2.AppWrapperSpec {Components : components },
187202 }
0 commit comments