From d3e505665db3245d3a8678a0b03108354a52e9a8 Mon Sep 17 00:00:00 2001 From: YACOVM Date: Sat, 17 Dec 2016 01:11:59 +0200 Subject: [PATCH] Gossip pullStore test fixes 1) Saw some sporadic failures of timeout in people's build jobs. I think 10s sometimes doesn't cut it in CI. Increased to 20s. If I'll see more failures after that I'll look deeper. 2) The assertions in TestHandleMessage might run twice before the test is finished and the second time they shouldn't be tested (because replication has been finished). Added a check for that. Change-Id: I319106dafad242063857acab2d502a6a14689324 Signed-off-by: Yacov Manevich --- gossip/gossip/pull/pullstore_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gossip/gossip/pull/pullstore_test.go b/gossip/gossip/pull/pullstore_test.go index 1cc650e5f9e..9c06a4db50d 100644 --- a/gossip/gossip/pull/pullstore_test.go +++ b/gossip/gossip/pull/pullstore_test.go @@ -31,7 +31,7 @@ import ( ) var pullInterval time.Duration -var timeoutInterval = 10 * time.Second +var timeoutInterval = 20 * time.Second func init() { pullInterval = time.Duration(500) * time.Millisecond @@ -222,11 +222,17 @@ func TestHandleMessage(t *testing.T) { inst1ReceivedResponse := int32(0) inst1.mediator.RegisterMsgHook(DigestMsgType, func(itemIds []string, _ []*proto.GossipMessage, _ comm.ReceivedMessage) { + if atomic.LoadInt32(&inst1ReceivedDigest) == int32(1) { + return + } atomic.StoreInt32(&inst1ReceivedDigest, int32(1)) assert.True(t, len(itemIds) == 3) }) inst1.mediator.RegisterMsgHook(ResponseMsgType, func(_ []string, items []*proto.GossipMessage, _ comm.ReceivedMessage) { + if atomic.LoadInt32(&inst1ReceivedResponse) == int32(1) { + return + } atomic.StoreInt32(&inst1ReceivedResponse, int32(1)) assert.True(t, len(items) == 3) })