Skip to content

Commit

Permalink
[FAB-3316] Reintroduce TestCloseConn back to CI
Browse files Browse the repository at this point in the history
This commit fixes TestCloseConn that was disabled due to being brittle.
Basically the test creates a stream and authenticates with the
a gossip instance and then makes the gossip instance close the connection
with the stream, and then attempts to send a message via the stream
and see that it fails.

However, due to HTTP/2 buffering, the send sometimes works.
Therefore, I just made the test send ~ 20 messages instead of 1,
hopefully that it would overload the buffer and cause a flush()
in the HTTP/2 implementation and that would fail, which would
make the sending return a failure too.
Also increased the size of the messages that are sent, in order
to make the flushing be more likely triggered

Change-Id: I18695e97f552b582bfa8ee6a3146e1e83a6d1e1d
Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Apr 24, 2017
1 parent 7f114bb commit 5c04b00
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions gossip/comm/comm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ func TestGetConnectionInfo(t *testing.T) {
}

func TestCloseConn(t *testing.T) {
t.Skip()
t.Parallel()
comm1, _ := newCommInstance(1611, naiveSec)
defer comm1.Stop()
Expand Down Expand Up @@ -334,7 +333,20 @@ func TestCloseConn(t *testing.T) {
}
comm1.CloseConn(&RemotePeer{PKIID: common.PKIidType("pkiID")})
time.Sleep(time.Second * 10)
assert.Error(t, stream.Send(createGossipMsg().Envelope), "Should have failed because connection is closed")
gotErr := false
msg2Send := createGossipMsg()
msg2Send.GetDataMsg().Payload = &proto.Payload{
Data: make([]byte, 1024*1024),
}
msg2Send.NoopSign()
for i := 0; i < defRecvBuffSize; i++ {
err := stream.Send(msg2Send.Envelope)
if err != nil {
gotErr = true
break
}
}
assert.True(t, gotErr, "Should have failed because connection is closed")
}

func TestParallelSend(t *testing.T) {
Expand Down

0 comments on commit 5c04b00

Please sign in to comment.