...

Source file src/k8s.io/kubernetes/test/e2e/upgrades/node/nvidia-gpu.go

Documentation: k8s.io/kubernetes/test/e2e/upgrades/node

     1  //go:build !providerless
     2  // +build !providerless
     3  
     4  /*
     5  Copyright 2018 The Kubernetes Authors.
     6  
     7  Licensed under the Apache License, Version 2.0 (the "License");
     8  you may not use this file except in compliance with the License.
     9  You may obtain a copy of the License at
    10  
    11      http://www.apache.org/licenses/LICENSE-2.0
    12  
    13  Unless required by applicable law or agreed to in writing, software
    14  distributed under the License is distributed on an "AS IS" BASIS,
    15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16  See the License for the specific language governing permissions and
    17  limitations under the License.
    18  */
    19  
    20  package node
    21  
    22  import (
    23  	"context"
    24  
    25  	"k8s.io/kubernetes/test/e2e/framework"
    26  	e2ejob "k8s.io/kubernetes/test/e2e/framework/job"
    27  	"k8s.io/kubernetes/test/e2e/scheduling"
    28  	"k8s.io/kubernetes/test/e2e/upgrades"
    29  
    30  	"github.com/onsi/ginkgo/v2"
    31  	"github.com/onsi/gomega"
    32  )
    33  
    34  const (
    35  	completions = int32(1)
    36  )
    37  
    38  // NvidiaGPUUpgradeTest tests that gpu resource is available before and after
    39  // a cluster upgrade.
    40  type NvidiaGPUUpgradeTest struct {
    41  }
    42  
    43  // Name returns the tracking name of the test.
    44  func (NvidiaGPUUpgradeTest) Name() string { return "nvidia-gpu-upgrade [sig-node] [sig-scheduling]" }
    45  
    46  // Setup creates a job requesting gpu.
    47  func (t *NvidiaGPUUpgradeTest) Setup(ctx context.Context, f *framework.Framework) {
    48  	scheduling.SetupNVIDIAGPUNode(ctx, f, false)
    49  	ginkgo.By("Creating a job requesting gpu")
    50  	scheduling.StartJob(ctx, f, completions)
    51  }
    52  
    53  // Test waits for the upgrade to complete, and then verifies that the
    54  // cuda pod started by the gpu job can successfully finish.
    55  func (t *NvidiaGPUUpgradeTest) Test(ctx context.Context, f *framework.Framework, done <-chan struct{}, upgrade upgrades.UpgradeType) {
    56  	<-done
    57  	ginkgo.By("Verifying gpu job success")
    58  	scheduling.VerifyJobNCompletions(ctx, f, completions)
    59  	if upgrade == upgrades.MasterUpgrade || upgrade == upgrades.ClusterUpgrade {
    60  		// MasterUpgrade should be totally hitless.
    61  		job, err := e2ejob.GetJob(ctx, f.ClientSet, f.Namespace.Name, "cuda-add")
    62  		framework.ExpectNoError(err)
    63  		gomega.Expect(job.Status.Failed).To(gomega.BeZero(), "Job pods failed during master upgrade: %v", job.Status.Failed)
    64  	}
    65  }
    66  
    67  // Teardown cleans up any remaining resources.
    68  func (t *NvidiaGPUUpgradeTest) Teardown(ctx context.Context, f *framework.Framework) {
    69  	// rely on the namespace deletion to clean up everything
    70  }
    71  

View as plain text