|
|
|
@@ -88,9 +88,9 @@ func newJob(parallelism, completions, backoffLimit int32) *batch.Job {
|
|
|
|
|
return j
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newJobControllerFromClient(kubeClient clientset.Interface, resyncPeriod controller.ResyncPeriodFunc) (*JobController, informers.SharedInformerFactory) {
|
|
|
|
|
func newControllerFromClient(kubeClient clientset.Interface, resyncPeriod controller.ResyncPeriodFunc) (*Controller, informers.SharedInformerFactory) {
|
|
|
|
|
sharedInformers := informers.NewSharedInformerFactory(kubeClient, resyncPeriod())
|
|
|
|
|
jm := NewJobController(sharedInformers.Core().V1().Pods(), sharedInformers.Batch().V1().Jobs(), kubeClient)
|
|
|
|
|
jm := NewController(sharedInformers.Core().V1().Pods(), sharedInformers.Batch().V1().Jobs(), kubeClient)
|
|
|
|
|
jm.podControl = &controller.FakePodControl{}
|
|
|
|
|
|
|
|
|
|
return jm, sharedInformers
|
|
|
|
@@ -272,7 +272,7 @@ func TestControllerSyncJob(t *testing.T) {
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
|
// job manager setup
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{Err: tc.podControllerError, CreateLimit: tc.podLimit}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -413,7 +413,7 @@ func TestSyncJobPastDeadline(t *testing.T) {
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
|
// job manager setup
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -479,7 +479,7 @@ func getCondition(job *batch.Job, condition batch.JobConditionType, reason strin
|
|
|
|
|
|
|
|
|
|
func TestSyncPastDeadlineJobFinished(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -517,7 +517,7 @@ func TestSyncPastDeadlineJobFinished(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestSyncJobComplete(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -545,7 +545,7 @@ func TestSyncJobComplete(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestSyncJobDeleted(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, _ := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, _ := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -570,7 +570,7 @@ func TestSyncJobDeleted(t *testing.T) {
|
|
|
|
|
func TestSyncJobUpdateRequeue(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
DefaultJobBackOff = time.Duration(0) // overwrite the default value for testing
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -599,7 +599,7 @@ func TestSyncJobUpdateRequeue(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestJobPodLookup(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
|
manager.jobStoreSynced = alwaysReady
|
|
|
|
|
testCases := []struct {
|
|
|
|
@@ -681,7 +681,7 @@ func TestJobPodLookup(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestGetPodsForJob(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -729,7 +729,7 @@ func TestGetPodsForJobAdopt(t *testing.T) {
|
|
|
|
|
job1 := newJob(1, 1, 6)
|
|
|
|
|
job1.Name = "job1"
|
|
|
|
|
clientset := fake.NewSimpleClientset(job1)
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -756,7 +756,7 @@ func TestGetPodsForJobNoAdoptIfBeingDeleted(t *testing.T) {
|
|
|
|
|
job1.Name = "job1"
|
|
|
|
|
job1.DeletionTimestamp = &metav1.Time{}
|
|
|
|
|
clientset := fake.NewSimpleClientset(job1)
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -787,7 +787,7 @@ func TestGetPodsForJobNoAdoptIfBeingDeletedRace(t *testing.T) {
|
|
|
|
|
// The up-to-date object says it's being deleted.
|
|
|
|
|
job1.DeletionTimestamp = &metav1.Time{}
|
|
|
|
|
clientset := fake.NewSimpleClientset(job1)
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -817,7 +817,7 @@ func TestGetPodsForJobNoAdoptIfBeingDeletedRace(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestGetPodsForJobRelease(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -846,7 +846,7 @@ func TestGetPodsForJobRelease(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestAddPod(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -891,7 +891,7 @@ func TestAddPod(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestAddPodOrphan(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -919,7 +919,7 @@ func TestAddPodOrphan(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestUpdatePod(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -968,7 +968,7 @@ func TestUpdatePod(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestUpdatePodOrphanWithNewLabels(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -995,7 +995,7 @@ func TestUpdatePodOrphanWithNewLabels(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestUpdatePodChangeControllerRef(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -1021,7 +1021,7 @@ func TestUpdatePodChangeControllerRef(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestUpdatePodRelease(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -1047,7 +1047,7 @@ func TestUpdatePodRelease(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestDeletePod(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -1092,7 +1092,7 @@ func TestDeletePod(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestDeletePodOrphan(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
jm, informer := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm, informer := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
jm.podStoreSynced = alwaysReady
|
|
|
|
|
jm.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -1132,7 +1132,7 @@ func (fe FakeJobExpectations) SatisfiedExpectations(controllerKey string) bool {
|
|
|
|
|
// and checking expectations.
|
|
|
|
|
func TestSyncJobExpectations(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -1166,7 +1166,7 @@ func TestWatchJobs(t *testing.T) {
|
|
|
|
|
clientset := fake.NewSimpleClientset()
|
|
|
|
|
fakeWatch := watch.NewFake()
|
|
|
|
|
clientset.PrependWatchReactor("jobs", core.DefaultWatchReactor(fakeWatch, nil))
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
|
manager.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -1211,7 +1211,7 @@ func TestWatchPods(t *testing.T) {
|
|
|
|
|
clientset := fake.NewSimpleClientset(testJob)
|
|
|
|
|
fakeWatch := watch.NewFake()
|
|
|
|
|
clientset.PrependWatchReactor("pods", core.DefaultWatchReactor(fakeWatch, nil))
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
|
manager.jobStoreSynced = alwaysReady
|
|
|
|
|
|
|
|
|
@@ -1294,7 +1294,7 @@ func TestJobBackoffReset(t *testing.T) {
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
DefaultJobBackOff = time.Duration(0) // overwrite the default value for testing
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -1382,7 +1382,7 @@ func TestJobBackoff(t *testing.T) {
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
@@ -1474,7 +1474,7 @@ func TestJobBackoffForOnFailure(t *testing.T) {
|
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
|
// job manager setup
|
|
|
|
|
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
|
|
|
|
manager, sharedInformerFactory := newJobControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
manager, sharedInformerFactory := newControllerFromClient(clientset, controller.NoResyncPeriodFunc)
|
|
|
|
|
fakePodControl := controller.FakePodControl{}
|
|
|
|
|
manager.podControl = &fakePodControl
|
|
|
|
|
manager.podStoreSynced = alwaysReady
|
|
|
|
|