use stopCh to avoid goroutine leak in tests
Kubernetes-commit: 132d477cb7aa323c0eae6dd9a09f9c93fb570b83
This commit is contained in:
parent
5d08b1abe9
commit
2595ae0416
|
|
@ -107,7 +107,11 @@ func TestAccessReviewCheckOnMissingNamespace(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("unexpected error initializing handler: %v", err)
|
||||
}
|
||||
informerFactory.Start(wait.NeverStop)
|
||||
|
||||
stopCh := make(chan struct{})
|
||||
defer close(stopCh)
|
||||
|
||||
informerFactory.Start(stopCh)
|
||||
|
||||
err = handler.Admit(context.TODO(), admission.NewAttributesRecord(nil, nil, schema.GroupVersionKind{Group: "authorization.k8s.io", Version: "v1", Kind: "LocalSubjectAccesReview"}, namespace, "", schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1", Resource: "localsubjectaccessreviews"}, "", admission.Create, &metav1.CreateOptions{}, false, nil), nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -115,15 +115,17 @@ func TestQueueWaitTimeLatencyTracker(t *testing.T) {
|
|||
QueueSetFactory: fqs.NewQueueSetFactory(clk),
|
||||
})
|
||||
|
||||
informerFactory.Start(nil)
|
||||
stopCh := make(chan struct{})
|
||||
defer close(stopCh)
|
||||
|
||||
status := informerFactory.WaitForCacheSync(nil)
|
||||
informerFactory.Start(stopCh)
|
||||
status := informerFactory.WaitForCacheSync(stopCh)
|
||||
if names := unsynced(status); len(names) > 0 {
|
||||
t.Fatalf("WaitForCacheSync did not successfully complete, resources=%#v", names)
|
||||
}
|
||||
|
||||
go func() {
|
||||
controller.Run(nil)
|
||||
controller.Run(stopCh)
|
||||
}()
|
||||
|
||||
// ensure that the controller has run its first loop.
|
||||
|
|
|
|||
Loading…
Reference in New Issue