sigs.k8s.io/kueue@v0.6.2/test/integration/controller/core/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 core
    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  	ctx         context.Context
    44  	fwk         *framework.Framework
    45  	crdPath     = filepath.Join("..", "..", "..", "..", "config", "components", "crd", "bases")
    46  	webhookPath = filepath.Join("..", "..", "..", "..", "config", "components", "webhook")
    47  )
    48  
    49  func TestAPIs(t *testing.T) {
    50  	gomega.RegisterFailHandler(ginkgo.Fail)
    51  
    52  	ginkgo.RunSpecs(t,
    53  		"Core Controllers Suite",
    54  	)
    55  }
    56  
    57  func managerSetup(mgr manager.Manager, ctx context.Context) {
    58  	err := indexer.Setup(ctx, mgr.GetFieldIndexer())
    59  	gomega.Expect(err).NotTo(gomega.HaveOccurred())
    60  
    61  	failedWebhook, err := webhooks.Setup(mgr)
    62  	gomega.Expect(err).ToNot(gomega.HaveOccurred(), "webhook", failedWebhook)
    63  
    64  	controllersCfg := &config.Configuration{}
    65  	mgr.GetScheme().Default(controllersCfg)
    66  
    67  	controllersCfg.Metrics.EnableClusterQueueResources = true
    68  	controllersCfg.QueueVisibility = &config.QueueVisibility{
    69  		UpdateIntervalSeconds: 2,
    70  		ClusterQueues: &config.ClusterQueueVisibility{
    71  			MaxCount: 3,
    72  		},
    73  	}
    74  
    75  	cCache := cache.New(mgr.GetClient())
    76  	queues := queue.NewManager(mgr.GetClient(), cCache)
    77  
    78  	failedCtrl, err := core.SetupControllers(mgr, queues, cCache, controllersCfg)
    79  	gomega.Expect(err).ToNot(gomega.HaveOccurred(), "controller", failedCtrl)
    80  }