Skip to content

Commit 5c04b00

Browse files
committed
[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 <[email protected]>
1 parent 7f114bb commit 5c04b00

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

gossip/comm/comm_test.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ func TestGetConnectionInfo(t *testing.T) {
297297
}
298298

299299
func TestCloseConn(t *testing.T) {
300-
t.Skip()
301300
t.Parallel()
302301
comm1, _ := newCommInstance(1611, naiveSec)
303302
defer comm1.Stop()
@@ -334,7 +333,20 @@ func TestCloseConn(t *testing.T) {
334333
}
335334
comm1.CloseConn(&RemotePeer{PKIID: common.PKIidType("pkiID")})
336335
time.Sleep(time.Second * 10)
337-
assert.Error(t, stream.Send(createGossipMsg().Envelope), "Should have failed because connection is closed")
336+
gotErr := false
337+
msg2Send := createGossipMsg()
338+
msg2Send.GetDataMsg().Payload = &proto.Payload{
339+
Data: make([]byte, 1024*1024),
340+
}
341+
msg2Send.NoopSign()
342+
for i := 0; i < defRecvBuffSize; i++ {
343+
err := stream.Send(msg2Send.Envelope)
344+
if err != nil {
345+
gotErr = true
346+
break
347+
}
348+
}
349+
assert.True(t, gotErr, "Should have failed because connection is closed")
338350
}
339351

340352
func TestParallelSend(t *testing.T) {

0 commit comments

Comments
 (0)