mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
chore(Job): use ctx.Done() instead of stopCh
This commit is contained in:
parent
af5b8bed70
commit
75a4cfbd58
@ -6446,10 +6446,8 @@ func TestWatchJobs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Start only the job watcher and the workqueue, send a watch event,
|
// Start only the job watcher and the workqueue, send a watch event,
|
||||||
// and make sure it hits the sync method.
|
// and make sure it hits the sync method.
|
||||||
stopCh := make(chan struct{})
|
sharedInformerFactory.Start(ctx.Done())
|
||||||
defer close(stopCh)
|
sharedInformerFactory.WaitForCacheSync(ctx.Done())
|
||||||
sharedInformerFactory.Start(stopCh)
|
|
||||||
sharedInformerFactory.WaitForCacheSync(stopCh)
|
|
||||||
go manager.Run(ctx, 1)
|
go manager.Run(ctx, 1)
|
||||||
|
|
||||||
// We're sending new job to see if it reaches syncHandler.
|
// We're sending new job to see if it reaches syncHandler.
|
||||||
@ -6494,9 +6492,7 @@ func TestWatchPods(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Start only the pod watcher and the workqueue, send a watch event,
|
// Start only the pod watcher and the workqueue, send a watch event,
|
||||||
// and make sure it hits the sync method for the right job.
|
// and make sure it hits the sync method for the right job.
|
||||||
stopCh := make(chan struct{})
|
go sharedInformerFactory.Core().V1().Pods().Informer().Run(ctx.Done())
|
||||||
defer close(stopCh)
|
|
||||||
go sharedInformerFactory.Core().V1().Pods().Informer().Run(stopCh)
|
|
||||||
go manager.Run(ctx, 1)
|
go manager.Run(ctx, 1)
|
||||||
|
|
||||||
pods := newPodList(1, v1.PodRunning, testJob)
|
pods := newPodList(1, v1.PodRunning, testJob)
|
||||||
@ -6519,11 +6515,9 @@ func TestWatchOrphanPods(t *testing.T) {
|
|||||||
manager.podStoreSynced = alwaysReady
|
manager.podStoreSynced = alwaysReady
|
||||||
manager.jobStoreSynced = alwaysReady
|
manager.jobStoreSynced = alwaysReady
|
||||||
|
|
||||||
stopCh := make(chan struct{})
|
|
||||||
defer close(stopCh)
|
|
||||||
podInformer := sharedInformers.Core().V1().Pods().Informer()
|
podInformer := sharedInformers.Core().V1().Pods().Informer()
|
||||||
go podInformer.Run(stopCh)
|
go podInformer.Run(ctx.Done())
|
||||||
cache.WaitForCacheSync(stopCh, podInformer.HasSynced)
|
cache.WaitForCacheSync(ctx.Done(), podInformer.HasSynced)
|
||||||
go manager.Run(ctx, 1)
|
go manager.Run(ctx, 1)
|
||||||
|
|
||||||
// Create job but don't add it to the store.
|
// Create job but don't add it to the store.
|
||||||
@ -6592,11 +6586,9 @@ func TestSyncOrphanPod(t *testing.T) {
|
|||||||
manager.podStoreSynced = alwaysReady
|
manager.podStoreSynced = alwaysReady
|
||||||
manager.jobStoreSynced = alwaysReady
|
manager.jobStoreSynced = alwaysReady
|
||||||
|
|
||||||
stopCh := make(chan struct{})
|
|
||||||
defer close(stopCh)
|
|
||||||
podInformer := sharedInformers.Core().V1().Pods().Informer()
|
podInformer := sharedInformers.Core().V1().Pods().Informer()
|
||||||
go podInformer.Run(stopCh)
|
go podInformer.Run(ctx.Done())
|
||||||
cache.WaitForCacheSync(stopCh, podInformer.HasSynced)
|
cache.WaitForCacheSync(ctx.Done(), podInformer.HasSynced)
|
||||||
go manager.Run(ctx, 1)
|
go manager.Run(ctx, 1)
|
||||||
|
|
||||||
cases := map[string]struct {
|
cases := map[string]struct {
|
||||||
@ -7507,10 +7499,8 @@ func TestFinalizersRemovedExpectations(t *testing.T) {
|
|||||||
t.Errorf("Different expectations for removed finalizers after syncJob (-want,+got):\n%s", diff)
|
t.Errorf("Different expectations for removed finalizers after syncJob (-want,+got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
stopCh := make(chan struct{})
|
go sharedInformers.Core().V1().Pods().Informer().Run(ctx.Done())
|
||||||
defer close(stopCh)
|
cache.WaitForCacheSync(ctx.Done(), podInformer.HasSynced)
|
||||||
go sharedInformers.Core().V1().Pods().Informer().Run(stopCh)
|
|
||||||
cache.WaitForCacheSync(stopCh, podInformer.HasSynced)
|
|
||||||
|
|
||||||
// Make sure the first syncJob sets the expectations, even after the caches synced.
|
// Make sure the first syncJob sets the expectations, even after the caches synced.
|
||||||
gotExpectedUIDs = manager.finalizerExpectations.getExpectedUIDs(jobKey)
|
gotExpectedUIDs = manager.finalizerExpectations.getExpectedUIDs(jobKey)
|
||||||
|
Loading…
Reference in New Issue
Block a user