sigs.k8s.io/kueue@v0.6.2/test/e2e/multikueue/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 mke2e
    18  
    19  import (
    20  	"context"
    21  	"fmt"
    22  	"os"
    23  	"testing"
    24  	"time"
    25  
    26  	"github.com/onsi/ginkgo/v2"
    27  	"github.com/onsi/gomega"
    28  	"sigs.k8s.io/controller-runtime/pkg/client"
    29  
    30  	"sigs.k8s.io/kueue/test/util"
    31  )
    32  
    33  var (
    34  	k8sManagerClient client.Client
    35  	k8sWorker1Client client.Client
    36  	k8sWorker2Client client.Client
    37  	ctx              context.Context
    38  )
    39  
    40  func TestAPIs(t *testing.T) {
    41  	suiteName := "End To End MultiKueue Suite"
    42  	if ver, found := os.LookupEnv("E2E_KIND_VERSION"); found {
    43  		suiteName = fmt.Sprintf("%s: %s", suiteName, ver)
    44  	}
    45  	gomega.RegisterFailHandler(ginkgo.Fail)
    46  	ginkgo.RunSpecs(t,
    47  		suiteName,
    48  	)
    49  }
    50  
    51  var _ = ginkgo.BeforeSuite(func() {
    52  	managerClusterName := os.Getenv("MANAGER_KIND_CLUSTER_NAME")
    53  	gomega.Expect(managerClusterName).NotTo(gomega.BeEmpty(), "MANAGER_KIND_CLUSTER_NAME should not be empty")
    54  
    55  	worker1ClusterName := os.Getenv("WORKER1_KIND_CLUSTER_NAME")
    56  	gomega.Expect(worker1ClusterName).NotTo(gomega.BeEmpty(), "WORKER1_KIND_CLUSTER_NAME should not be empty")
    57  
    58  	worker2ClusterName := os.Getenv("WORKER2_KIND_CLUSTER_NAME")
    59  	gomega.Expect(worker1ClusterName).NotTo(gomega.BeEmpty(), "WORKER2_KIND_CLUSTER_NAME should not be empty")
    60  
    61  	k8sManagerClient = util.CreateClientUsingCluster("kind-" + managerClusterName)
    62  	k8sWorker1Client = util.CreateClientUsingCluster("kind-" + worker1ClusterName)
    63  	k8sWorker2Client = util.CreateClientUsingCluster("kind-" + worker2ClusterName)
    64  
    65  	ctx = context.Background()
    66  
    67  	waitForAvailableStart := time.Now()
    68  	util.WaitForKueueAvailability(ctx, k8sManagerClient)
    69  	util.WaitForKueueAvailability(ctx, k8sWorker1Client)
    70  	util.WaitForKueueAvailability(ctx, k8sWorker2Client)
    71  	ginkgo.GinkgoLogr.Info("Kueue is Available in all the clusters", "waitingTime", time.Since(waitForAvailableStart))
    72  })