sigs.k8s.io/kueue@v0.6.2/test/integration/controller/jobs/raycluster/raycluster_webhook_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 raycluster 15 16 import ( 17 "github.com/onsi/ginkgo/v2" 18 "github.com/onsi/gomega" 19 corev1 "k8s.io/api/core/v1" 20 apierrors "k8s.io/apimachinery/pkg/api/errors" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 23 testingjob "sigs.k8s.io/kueue/pkg/util/testingjobs/raycluster" 24 "sigs.k8s.io/kueue/test/integration/framework" 25 "sigs.k8s.io/kueue/test/util" 26 ) 27 28 var _ = ginkgo.Describe("RayCluster Webhook", func() { 29 var ns *corev1.Namespace 30 31 ginkgo.When("With manageJobsWithoutQueueName disabled", ginkgo.Ordered, ginkgo.ContinueOnFailure, func() { 32 33 ginkgo.BeforeAll(func() { 34 fwk = &framework.Framework{ 35 CRDPath: crdPath, 36 DepCRDPaths: []string{rayCrdPath}, 37 WebhookPath: webhookPath, 38 } 39 cfg = fwk.Init() 40 ctx, k8sClient = fwk.RunManager(cfg, managerSetup()) 41 }) 42 ginkgo.BeforeEach(func() { 43 ns = &corev1.Namespace{ 44 ObjectMeta: metav1.ObjectMeta{ 45 GenerateName: "raycluster-", 46 }, 47 } 48 gomega.Expect(k8sClient.Create(ctx, ns)).To(gomega.Succeed()) 49 }) 50 51 ginkgo.AfterEach(func() { 52 gomega.Expect(util.DeleteNamespace(ctx, k8sClient, ns)).To(gomega.Succeed()) 53 }) 54 ginkgo.AfterAll(func() { 55 fwk.Teardown() 56 }) 57 58 ginkgo.It("the creation doesn't succeed if the queue name is invalid", func() { 59 job := testingjob.MakeCluster(jobName, ns.Name).Queue("indexed_job").Obj() 60 err := k8sClient.Create(ctx, job) 61 gomega.Expect(err).Should(gomega.HaveOccurred()) 62 gomega.Expect(apierrors.IsForbidden(err)).Should(gomega.BeTrue(), "error: %v", err) 63 }) 64 }) 65 })