mirror of
https://github.com/kubernetes/client-go.git
synced 2025-12-26 06:32:27 +00:00
Add a test case for the race in #59822
Kubernetes-commit: 5596045f46c219ee91428b677675a17dd9c97440
This commit is contained in:
committed by
Kubernetes Publisher
parent
3a46b5de73
commit
7cef162dc9
12
tools/cache/shared_informer_test.go
vendored
12
tools/cache/shared_informer_test.go
vendored
@@ -251,3 +251,15 @@ func TestResyncCheckPeriod(t *testing.T) {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user