Skip to content

Commit

Permalink
[FAB-3182] CI failure delivery svc- goroutines not end
Browse files Browse the repository at this point in the history
Added polling logic to the check that ensures that goroutines
are not left running.

Change-Id: I513a680789ffca9073f8f45b5c2377fcd626aa1f
Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Apr 16, 2017
1 parent 56b6d12 commit 297df35
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions core/deliverservice/deliveryclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func init() {
msptesttools.LoadMSPSetupForTesting("../../msp/sampleconfig")
}

var lock = sync.Mutex{}
const (
goRoutineTestWaitTimeout = time.Second * 10
)

var (
lock = sync.Mutex{}
)

type mockBlocksDelivererFactory struct {
mockCreate func() (blocksprovider.BlocksDeliverer, error)
Expand Down Expand Up @@ -349,7 +355,14 @@ func assertBlockDissemination(expectedSeq uint64, ch chan uint64, t *testing.T)
func ensureNoGoroutineLeak(t *testing.T) func() {
goroutineCountAtStart := runtime.NumGoroutine()
return func() {
time.Sleep(time.Second)
start := time.Now()
timeLimit := start.Add(goRoutineTestWaitTimeout)
for time.Now().Before(timeLimit) {
time.Sleep(time.Millisecond * 500)
if goroutineCountAtStart == runtime.NumGoroutine() {
return
}
}
assert.Equal(t, goroutineCountAtStart, runtime.NumGoroutine(), "Some goroutine(s) didn't finish: %s", getStackTrace())
}
}
Expand Down

0 comments on commit 297df35

Please sign in to comment.