nvidia-gpu.go 2.1 KB

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