@@ -45,6 +45,7 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
45
45
46
46
var (
47
47
ns * corev1.Namespace
48
+ nsNoLabel * corev1.Namespace
48
49
rf * kueuev1beta1.ResourceFlavor
49
50
cq * kueuev1beta1.ClusterQueue
50
51
lq * kueuev1beta1.LocalQueue
@@ -70,6 +71,10 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
70
71
ns = CreateTestNamespaceWithName (test , uniqueSuffix ("vap" ))
71
72
defer test .Client ().Core ().CoreV1 ().Namespaces ().Delete (test .Ctx (), ns .Name , metav1.DeleteOptions {})
72
73
74
+ // Create a namespace that will not receive the `kueue.x-k8s.io/queue-name` label
75
+ nsNoLabel = CreateTestNamespaceWithName (test , uniqueSuffix ("vap-nl" ))
76
+ defer test .Client ().Core ().CoreV1 ().Namespaces ().Delete (test .Ctx (), nsNoLabel .Name , metav1.DeleteOptions {})
77
+
73
78
// Create a resource flavor
74
79
rf = CreateKueueResourceFlavor (test , kueuev1beta1.ResourceFlavorSpec {})
75
80
defer test .Client ().Kueue ().KueueV1beta1 ().ResourceFlavors ().Delete (test .Ctx (), rf .Name , metav1.DeleteOptions {})
@@ -176,7 +181,7 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
176
181
test .Eventually (func () error {
177
182
_ , err := test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Create (test .Ctx (), rc , metav1.CreateOptions {})
178
183
return err
179
- }).WithTimeout (5 * time .Second ).WithPolling (500 * time .Millisecond ).Should (Succeed ())
184
+ }).WithTimeout (10 * time .Second ).WithPolling (500 * time .Millisecond ).Should (Succeed ())
180
185
defer test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
181
186
})
182
187
t .Run ("RayCluster should be admitted with the 'kueue.x-k8s.io/queue-name' label set" , func (t * testing.T ) {
@@ -217,7 +222,7 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
217
222
test .Eventually (func () bool {
218
223
ns , _ = test .Client ().Core ().CoreV1 ().Namespaces ().Get (test .Ctx (), ns .Name , metav1.GetOptions {})
219
224
return ns .Labels ["kueue-managed" ] == "true"
220
- }).WithTimeout (5 * time .Second ).WithPolling (500 * time .Millisecond ).Should (BeTrue ())
225
+ }).WithTimeout (10 * time .Second ).WithPolling (500 * time .Millisecond ).Should (BeTrue ())
221
226
test .Expect (err ).ToNot (HaveOccurred ())
222
227
223
228
// Apply the ValidatingAdmissionPolicyBinding targetting namespaces with the label 'kueue-managed'
@@ -234,7 +239,7 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
234
239
test .Eventually (func () error {
235
240
_ , err := test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Create (test .Ctx (), rc , metav1.CreateOptions {})
236
241
return err
237
- }).WithTimeout (5 * time .Second ).WithPolling (500 * time .Millisecond ).ShouldNot (Succeed ())
242
+ }).WithTimeout (10 * time .Second ).WithPolling (500 * time .Millisecond ).ShouldNot (Succeed ())
238
243
defer test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
239
244
})
240
245
t .Run ("RayCluster should be admitted with the 'kueue.x-k8s.io/queue-name' label in a labeled namespace" , func (t * testing.T ) {
@@ -244,16 +249,18 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
244
249
defer test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
245
250
})
246
251
t .Run ("RayCluster should be admitted with the 'kueue.x-k8s.io/queue-name' label in any other namespace" , func (t * testing.T ) {
247
- rc = testingraycluster .MakeCluster (uniqueSuffix (rcWithLQName ), "default" ).Queue (lq .Name ).Obj ()
248
- _ , err = test .Client ().Ray ().RayV1 ().RayClusters ("default" ).Create (test .Ctx (), rc , metav1.CreateOptions {})
252
+ rc = testingraycluster .MakeCluster (uniqueSuffix (rcWithLQName ), nsNoLabel . Name ).Queue (lq .Name ).Obj ()
253
+ _ , err = test .Client ().Ray ().RayV1 ().RayClusters (nsNoLabel . Name ).Create (test .Ctx (), rc , metav1.CreateOptions {})
249
254
test .Expect (err ).ToNot (HaveOccurred ())
250
- defer test .Client ().Ray ().RayV1 ().RayClusters ("default" ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
255
+ defer test .Client ().Ray ().RayV1 ().RayClusters (nsNoLabel . Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
251
256
})
252
257
t .Run ("RayCluster should be admitted without the 'kueue.x-k8s.io/queue-name' label in any other namespace" , func (t * testing.T ) {
253
- rc = testingraycluster .MakeCluster (uniqueSuffix (rcNoLQName ), "default" ).Obj ()
254
- _ , err = test .Client ().Ray ().RayV1 ().RayClusters ("default" ).Create (test .Ctx (), rc , metav1.CreateOptions {})
255
- test .Expect (err ).ToNot (HaveOccurred ())
256
- defer test .Client ().Ray ().RayV1 ().RayClusters ("default" ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
258
+ rc = testingraycluster .MakeCluster (uniqueSuffix (rcNoLQName ), nsNoLabel .Name ).Obj ()
259
+ test .Eventually (func () error {
260
+ _ , err = test .Client ().Ray ().RayV1 ().RayClusters (nsNoLabel .Name ).Create (test .Ctx (), rc , metav1.CreateOptions {})
261
+ return err
262
+ }).WithTimeout (10 * time .Second ).WithPolling (500 * time .Millisecond ).Should (Succeed ())
263
+ defer test .Client ().Ray ().RayV1 ().RayClusters (nsNoLabel .Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
257
264
})
258
265
})
259
266
}
0 commit comments