Skip to content

Commit 6648392

Browse files
committed
[FAB-3953] Re-introduce disabled goroutine leak test
The check was disabled in FAB-3257 and deals with checking if goroutines that are created during a test are dead after the test ends. It failed because sometimes the number of goroutines that the test started with, was higher than the number it ended with. It should be re-introduced. I think we should simply instead of checking that the number of goroutines hasn't changed from the start of the test to the end of the test - check that it didn't increase, because that proves that a goroutine was created at the time of the test and hasn't finished. Change-Id: Id8caabff4723699ede6047d2640f4442948e52e4 Signed-off-by: Yacov Manevich <[email protected]>
1 parent 956515b commit 6648392

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

core/deliverservice/deliveryclient_test.go

+10-12
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,17 @@ func assertBlockDissemination(expectedSeq uint64, ch chan uint64, t *testing.T)
353353
}
354354

355355
func ensureNoGoroutineLeak(t *testing.T) func() {
356-
//goroutineCountAtStart := runtime.NumGoroutine()
356+
goroutineCountAtStart := runtime.NumGoroutine()
357357
return func() {
358-
// Temporarily disabled, see FAB-3257 for progress
359-
/* start := time.Now()
360-
timeLimit := start.Add(goRoutineTestWaitTimeout)
361-
for time.Now().Before(timeLimit) {
362-
time.Sleep(time.Millisecond * 500)
363-
if goroutineCountAtStart == runtime.NumGoroutine() {
364-
fmt.Println(getStackTrace())
365-
return
366-
}
367-
}
368-
assert.Equal(t, goroutineCountAtStart, runtime.NumGoroutine(), "Some goroutine(s) didn't finish: %s", getStackTrace())*/
358+
start := time.Now()
359+
timeLimit := start.Add(goRoutineTestWaitTimeout)
360+
for time.Now().Before(timeLimit) {
361+
time.Sleep(time.Millisecond * 500)
362+
if goroutineCountAtStart >= runtime.NumGoroutine() {
363+
return
364+
}
365+
}
366+
assert.Fail(t, "Some goroutine(s) didn't finish: %s", getStackTrace())
369367
}
370368
}
371369

0 commit comments

Comments
 (0)