Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MESOS: properly wait for called chans to close #19454

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions contrib/mesos/pkg/runtime/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,37 @@ func TestUntil(t *testing.T) {

<-called
close(ch)
<-called

// wait for 'called' to be closed
for {
if _, ok := <-called; !ok {
break
}
}

//--
ch = make(chan struct{})
called = make(chan struct{})
called2 := make(chan struct{})
running := make(chan struct{})
After(func() {
Until(func() {
close(running)
called <- struct{}{}
called2 <- struct{}{}
}, 2*time.Second, ch)
}).Then(func() { close(called) })
}).Then(func() { close(called2) })

<-running
close(ch)
<-called // unblock the goroutine
<-called2 // unblock the goroutine
now := time.Now()

<-called
// wait for 'called2' to be closed
for {
if _, ok := <-called2; !ok {
break
}
}

if time.Since(now) > 1800*time.Millisecond {
t.Fatalf("Until should not have waited the full timeout period since we closed the stop chan")
}
Expand Down