From f5e3db1e1acf572b8fcab259019b274dd496ee5d Mon Sep 17 00:00:00 2001 From: Parameswaran Selvam Date: Thu, 7 Oct 2021 12:37:19 +0000 Subject: [PATCH] set TestBlockPullerBadBlocks pullblock wait time Limiting the test wait time. It will help to fail fast the testcase. Signed-off-by: Parameswaran Selvam --- orderer/common/cluster/deliver_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/orderer/common/cluster/deliver_test.go b/orderer/common/cluster/deliver_test.go index 6c63bc29a43..990422938c7 100644 --- a/orderer/common/cluster/deliver_test.go +++ b/orderer/common/cluster/deliver_test.go @@ -1086,7 +1086,11 @@ func TestBlockPullerBadBlocks(t *testing.T) { return nil })) - bp.PullBlock(10) + endPullBlock := make(chan struct{}) + go func() { + bp.PullBlock(10) + close(endPullBlock) + }() select { case <-detectedBadBlockDone: @@ -1094,6 +1098,14 @@ func TestBlockPullerBadBlocks(t *testing.T) { t.Fatalf("expected %q to be logged but it was not seen", testCase.expectedErrMsg) } + select { + case <-endPullBlock: + case <-time.After(10 * time.Second): + // Signal PullBlock to give up on the retries & mark the test as fail + close(bp.StopChannel) + t.Fatalf("PullBlock did not complete within time") + } + bp.Close() dialer.assertAllConnectionsClosed(t) })