@@ -45,6 +45,7 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
4545
4646 var (
4747 ns * corev1.Namespace
48+ nsNoLabel * corev1.Namespace
4849 rf * kueuev1beta1.ResourceFlavor
4950 cq * kueuev1beta1.ClusterQueue
5051 lq * kueuev1beta1.LocalQueue
@@ -70,6 +71,10 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
7071 ns = CreateTestNamespaceWithName (test , uniqueSuffix ("vap" ))
7172 defer test .Client ().Core ().CoreV1 ().Namespaces ().Delete (test .Ctx (), ns .Name , metav1.DeleteOptions {})
7273
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+
7378 // Create a resource flavor
7479 rf = CreateKueueResourceFlavor (test , kueuev1beta1.ResourceFlavorSpec {})
7580 defer test .Client ().Kueue ().KueueV1beta1 ().ResourceFlavors ().Delete (test .Ctx (), rf .Name , metav1.DeleteOptions {})
@@ -176,7 +181,7 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
176181 test .Eventually (func () error {
177182 _ , err := test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Create (test .Ctx (), rc , metav1.CreateOptions {})
178183 return err
179- }).WithTimeout (5 * time .Second ).WithPolling (500 * time .Millisecond ).Should (Succeed ())
184+ }).WithTimeout (10 * time .Second ).WithPolling (500 * time .Millisecond ).Should (Succeed ())
180185 defer test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
181186 })
182187 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) {
217222 test .Eventually (func () bool {
218223 ns , _ = test .Client ().Core ().CoreV1 ().Namespaces ().Get (test .Ctx (), ns .Name , metav1.GetOptions {})
219224 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 ())
221226 test .Expect (err ).ToNot (HaveOccurred ())
222227
223228 // Apply the ValidatingAdmissionPolicyBinding targetting namespaces with the label 'kueue-managed'
@@ -234,7 +239,7 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
234239 test .Eventually (func () error {
235240 _ , err := test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Create (test .Ctx (), rc , metav1.CreateOptions {})
236241 return err
237- }).WithTimeout (5 * time .Second ).WithPolling (500 * time .Millisecond ).ShouldNot (Succeed ())
242+ }).WithTimeout (10 * time .Second ).WithPolling (500 * time .Millisecond ).ShouldNot (Succeed ())
238243 defer test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
239244 })
240245 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) {
244249 defer test .Client ().Ray ().RayV1 ().RayClusters (ns .Name ).Delete (test .Ctx (), rc .Name , metav1.DeleteOptions {})
245250 })
246251 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 {})
249254 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 {})
251256 })
252257 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 {})
257264 })
258265 })
259266}
0 commit comments