sigs.k8s.io/kueue@v0.6.2/test/integration/controller/jobs/raycluster/suite_test.go (about) 1 /* 2 Copyright 2023 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 "context" 18 "path/filepath" 19 "testing" 20 21 "github.com/onsi/ginkgo/v2" 22 "github.com/onsi/gomega" 23 "k8s.io/client-go/rest" 24 "sigs.k8s.io/controller-runtime/pkg/client" 25 "sigs.k8s.io/controller-runtime/pkg/manager" 26 27 config "sigs.k8s.io/kueue/apis/config/v1beta1" 28 "sigs.k8s.io/kueue/pkg/cache" 29 "sigs.k8s.io/kueue/pkg/constants" 30 "sigs.k8s.io/kueue/pkg/controller/core" 31 "sigs.k8s.io/kueue/pkg/controller/core/indexer" 32 "sigs.k8s.io/kueue/pkg/controller/jobframework" 33 "sigs.k8s.io/kueue/pkg/controller/jobs/raycluster" 34 "sigs.k8s.io/kueue/pkg/queue" 35 "sigs.k8s.io/kueue/pkg/scheduler" 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 ctx context.Context 44 fwk *framework.Framework 45 crdPath = filepath.Join("..", "..", "..", "..", "..", "config", "components", "crd", "bases") 46 rayCrdPath = filepath.Join("..", "..", "..", "..", "..", "dep-crds", "ray-operator") 47 webhookPath = filepath.Join("..", "..", "..", "..", "..", "config", "components", "webhook") 48 ) 49 50 func TestAPIs(t *testing.T) { 51 gomega.RegisterFailHandler(ginkgo.Fail) 52 53 ginkgo.RunSpecs(t, 54 "RayCluster Controller Suite", 55 ) 56 } 57 58 func managerSetup(opts ...jobframework.Option) framework.ManagerSetup { 59 return func(mgr manager.Manager, ctx context.Context) { 60 reconciler := raycluster.NewReconciler( 61 mgr.GetClient(), 62 mgr.GetEventRecorderFor(constants.JobControllerName), 63 opts...) 64 err := raycluster.SetupIndexes(ctx, mgr.GetFieldIndexer()) 65 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 66 err = reconciler.SetupWithManager(mgr) 67 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 68 err = raycluster.SetupRayClusterWebhook(mgr, opts...) 69 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 70 } 71 } 72 73 func managerAndSchedulerSetup(opts ...jobframework.Option) framework.ManagerSetup { 74 return func(mgr manager.Manager, ctx context.Context) { 75 err := indexer.Setup(ctx, mgr.GetFieldIndexer()) 76 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 77 78 cCache := cache.New(mgr.GetClient()) 79 queues := queue.NewManager(mgr.GetClient(), cCache) 80 81 failedCtrl, err := core.SetupControllers(mgr, queues, cCache, &config.Configuration{}) 82 gomega.Expect(err).ToNot(gomega.HaveOccurred(), "controller", failedCtrl) 83 84 err = raycluster.SetupIndexes(ctx, mgr.GetFieldIndexer()) 85 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 86 err = raycluster.NewReconciler(mgr.GetClient(), 87 mgr.GetEventRecorderFor(constants.JobControllerName), opts...).SetupWithManager(mgr) 88 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 89 err = raycluster.SetupRayClusterWebhook(mgr, opts...) 90 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 91 92 sched := scheduler.New(queues, cCache, mgr.GetClient(), mgr.GetEventRecorderFor(constants.AdmissionName)) 93 err = sched.Start(ctx) 94 gomega.Expect(err).NotTo(gomega.HaveOccurred()) 95 } 96 }