Skip to content

Commit

Permalink
Gossip comm test fix
Browse files Browse the repository at this point in the history
Was notified that TestReconnections fails on ppc build with high probability.
Fixed a timely assumption in TestReConnections in gossip/comm/comm_test.go
Also changed the file name convention of the private and public keys to
be randomly generated.

Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
Change-Id: I9143efa5b7082ea1023fb1331386d5dcd01f2601
  • Loading branch information
yacovm committed Dec 22, 2016
1 parent 384e294 commit a9d0652
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions gossip/comm/comm_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,9 @@ func createGRPCLayer(port int) (*grpc.Server, net.Listener, grpc.DialOption) {
var serverOpts []grpc.ServerOption
var dialOpts grpc.DialOption

keyFileName := fmt.Sprintf("key.%d.pem", time.Now().UnixNano())
certFileName := fmt.Sprintf("cert.%d.pem", time.Now().UnixNano())

keyFileName := fmt.Sprintf("key.%d.pem", rand.Int63())
certFileName := fmt.Sprintf("cert.%d.pem", rand.Int63())

defer os.Remove(keyFileName)
defer os.Remove(certFileName)
Expand Down
16 changes: 7 additions & 9 deletions gossip/comm/comm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,21 +420,19 @@ func TestReConnections(t *testing.T) {

// comm1 connects to comm2
comm1.Send(createGossipMsg(), remotePeer(3612))
time.Sleep(100 * time.Millisecond)
waitForMessages(t, out2 , 1, "Comm2 didn't receive a message from comm1 in a timely manner")
time.Sleep(time.Second)
// comm2 sends to comm1
comm2.Send(createGossipMsg(), remotePeer(3611))
time.Sleep(100 * time.Millisecond)

assert.Equal(t, 1, len(out2))
assert.Equal(t, 1, len(out1))
waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner")

comm1.Stop()
comm1, _ = newCommInstance(3611, naiveSec)
time.Sleep(time.Second)
out1 = make(chan uint64, 1)
go reader(out1, comm1.Accept(acceptAll))
time.Sleep(300 * time.Millisecond)
comm2.Send(createGossipMsg(), remotePeer(3611))
time.Sleep(100 * time.Millisecond)
assert.Equal(t, 2, len(out1))
waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner")
}

func TestProbe(t *testing.T) {
Expand Down Expand Up @@ -498,7 +496,7 @@ func remotePeer(port int) *RemotePeer {
func waitForMessages(t *testing.T, msgChan chan uint64, count int, errMsg string) {
c := 0
waiting := true
ticker := time.NewTicker(time.Duration(5) * time.Second)
ticker := time.NewTicker(time.Duration(10) * time.Second)
for waiting {
select {
case <-msgChan:
Expand Down

0 comments on commit a9d0652

Please sign in to comment.