Skip to content

Commit

Permalink
call watch.Stop() for pending events
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
  • Loading branch information
gaurav1086 committed Jul 11, 2020
1 parent fef7ce9 commit ccf8ad7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/e2e/node/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ var _ = SIGDescribe("Pods Extended", func() {
// create the pod, capture the change events, then delete the pod
start := time.Now()
created := podClient.Create(pod)
ch := make(chan []watch.Event, 1)
ch := make(chan []watch.Event)
numEvents := 0
go func() {
defer close(ch)
w, err := podClient.Watch(context.TODO(), metav1.ListOptions{
Expand All @@ -298,6 +299,7 @@ var _ = SIGDescribe("Pods Extended", func() {
}
}
ch <- events
numEvents = len(events)
}()

t := time.Duration(rand.Intn(delay)) * time.Millisecond
Expand All @@ -319,6 +321,11 @@ var _ = SIGDescribe("Pods Extended", func() {
}
case <-time.After(5 * time.Minute):
framework.Failf("timed out waiting for watch events for %s", pod.Name)
// Iterate over the events and stop them to avoid leak
for i := 0; i < numEvents; i++ {
w := <-ch
w.Stop()
}
}

end := time.Now()
Expand Down

0 comments on commit ccf8ad7

Please sign in to comment.