sigs.k8s.io/kueue@v0.6.2/test/integration/webhook/suite_test.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package webhook 18 19 import ( 20 "context" 21 "path/filepath" 22 "testing" 23 24 "github.com/onsi/ginkgo/v2" 25 "github.com/onsi/gomega" 26 "k8s.io/client-go/rest" 27 "sigs.k8s.io/controller-runtime/pkg/client" 28 "sigs.k8s.io/controller-runtime/pkg/manager" 29 30 config "sigs.k8s.io/kueue/apis/config/v1beta1" 31 "sigs.k8s.io/kueue/pkg/cache" 32 "sigs.k8s.io/kueue/pkg/controller/core" 33 "sigs.k8s.io/kueue/pkg/controller/core/indexer" 34 "sigs.k8s.io/kueue/pkg/queue" 35 "sigs.k8s.io/kueue/pkg/webhooks" 36 "sigs.k8s.io/kueue/test/integration/framework" 37 // +kubebuilder:scaffold:imports 38 ) 39 40 var ( 41 cfg *rest.Config 42 k8sClient client.Client 43 fwk *framework.Framework 44 ctx context.Context 45 ) 46 47 func TestAPIs(t *testing.T) { 48 gomega.RegisterFailHandler(ginkgo.Fail) 49 ginkgo.RunSpecs(t, 50 "Webhook Suite", 51 ) 52 } 53 54 var _ = ginkgo.BeforeSuite(func() { 55 fwk = &framework.Framework{ 56 CRDPath: filepath.Join("..", "..", "..", "config", "components", "crd", "bases"), 57 WebhookPath: filepath.Join("..", "..", "..", "config", "components", "webhook"), 58 } 59 cfg = fwk.Init() 60 ctx, k8sClient = fwk.RunManager(cfg, func(mgr manager.Manager, ctx context.Context) { 61 err := indexer.Setup(ctx, mgr.GetFieldIndexer()) 62 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 63 64 failedWebhook, err := webhooks.Setup(mgr) 65 gomega.Expect(err).ToNot(gomega.HaveOccurred(), "webhook", failedWebhook) 66 67 cCache := cache.New(mgr.GetClient()) 68 queues := queue.NewManager(mgr.GetClient(), cCache) 69 70 configuration := &config.Configuration{} 71 mgr.GetScheme().Default(configuration) 72 73 failedCtrl, err := core.SetupControllers(mgr, queues, cCache, configuration) 74 gomega.Expect(err).ToNot(gomega.HaveOccurred(), "controller", failedCtrl) 75 }) 76 }) 77 78 var _ = ginkgo.AfterSuite(func() { 79 fwk.Teardown() 80 })