@@ -2756,7 +2756,7 @@ func getCondition(job *batch.Job, condition batch.JobConditionType, status v1.Co
2756
2756
// reaching the active deadline, at which point it is marked as Failed.
2757
2757
func TestPastDeadlineJobFinished (t * testing.T ) {
2758
2758
_ , ctx := ktesting .NewTestContext (t )
2759
- clientset := fake .NewSimpleClientset ()
2759
+ clientset := fake .NewClientset ()
2760
2760
fakeClock := clocktesting .NewFakeClock (time .Now ().Truncate (time .Second ))
2761
2761
manager , sharedInformerFactory := newControllerFromClientWithClock (ctx , t , clientset , controller .NoResyncPeriodFunc , fakeClock )
2762
2762
manager .podStoreSynced = alwaysReady
@@ -6044,7 +6044,7 @@ func TestGetPodsForJob(t *testing.T) {
6044
6044
if tc .jobDeleted {
6045
6045
job .DeletionTimestamp = & metav1.Time {}
6046
6046
}
6047
- clientSet := fake .NewSimpleClientset (job , otherJob )
6047
+ clientSet := fake .NewClientset (job , otherJob )
6048
6048
jm , informer := newControllerFromClient (ctx , t , clientSet , controller .NoResyncPeriodFunc )
6049
6049
jm .podStoreSynced = alwaysReady
6050
6050
jm .jobStoreSynced = alwaysReady
@@ -6416,7 +6416,7 @@ func TestSyncJobExpectations(t *testing.T) {
6416
6416
6417
6417
func TestWatchJobs (t * testing.T ) {
6418
6418
_ , ctx := ktesting .NewTestContext (t )
6419
- clientset := fake .NewSimpleClientset ()
6419
+ clientset := fake .NewClientset ()
6420
6420
fakeWatch := watch .NewFake ()
6421
6421
clientset .PrependWatchReactor ("jobs" , core .DefaultWatchReactor (fakeWatch , nil ))
6422
6422
manager , sharedInformerFactory := newControllerFromClient (ctx , t , clientset , controller .NoResyncPeriodFunc )
@@ -6446,9 +6446,8 @@ func TestWatchJobs(t *testing.T) {
6446
6446
}
6447
6447
// Start only the job watcher and the workqueue, send a watch event,
6448
6448
// and make sure it hits the sync method.
6449
- stopCh := make (chan struct {})
6450
- defer close (stopCh )
6451
- sharedInformerFactory .Start (stopCh )
6449
+ sharedInformerFactory .Start (ctx .Done ())
6450
+ sharedInformerFactory .WaitForCacheSync (ctx .Done ())
6452
6451
go manager .Run (ctx , 1 )
6453
6452
6454
6453
// We're sending new job to see if it reaches syncHandler.
@@ -6462,7 +6461,7 @@ func TestWatchJobs(t *testing.T) {
6462
6461
func TestWatchPods (t * testing.T ) {
6463
6462
_ , ctx := ktesting .NewTestContext (t )
6464
6463
testJob := newJob (2 , 2 , 6 , batch .NonIndexedCompletion )
6465
- clientset := fake .NewSimpleClientset (testJob )
6464
+ clientset := fake .NewClientset (testJob )
6466
6465
fakeWatch := watch .NewFake ()
6467
6466
clientset .PrependWatchReactor ("pods" , core .DefaultWatchReactor (fakeWatch , nil ))
6468
6467
manager , sharedInformerFactory := newControllerFromClient (ctx , t , clientset , controller .NoResyncPeriodFunc )
@@ -6493,9 +6492,7 @@ func TestWatchPods(t *testing.T) {
6493
6492
}
6494
6493
// Start only the pod watcher and the workqueue, send a watch event,
6495
6494
// and make sure it hits the sync method for the right job.
6496
- stopCh := make (chan struct {})
6497
- defer close (stopCh )
6498
- go sharedInformerFactory .Core ().V1 ().Pods ().Informer ().Run (stopCh )
6495
+ go sharedInformerFactory .Core ().V1 ().Pods ().Informer ().Run (ctx .Done ())
6499
6496
go manager .Run (ctx , 1 )
6500
6497
6501
6498
pods := newPodList (1 , v1 .PodRunning , testJob )
@@ -6509,7 +6506,7 @@ func TestWatchPods(t *testing.T) {
6509
6506
6510
6507
func TestWatchOrphanPods (t * testing.T ) {
6511
6508
_ , ctx := ktesting .NewTestContext (t )
6512
- clientset := fake .NewSimpleClientset ()
6509
+ clientset := fake .NewClientset ()
6513
6510
sharedInformers := informers .NewSharedInformerFactory (clientset , controller .NoResyncPeriodFunc ())
6514
6511
manager , err := NewController (ctx , sharedInformers .Core ().V1 ().Pods (), sharedInformers .Batch ().V1 ().Jobs (), clientset )
6515
6512
if err != nil {
@@ -6518,11 +6515,9 @@ func TestWatchOrphanPods(t *testing.T) {
6518
6515
manager .podStoreSynced = alwaysReady
6519
6516
manager .jobStoreSynced = alwaysReady
6520
6517
6521
- stopCh := make (chan struct {})
6522
- defer close (stopCh )
6523
6518
podInformer := sharedInformers .Core ().V1 ().Pods ().Informer ()
6524
- go podInformer .Run (stopCh )
6525
- cache .WaitForCacheSync (stopCh , podInformer .HasSynced )
6519
+ go podInformer .Run (ctx . Done () )
6520
+ cache .WaitForCacheSync (ctx . Done () , podInformer .HasSynced )
6526
6521
go manager .Run (ctx , 1 )
6527
6522
6528
6523
// Create job but don't add it to the store.
@@ -6582,7 +6577,7 @@ func TestWatchOrphanPods(t *testing.T) {
6582
6577
6583
6578
func TestSyncOrphanPod (t * testing.T ) {
6584
6579
_ , ctx := ktesting .NewTestContext (t )
6585
- clientset := fake .NewSimpleClientset ()
6580
+ clientset := fake .NewClientset ()
6586
6581
sharedInformers := informers .NewSharedInformerFactory (clientset , controller .NoResyncPeriodFunc ())
6587
6582
manager , err := NewController (ctx , sharedInformers .Core ().V1 ().Pods (), sharedInformers .Batch ().V1 ().Jobs (), clientset )
6588
6583
if err != nil {
@@ -6591,11 +6586,9 @@ func TestSyncOrphanPod(t *testing.T) {
6591
6586
manager .podStoreSynced = alwaysReady
6592
6587
manager .jobStoreSynced = alwaysReady
6593
6588
6594
- stopCh := make (chan struct {})
6595
- defer close (stopCh )
6596
6589
podInformer := sharedInformers .Core ().V1 ().Pods ().Informer ()
6597
- go podInformer .Run (stopCh )
6598
- cache .WaitForCacheSync (stopCh , podInformer .HasSynced )
6590
+ go podInformer .Run (ctx . Done () )
6591
+ cache .WaitForCacheSync (ctx . Done () , podInformer .HasSynced )
6599
6592
go manager .Run (ctx , 1 )
6600
6593
6601
6594
cases := map [string ]struct {
@@ -7462,7 +7455,7 @@ func TestEnsureJobConditions(t *testing.T) {
7462
7455
7463
7456
func TestFinalizersRemovedExpectations (t * testing.T ) {
7464
7457
_ , ctx := ktesting .NewTestContext (t )
7465
- clientset := fake .NewSimpleClientset ()
7458
+ clientset := fake .NewClientset ()
7466
7459
sharedInformers := informers .NewSharedInformerFactory (clientset , controller .NoResyncPeriodFunc ())
7467
7460
manager , err := NewController (ctx , sharedInformers .Core ().V1 ().Pods (), sharedInformers .Batch ().V1 ().Jobs (), clientset )
7468
7461
if err != nil {
@@ -7506,10 +7499,8 @@ func TestFinalizersRemovedExpectations(t *testing.T) {
7506
7499
t .Errorf ("Different expectations for removed finalizers after syncJob (-want,+got):\n %s" , diff )
7507
7500
}
7508
7501
7509
- stopCh := make (chan struct {})
7510
- defer close (stopCh )
7511
- go sharedInformers .Core ().V1 ().Pods ().Informer ().Run (stopCh )
7512
- cache .WaitForCacheSync (stopCh , podInformer .HasSynced )
7502
+ go sharedInformers .Core ().V1 ().Pods ().Informer ().Run (ctx .Done ())
7503
+ cache .WaitForCacheSync (ctx .Done (), podInformer .HasSynced )
7513
7504
7514
7505
// Make sure the first syncJob sets the expectations, even after the caches synced.
7515
7506
gotExpectedUIDs = manager .finalizerExpectations .getExpectedUIDs (jobKey )
@@ -7568,7 +7559,7 @@ func TestFinalizerCleanup(t *testing.T) {
7568
7559
ctx , cancel := context .WithCancel (ctx )
7569
7560
defer cancel ()
7570
7561
7571
- clientset := fake .NewSimpleClientset ()
7562
+ clientset := fake .NewClientset ()
7572
7563
sharedInformers := informers .NewSharedInformerFactory (clientset , controller .NoResyncPeriodFunc ())
7573
7564
manager , err := NewController (ctx , sharedInformers .Core ().V1 ().Pods (), sharedInformers .Batch ().V1 ().Jobs (), clientset )
7574
7565
if err != nil {
0 commit comments