Merge pull request #95123 from lavalamp/fix-95064

fix goroutine that lives too long
This commit is contained in:
Kubernetes Prow Robot
2020-09-29 01:39:25 -07:00
committed by GitHub

View File

@@ -22,6 +22,7 @@ import (
"reflect"
goruntime "runtime"
"strconv"
"sync"
"testing"
"time"
@@ -941,8 +942,12 @@ func TestWatchBookmarksWithCorrectResourceVersion(t *testing.T) {
defer watcher.Stop()
done := make(chan struct{})
defer close(done)
var wg sync.WaitGroup
wg.Add(1)
defer wg.Wait() // We must wait for the waitgroup to exit before we terminate the cache or the server in prior defers
defer close(done) // call close first, so the goroutine knows to exit
go func() {
defer wg.Done()
for i := 0; i < 100; i++ {
select {
case <-done: