Skip to content

Commit 297df35

Browse files
committedApr 16, 2017
[FAB-3182] CI failure delivery svc- goroutines not end
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>
1 parent 56b6d12 commit 297df35

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎core/deliverservice/deliveryclient_test.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ func init() {
3737
msptesttools.LoadMSPSetupForTesting("../../msp/sampleconfig")
3838
}
3939

40-
var lock = sync.Mutex{}
40+
const (
41+
goRoutineTestWaitTimeout = time.Second * 10
42+
)
43+
44+
var (
45+
lock = sync.Mutex{}
46+
)
4147

4248
type mockBlocksDelivererFactory struct {
4349
mockCreate func() (blocksprovider.BlocksDeliverer, error)
@@ -349,7 +355,14 @@ func assertBlockDissemination(expectedSeq uint64, ch chan uint64, t *testing.T)
349355
func ensureNoGoroutineLeak(t *testing.T) func() {
350356
goroutineCountAtStart := runtime.NumGoroutine()
351357
return func() {
352-
time.Sleep(time.Second)
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+
}
353366
assert.Equal(t, goroutineCountAtStart, runtime.NumGoroutine(), "Some goroutine(s) didn't finish: %s", getStackTrace())
354367
}
355368
}

0 commit comments

Comments
 (0)