From b7aaeb8591d1d3ffc6865413628f7b9122176138 Mon Sep 17 00:00:00 2001 From: Andrew Coleman Date: Mon, 7 Feb 2022 16:20:31 +0000 Subject: [PATCH] Fix gossip unit test flake (#3215) Increasing the timeout in the gossip service unit tests appears to reduce the occurence of the flake that we frequently observe. This should be seen as a tactical fix while the underlying cause is investigated. Signed-off-by: andrew-coleman (cherry picked from commit ab3d74183ffcda347f2c09c3dc80f3dd4f946f62) --- gossip/service/gossip_service_test.go | 7 +++++-- gossip/service/integration_test.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gossip/service/gossip_service_test.go b/gossip/service/gossip_service_test.go index 70e0f27533b..81d993687bb 100644 --- a/gossip/service/gossip_service_test.go +++ b/gossip/service/gossip_service_test.go @@ -51,7 +51,7 @@ import ( "google.golang.org/grpc" ) -const TIMEOUT = 45 * time.Second +const TIMEOUT = 90 * time.Second func init() { util.SetupTestLogging() @@ -610,7 +610,9 @@ func (jmc *joinChanMsg) AnchorPeersOf(org api.OrgIdentityType) []api.AnchorPeer } func waitForFullMembershipOrFailNow(t *testing.T, channel string, gossips []*gossipGRPC, peersNum int, timeout time.Duration, testPollInterval time.Duration) { - end := time.Now().Add(timeout) + logger.Warning("Waiting for", peersNum, "members") + start := time.Now() + end := start.Add(timeout) var correctPeers int for time.Now().Before(end) { correctPeers = 0 @@ -620,6 +622,7 @@ func waitForFullMembershipOrFailNow(t *testing.T, channel string, gossips []*gos } } if correctPeers == peersNum { + logger.Warning("Established full channel membership in", time.Since(start)) return } time.Sleep(testPollInterval) diff --git a/gossip/service/integration_test.go b/gossip/service/integration_test.go index 452e203815e..0681124b6c1 100644 --- a/gossip/service/integration_test.go +++ b/gossip/service/integration_test.go @@ -105,7 +105,7 @@ func TestLeaderYield(t *testing.T) { // Add peers to the channel addPeersToChannel(channelName, gossips, peerIndexes) // Prime the membership view of the peers - waitForFullMembershipOrFailNow(t, channelName, gossips, n, time.Second*30, time.Millisecond*100) + waitForFullMembershipOrFailNow(t, channelName, gossips, n, TIMEOUT, time.Millisecond*100) grpcClient, err := comm.NewGRPCClient(comm.ClientConfig{}) require.NoError(t, err)