mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-19 09:38:39 +00:00
Merge pull request #94570 from knight42/fix/TestEventSeriesf
test(tools::events): deflake TestEventSeriesf Kubernetes-commit: 86cbfc3ca271cde93ebf5aabbe088e2b0641b50b
This commit is contained in:
commit
529dda0cb8
@ -307,14 +307,7 @@ func (e *eventBroadcasterImpl) StartEventWatcher(eventHandler func(event runtime
|
|||||||
return watcher.Stop
|
return watcher.Stop
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartRecordingToSink starts sending events received from the specified eventBroadcaster to the given sink.
|
func (e *eventBroadcasterImpl) startRecordingEvents(stopCh <-chan struct{}) {
|
||||||
func (e *eventBroadcasterImpl) StartRecordingToSink(stopCh <-chan struct{}) {
|
|
||||||
go wait.Until(func() {
|
|
||||||
e.refreshExistingEventSeries()
|
|
||||||
}, refreshTime, stopCh)
|
|
||||||
go wait.Until(func() {
|
|
||||||
e.finishSeries()
|
|
||||||
}, finishTime, stopCh)
|
|
||||||
eventHandler := func(obj runtime.Object) {
|
eventHandler := func(obj runtime.Object) {
|
||||||
event, ok := obj.(*eventsv1.Event)
|
event, ok := obj.(*eventsv1.Event)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -330,6 +323,13 @@ func (e *eventBroadcasterImpl) StartRecordingToSink(stopCh <-chan struct{}) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StartRecordingToSink starts sending events received from the specified eventBroadcaster to the given sink.
|
||||||
|
func (e *eventBroadcasterImpl) StartRecordingToSink(stopCh <-chan struct{}) {
|
||||||
|
go wait.Until(e.refreshExistingEventSeries, refreshTime, stopCh)
|
||||||
|
go wait.Until(e.finishSeries, finishTime, stopCh)
|
||||||
|
e.startRecordingEvents(stopCh)
|
||||||
|
}
|
||||||
|
|
||||||
type eventBroadcasterAdapterImpl struct {
|
type eventBroadcasterAdapterImpl struct {
|
||||||
coreClient typedv1core.EventsGetter
|
coreClient typedv1core.EventsGetter
|
||||||
coreBroadcaster record.EventBroadcaster
|
coreBroadcaster record.EventBroadcaster
|
||||||
|
@ -69,7 +69,6 @@ func TestEventSeriesf(t *testing.T) {
|
|||||||
|
|
||||||
testPod := &v1.Pod{
|
testPod := &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
SelfLink: "/api/v1/namespaces/baz/pods/foo",
|
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Namespace: "baz",
|
Namespace: "baz",
|
||||||
UID: "bar",
|
UID: "bar",
|
||||||
@ -158,7 +157,11 @@ func TestEventSeriesf(t *testing.T) {
|
|||||||
}
|
}
|
||||||
eventBroadcaster := newBroadcaster(&testEvents, 0, map[eventKey]*eventsv1.Event{})
|
eventBroadcaster := newBroadcaster(&testEvents, 0, map[eventKey]*eventsv1.Event{})
|
||||||
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, "eventTest")
|
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, "eventTest")
|
||||||
eventBroadcaster.StartRecordingToSink(stopCh)
|
broadcaster := eventBroadcaster.(*eventBroadcasterImpl)
|
||||||
|
// Don't call StartRecordingToSink, as we don't need neither refreshing event
|
||||||
|
// series nor finishing them in this tests and additional events updated would
|
||||||
|
// race with our expected ones.
|
||||||
|
broadcaster.startRecordingEvents(stopCh)
|
||||||
recorder.Eventf(regarding, related, isomorphicEvent.Type, isomorphicEvent.Reason, isomorphicEvent.Action, isomorphicEvent.Note, []interface{}{1})
|
recorder.Eventf(regarding, related, isomorphicEvent.Type, isomorphicEvent.Reason, isomorphicEvent.Action, isomorphicEvent.Note, []interface{}{1})
|
||||||
// read from the chan as this was needed only to populate the cache
|
// read from the chan as this was needed only to populate the cache
|
||||||
<-createEvent
|
<-createEvent
|
||||||
|
Loading…
Reference in New Issue
Block a user