job.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright 2017 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. batch "k8s.io/api/batch/v1"
  16. "k8s.io/api/core/v1"
  17. "k8s.io/kubernetes/test/e2e/framework"
  18. jobutil "k8s.io/kubernetes/test/e2e/framework/job"
  19. "k8s.io/kubernetes/test/e2e/upgrades"
  20. "github.com/onsi/ginkgo"
  21. )
  22. // JobUpgradeTest is a test harness for batch Jobs.
  23. type JobUpgradeTest struct {
  24. job *batch.Job
  25. namespace string
  26. }
  27. // Name returns the tracking name of the test.
  28. func (JobUpgradeTest) Name() string { return "[sig-apps] job-upgrade" }
  29. // Setup starts a Job with a parallelism of 2 and 2 completions running.
  30. func (t *JobUpgradeTest) Setup(f *framework.Framework) {
  31. t.namespace = f.Namespace.Name
  32. ginkgo.By("Creating a job")
  33. t.job = jobutil.NewTestJob("notTerminate", "foo", v1.RestartPolicyOnFailure, 2, 2, nil, 6)
  34. job, err := jobutil.CreateJob(f.ClientSet, t.namespace, t.job)
  35. t.job = job
  36. framework.ExpectNoError(err)
  37. ginkgo.By("Ensuring active pods == parallelism")
  38. err = jobutil.WaitForAllJobPodsRunning(f.ClientSet, t.namespace, job.Name, 2)
  39. framework.ExpectNoError(err)
  40. }
  41. // Test verifies that the Jobs Pods are running after the an upgrade
  42. func (t *JobUpgradeTest) Test(f *framework.Framework, done <-chan struct{}, upgrade upgrades.UpgradeType) {
  43. <-done
  44. ginkgo.By("Ensuring active pods == parallelism")
  45. err := jobutil.EnsureAllJobPodsRunning(f.ClientSet, t.namespace, t.job.Name, 2)
  46. framework.ExpectNoError(err)
  47. }
  48. // Teardown cleans up any remaining resources.
  49. func (t *JobUpgradeTest) Teardown(f *framework.Framework) {
  50. // rely on the namespace deletion to clean up everything
  51. }