Skip to content

Commit 51b2b2e

Browse files
committed
Fix merge conflicts
1 parent 252a76b commit 51b2b2e

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

test/integration_test.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,29 @@ func (ts *IntegrationTestSuite) SetupSuite() {
100100

101101
func (ts *IntegrationTestSuite) TearDownSuite() {
102102
ts.rpcClient.Close()
103-
// sleep for a while to allow the pollers to shutdown
104-
// then assert that there are no lingering go routines
105-
time.Sleep(1 * time.Minute)
106-
// https://github.com/uber-go/cadence-client/issues/739
107-
goleak.VerifyNoLeaks(ts.T(), goleak.IgnoreTopFunction("go.uber.org/cadence/internal.(*coroutineState).initialYield"))
103+
104+
// allow the pollers to shut down, and ensure there are no goroutine leaks.
105+
// this will wait for up to 1 minute for leaks to subside, but exit relatively quickly if possible.
106+
max := time.After(time.Minute)
107+
var last error
108+
for {
109+
select {
110+
case <-max:
111+
if last != nil {
112+
ts.NoError(last)
113+
return
114+
}
115+
ts.FailNow("leaks timed out but no error, should be impossible")
116+
case <-time.After(time.Second):
117+
// https://github.com/uber-go/cadence-client/issues/739
118+
last = goleak.FindLeaks(goleak.IgnoreTopFunction("go.uber.org/cadence/internal.(*coroutineState).initialYield"))
119+
if last == nil {
120+
// no leak, done waiting
121+
return
122+
}
123+
// else wait for another check or the timeout (which will record the latest error)
124+
}
125+
}
108126
}
109127

110128
func (ts *IntegrationTestSuite) SetupTest() {

0 commit comments

Comments
 (0)