sigs.k8s.io/kueue@v0.6.2/test/integration/webhook/localqueue_test.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 http://www.apache.org/licenses/LICENSE-2.0 7 Unless required by applicable law or agreed to in writing, software 8 distributed under the License is distributed on an "AS IS" BASIS, 9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 See the License for the specific language governing permissions and 11 limitations under the License. 12 */ 13 14 package webhook 15 16 import ( 17 "github.com/onsi/ginkgo/v2" 18 "github.com/onsi/gomega" 19 "sigs.k8s.io/controller-runtime/pkg/client" 20 21 kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1" 22 "sigs.k8s.io/kueue/pkg/util/testing" 23 "sigs.k8s.io/kueue/test/util" 24 ) 25 26 const queueName = "queue-test" 27 28 var _ = ginkgo.Describe("Queue validating webhook", func() { 29 ginkgo.When("Updating a Queue", func() { 30 ginkgo.It("Should reject the change of spec.clusterQueue", func() { 31 ginkgo.By("Creating a new Queue") 32 obj := testing.MakeLocalQueue(queueName, ns.Name).ClusterQueue("foo").Obj() 33 gomega.Expect(k8sClient.Create(ctx, obj)).Should(gomega.Succeed()) 34 35 ginkgo.By("Updating the Queue") 36 gomega.Eventually(func() error { 37 var updatedQ kueue.LocalQueue 38 gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(obj), &updatedQ)).Should(gomega.Succeed()) 39 updatedQ.Spec.ClusterQueue = "bar" 40 return k8sClient.Update(ctx, &updatedQ) 41 }, util.Timeout, util.Interval).Should(testing.BeForbiddenError()) 42 }) 43 }) 44 })