Clean shutdown of endpoints/endpointslice integration tests

This commit is contained in:
Wojciech Tyczyński
2022-05-28 21:51:14 +02:00
parent 3af4c74f37
commit c20f7cc4e1
4 changed files with 25 additions and 6 deletions

View File

@@ -28,9 +28,11 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/fake"
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/controller"
)
@@ -58,6 +60,11 @@ func newController(batchPeriod time.Duration) (*fake.Clientset, *endpointSliceMi
client,
batchPeriod)
// The event processing pipeline is normally started via Run() method.
// However, since we don't start it in unit tests, we explicitly start it here.
esController.eventBroadcaster.StartLogging(klog.Infof)
esController.eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: client.CoreV1().Events("")})
esController.endpointsSynced = alwaysReady
esController.endpointSlicesSynced = alwaysReady
esController.servicesSynced = alwaysReady