Skip to content

Commit

Permalink
Fix gossip unit test flake (#3215)
Browse files Browse the repository at this point in the history
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 <andrew_coleman@uk.ibm.com>
(cherry picked from commit ab3d741)
  • Loading branch information
andrew-coleman authored and ale-linux committed Jun 16, 2022
1 parent a914ec3 commit 6f4282b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions gossip/service/gossip_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import (
"google.golang.org/grpc"
)

const TIMEOUT = 45 * time.Second
const TIMEOUT = 90 * time.Second

func init() {
util.SetupTestLogging()
Expand Down Expand Up @@ -611,7 +611,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
Expand All @@ -621,6 +623,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)
Expand Down
2 changes: 1 addition & 1 deletion gossip/service/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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)

store := newTransientStore(t)
defer store.tearDown()
Expand Down

0 comments on commit 6f4282b

Please sign in to comment.