k8s.io/kubernetes@v1.29.3/test/e2e/upgrades/node/nvidia-gpu.go (about) 1 /* 2 Copyright 2018 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 node 18 19 import ( 20 "context" 21 22 "k8s.io/kubernetes/test/e2e/framework" 23 e2ejob "k8s.io/kubernetes/test/e2e/framework/job" 24 "k8s.io/kubernetes/test/e2e/scheduling" 25 "k8s.io/kubernetes/test/e2e/upgrades" 26 27 "github.com/onsi/ginkgo/v2" 28 "github.com/onsi/gomega" 29 ) 30 31 const ( 32 completions = int32(1) 33 ) 34 35 // NvidiaGPUUpgradeTest tests that gpu resource is available before and after 36 // a cluster upgrade. 37 type NvidiaGPUUpgradeTest struct { 38 } 39 40 // Name returns the tracking name of the test. 41 func (NvidiaGPUUpgradeTest) Name() string { return "nvidia-gpu-upgrade [sig-node] [sig-scheduling]" } 42 43 // Setup creates a job requesting gpu. 44 func (t *NvidiaGPUUpgradeTest) Setup(ctx context.Context, f *framework.Framework) { 45 scheduling.SetupNVIDIAGPUNode(ctx, f, false) 46 ginkgo.By("Creating a job requesting gpu") 47 scheduling.StartJob(ctx, f, completions) 48 } 49 50 // Test waits for the upgrade to complete, and then verifies that the 51 // cuda pod started by the gpu job can successfully finish. 52 func (t *NvidiaGPUUpgradeTest) Test(ctx context.Context, f *framework.Framework, done <-chan struct{}, upgrade upgrades.UpgradeType) { 53 <-done 54 ginkgo.By("Verifying gpu job success") 55 scheduling.VerifyJobNCompletions(ctx, f, completions) 56 if upgrade == upgrades.MasterUpgrade || upgrade == upgrades.ClusterUpgrade { 57 // MasterUpgrade should be totally hitless. 58 job, err := e2ejob.GetJob(ctx, f.ClientSet, f.Namespace.Name, "cuda-add") 59 framework.ExpectNoError(err) 60 gomega.Expect(job.Status.Failed).To(gomega.BeZero(), "Job pods failed during master upgrade: %v", job.Status.Failed) 61 } 62 } 63 64 // Teardown cleans up any remaining resources. 65 func (t *NvidiaGPUUpgradeTest) Teardown(ctx context.Context, f *framework.Framework) { 66 // rely on the namespace deletion to clean up everything 67 }