Add a test case for the race in #59822

Kubernetes-commit: be482ad51c21d493f4b83de9aa06c511a552b5b1
This commit is contained in:
Kris 2018-02-13 11:32:36 -08:00 committed by Kubernetes Publisher
parent 7cd1d3291b
commit 3f0de10d86

View File

@ -251,3 +251,15 @@ func TestResyncCheckPeriod(t *testing.T) {
t.Errorf("expected %d, got %d", e, a) t.Errorf("expected %d, got %d", e, a)
} }
} }
// verify that https://github.com/kubernetes/kubernetes/issues/59822 is fixed
func TestSharedInformerInitializationRace(t *testing.T) {
source := fcache.NewFakeControllerSource()
informer := NewSharedInformer(source, &v1.Pod{}, 1*time.Second).(*sharedIndexInformer)
listener := newTestListener("raceListener", 0)
stop := make(chan struct{})
go informer.AddEventHandlerWithResyncPeriod(listener, listener.resyncPeriod)
go informer.Run(stop)
close(stop)
}