Skip to content

Commit e4cffe0

Browse files
authored
Merge pull request #578 from alexppxela/test/acceptance-random-disconnected-peer
Acceptance test result must be predictable
2 parents bc6d66a + 216c3e3 commit e4cffe0

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

_test/ReflectorClient.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ def @reflector.waitConnectAction(cid)
6767
end
6868

6969
def @reflector.waitDisconnectAction(cid)
70-
socket = @sockets[cid]
71-
if IO.select([socket], nil, nil, 10) == nil then
72-
raise "Connection hangs after ten seconds."
73-
elsif !socket.eof? then
74-
raise "Expected disconnection, got data"
70+
begin
71+
socket = @sockets[cid]
72+
if IO.select([socket], nil, nil, 10) == nil then
73+
raise "Connection hangs after ten seconds."
74+
elsif !socket.eof? then
75+
raise "Expected disconnection, got data"
76+
end
77+
rescue Errno::ECONNRESET
78+
# Ignore, server has already disconnected the socket
7579
end
7680
end
7781

_test/ReflectorServer.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ def @reflector.waitConnectAction(cid)
5858
end
5959

6060
def @reflector.waitDisconnectAction(cid)
61-
if IO.select([@socket], nil, nil, 10) == nil then
62-
raise "Connection hangs after five seconds."
63-
elsif !@socket.eof? then
64-
raise "Expected disconnection, got data"
61+
begin
62+
if IO.select([@socket], nil, nil, 10) == nil then
63+
raise "Connection hangs after five seconds."
64+
elsif !@socket.eof? then
65+
raise "Expected disconnection, got data"
66+
end
67+
rescue Errno::ECONNRESET
68+
# Ignore, client has already disconnected the socket
6569
end
6670
end
6771

0 commit comments

Comments
 (0)