Skip to content

Commit

Permalink
Merge "[FAB-3182] CI failure delivery svc- goroutines not end"
Browse files Browse the repository at this point in the history
  • Loading branch information
hacera-jonathan authored and Gerrit Code Review committed Apr 18, 2017
2 parents 2289034 + 297df35 commit eba4a20
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 eba4a20

Please sign in to comment.