From 5c04b004d0252398e1ac59742a3ae71054fbcd17 Mon Sep 17 00:00:00 2001 From: YACOVM Date: Mon, 24 Apr 2017 11:43:19 +0300 Subject: [PATCH] [FAB-3316] Reintroduce TestCloseConn back to CI 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 --- gossip/comm/comm_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gossip/comm/comm_test.go b/gossip/comm/comm_test.go index 274f015542c..1e2cfc09a9d 100644 --- a/gossip/comm/comm_test.go +++ b/gossip/comm/comm_test.go @@ -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() @@ -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) {