fix goroutine that lives too long
Kubernetes-commit: 9a2e0fcb18bc9feb327122edc95a968a8d423af7
This commit is contained in:
parent
3f80aac972
commit
7e305c53b5
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue