@@ -39,6 +39,7 @@ import (
39
39
// The Validating Admission Policy feature gate is GA and enabled by default from OCP v4.17 (k8s v1.30)
40
40
41
41
var (
42
+ err error
42
43
ns * corev1.Namespace
43
44
nsNoLabel * corev1.Namespace
44
45
rf * kueuev1beta1.ResourceFlavor
@@ -56,20 +57,19 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
56
57
57
58
Tags (t , Sanity )
58
59
59
- // Create a namespace
60
- ns = CreateTestNamespaceWithName (test , uniqueSuffix ("vap" ))
61
- defer test .Client ().Core ().CoreV1 ().Namespaces ().Delete (test .Ctx (), ns .Name , metav1.DeleteOptions {})
62
-
63
- // Get the latest version of the namespace
64
- ns , err := test .Client ().Core ().CoreV1 ().Namespaces ().Get (test .Ctx (), ns .Name , metav1.GetOptions {})
65
- test .Expect (err ).ToNot (HaveOccurred ())
66
-
67
- // Add the 'kueue.openshift.io/managed' label
68
- ns .Labels = map [string ]string {
69
- "kueue.openshift.io/managed" : "true" ,
70
- }
71
- _ , err = test .Client ().Core ().CoreV1 ().Namespaces ().Update (test .Ctx (), ns , metav1.UpdateOptions {})
72
- test .Expect (err ).ToNot (HaveOccurred ())
60
+ // Create namespace with unique name and required labels
61
+ var AsDefaultQueueNamespace = ErrorOption [* corev1.Namespace ](func (ns * corev1.Namespace ) error {
62
+ if ns .Labels == nil {
63
+ ns .Labels = make (map [string ]string )
64
+ }
65
+ ns .Labels ["kueue.openshift.io/managed" ] = "true"
66
+ return nil
67
+ })
68
+ ns = CreateTestNamespaceWithName (
69
+ test ,
70
+ uniqueSuffix ("vap" ),
71
+ AsDefaultQueueNamespace ,
72
+ )
73
73
74
74
// Create a namespace that will not receive the `kueue.x-k8s.io/queue-name` label
75
75
nsNoLabel = CreateTestNamespaceWithName (test , uniqueSuffix ("vap-nl" ))
0 commit comments