sigs.k8s.io/kueue@v0.6.2/test/integration/controller/admissionchecks/provisioning/suite_test.go (about)

     1  /*
     2  Copyright 2023 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 provisioning
    18  
    19  import (
    20  	"context"
    21  	"path/filepath"
    22  	"testing"
    23  
    24  	"github.com/onsi/ginkgo/v2"
    25  	"github.com/onsi/gomega"
    26  	autoscaling "k8s.io/autoscaler/cluster-autoscaler/apis/provisioningrequest/autoscaling.x-k8s.io/v1beta1"
    27  	"k8s.io/client-go/rest"
    28  	"sigs.k8s.io/controller-runtime/pkg/client"
    29  	"sigs.k8s.io/controller-runtime/pkg/manager"
    30  
    31  	"sigs.k8s.io/kueue/pkg/controller/admissionchecks/provisioning"
    32  	"sigs.k8s.io/kueue/test/integration/framework"
    33  	// +kubebuilder:scaffold:imports
    34  )
    35  
    36  var (
    37  	cfg       *rest.Config
    38  	k8sClient client.Client
    39  	ctx       context.Context
    40  	fwk       *framework.Framework
    41  )
    42  
    43  func TestProvisioning(t *testing.T) {
    44  	gomega.RegisterFailHandler(ginkgo.Fail)
    45  
    46  	ginkgo.RunSpecs(t,
    47  		"Provisioning admission check suite",
    48  	)
    49  }
    50  
    51  func managerSetup(mgr manager.Manager, ctx context.Context) {
    52  	err := autoscaling.AddToScheme(mgr.GetScheme())
    53  	gomega.Expect(err).NotTo(gomega.HaveOccurred())
    54  
    55  	err = provisioning.SetupIndexer(ctx, mgr.GetFieldIndexer())
    56  	gomega.Expect(err).NotTo(gomega.HaveOccurred())
    57  
    58  	reconciler, err := provisioning.NewController(mgr.GetClient(), mgr.GetEventRecorderFor("kueue-provisioning-request-controller"))
    59  	gomega.Expect(err).NotTo(gomega.HaveOccurred())
    60  	err = reconciler.SetupWithManager(mgr)
    61  	gomega.Expect(err).NotTo(gomega.HaveOccurred())
    62  }
    63  
    64  var _ = ginkgo.BeforeSuite(func() {
    65  	fwk = &framework.Framework{
    66  		CRDPath:     filepath.Join("..", "..", "..", "..", "..", "config", "components", "crd", "bases"),
    67  		DepCRDPaths: []string{filepath.Join("..", "..", "..", "..", "..", "dep-crds", "cluster-autoscaler")},
    68  	}
    69  	cfg = fwk.Init()
    70  	ctx, k8sClient = fwk.RunManager(cfg, managerSetup)
    71  })
    72  
    73  var _ = ginkgo.AfterSuite(func() {
    74  	fwk.Teardown()
    75  })