mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 16:49:35 +00:00
Merge pull request #26619 from jsafrane/fix-fake-recorder-flake
Automatic merge from submit-queue Fix fake event recorder race Event recorder should wait for some time to get all expected events, the event may be written by another goroutine that just have finished. It should not slow down the test in most cases, only when there is a bug and expected event is not sent. Fixes #26578 Using P2 to speed up merge and to prevent further flakes. @kubernetes/sig-storage
This commit is contained in:
commit
517dedd419
@ -358,11 +358,14 @@ func (r *volumeReactor) checkClaims(t *testing.T, expectedClaims []*api.Persiste
|
||||
func checkEvents(t *testing.T, expectedEvents []string, ctrl *PersistentVolumeController) error {
|
||||
var err error
|
||||
|
||||
// Read recorded events
|
||||
// Read recorded events - wait up to 1 minute to get all the expected ones
|
||||
// (just in case some goroutines are slower with writing)
|
||||
timer := time.NewTimer(time.Minute)
|
||||
|
||||
fakeRecorder := ctrl.eventRecorder.(*record.FakeRecorder)
|
||||
gotEvents := []string{}
|
||||
finished := false
|
||||
for !finished {
|
||||
for len(gotEvents) < len(expectedEvents) && !finished {
|
||||
select {
|
||||
case event, ok := <-fakeRecorder.Events:
|
||||
if ok {
|
||||
@ -372,8 +375,8 @@ func checkEvents(t *testing.T, expectedEvents []string, ctrl *PersistentVolumeCo
|
||||
glog.V(5).Infof("event recorder finished")
|
||||
finished = true
|
||||
}
|
||||
default:
|
||||
glog.V(5).Infof("event recorder finished")
|
||||
case _, _ = <-timer.C:
|
||||
glog.V(5).Infof("event recorder timeout")
|
||||
finished = true
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user