File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -100,11 +100,29 @@ func (ts *IntegrationTestSuite) SetupSuite() {
100100
101101func (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
110128func (ts * IntegrationTestSuite ) SetupTest () {
You can’t perform that action at this time.
0 commit comments