Skip to content

Commit 9ce948f

Browse files
committed
Acceptance test result must be predictable
Signed-off-by: Alexandre Thibault <[email protected]>
1 parent ab15e58 commit 9ce948f

File tree

8 files changed

+40
-24
lines changed

8 files changed

+40
-24
lines changed

_test/Reflector.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def processLine(lineNum, line, body, cid)
6868
if body == "CONNECT"
6969
waitConnectAction(cid)
7070
elsif body == "DISCONNECT"
71-
waitDisconnectAction(cid)
71+
waitDisconnectAction(cid, false)
72+
elsif body == "DISCONNECT_OR_ALREADY_DISCONNECTED"
73+
waitDisconnectAction(cid, true)
7274
else
7375
raise "Syntax error: " + body
7476
end

_test/ReflectorClient.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ def @reflector.disconnectAction(cid)
6666
def @reflector.waitConnectAction(cid)
6767
end
6868

69-
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"
69+
def @reflector.waitDisconnectAction(cid, canBeDisconnectedByPeer)
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+
raise unless canBeDisconnectedByPeer
7579
end
7680
end
7781

_test/ReflectorServer.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,21 @@ def @reflector.waitConnectAction(cid)
5757
@server.waitConnectAction
5858
end
5959

60-
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"
60+
def @reflector.waitDisconnectAction(cid, canBeDisconnectedByPeer)
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 => e
68+
unless canBeDisconnectedByPeer
69+
raise
70+
end
6571
end
6672
end
6773

6874
end
69-
7075
def connectAction(s)
7176
if @socket == nil
7277
@socket = s

_test/ReflectorTestCase.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,14 @@ def reflector.waitConnectAction(cid)
181181
@econ += cid.to_s + "," + "eCONNECT" + "|"
182182
end
183183

184-
def reflector.waitDisconnectAction(cid)
185-
@cum += cid.to_s + "," + "eDISCONNECT" + "|"
186-
@edis += cid.to_s + "," + "eDISCONNECT" + "|"
184+
def reflector.waitDisconnectAction(cid, canBeDisconnectedByPeer)
185+
if canBeDisconnectedByPeer then
186+
@cum += cid.to_s + "," + "eDISCONNECT_OR_ALREADY_DISCONNECTED" + "|"
187+
@edis += cid.to_s + "," + "eDISCONNECT_OR_ALREADY_DISCONNECTED" + "|"
188+
else
189+
@cum += cid.to_s + "," + "eDISCONNECT" + "|"
190+
@edis += cid.to_s + "," + "eDISCONNECT" + "|"
191+
end
187192
end
188193

189194
def reflector.errorAction(lineNum, msg)

_test/definitions/server/fix50sp2/2f_PossDupOrigSendingTimeTooHigh.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ E8=FIXT.1.19=9935=334=449=ISLD52=00000000-00:00:00.00056=TW45=258=Sendin
1919
# logout message
2020
E8=FIXT.1.19=4935=534=549=ISLD52=00000000-00:00:00.00056=TW10=0
2121
I8=FIXT.1.135=534=449=TW52=<TIME>56=ISLD
22-
eDISCONNECT
22+
eDISCONNECT_OR_ALREADY_DISCONNECTED

_test/definitions/server/fix50sp2/2i_BeginStringValueUnexpected.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ E8=FIXT.1.19=6835=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=3011
88
I8=FIX.4.135=134=249=TW52=<TIME>56=ISLD112=id
99
E8=FIXT.1.19=7435=534=249=ISLD52=00000000-00:00:00.00056=TW58=Incorrect BeginString10=0
1010
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
11-
eDISCONNECT
11+
eDISCONNECT_OR_ALREADY_DISCONNECTED
1212

1313
iCONNECT
1414
I8=FIXT.1.135=A34=149=TW52=<TIME>56=ISLD98=0108=301137=9
@@ -17,4 +17,4 @@ E8=FIXT.1.19=6835=A34=149=ISLD52=00000000-00:00:00.00056=TW98=0108=3011
1717
# Send with incorrect begin string and don't respond to logout
1818
I8=FIX.4.135=134=249=TW52=<TIME>56=ISLD112=id
1919
E8=FIXT.1.19=7435=534=249=ISLD52=00000000-00:00:00.00056=TW58=Incorrect BeginString10=0
20-
eDISCONNECT
20+
eDISCONNECT_OR_ALREADY_DISCONNECTED

_test/definitions/server/fix50sp2/2k_CompIDDoesNotMatchProfile.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ E8=FIXT.1.19=8435=334=249=ISLD52=00000000-00:00:00.00056=TW45=258=CompID
1212
# logout message
1313
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0
1414
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
15-
eDISCONNECT
15+
eDISCONNECT_OR_ALREADY_DISCONNECTED
1616

1717
# TargetCompID is invalid
1818

@@ -28,7 +28,7 @@ E8=FIXT.1.19=8435=334=249=ISLD52=00000000-00:00:00.00056=TW45=258=CompID
2828
# logout message
2929
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0
3030
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
31-
eDISCONNECT
31+
eDISCONNECT_OR_ALREADY_DISCONNECTED
3232

3333
# SenderCompID and TargetCompID is invalid
3434

@@ -44,4 +44,4 @@ E8=FIXT.1.19=8435=334=249=ISLD52=00000000-00:00:00.00056=TW45=258=CompID
4444
# logout message
4545
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0
4646
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
47-
eDISCONNECT
47+
eDISCONNECT_OR_ALREADY_DISCONNECTED

_test/definitions/server/fix50sp2/2o_SendingTimeValueOutOfRange.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ I8=FIXT.1.135=034=249=TW52=<TIME-121>56=ISLD
1111
E8=FIXT.1.19=9935=334=249=ISLD52=00000000-00:00:00.00056=TW45=258=SendingTime accuracy problem372=0373=1010=0
1212
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0
1313
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
14-
eDISCONNECT
14+
eDISCONNECT_OR_ALREADY_DISCONNECTED
1515

1616
# SendingTime is too large, reject
1717

@@ -26,4 +26,4 @@ I8=FIXT.1.135=034=249=TW52=<TIME+121>56=ISLD
2626
E8=FIXT.1.19=9935=334=249=ISLD52=00000000-00:00:00.00056=TW45=258=SendingTime accuracy problem372=0373=1010=0
2727
E8=FIXT.1.19=4935=534=349=ISLD52=00000000-00:00:00.00056=TW10=0
2828
I8=FIXT.1.135=534=349=TW52=<TIME>56=ISLD
29-
eDISCONNECT
29+
eDISCONNECT_OR_ALREADY_DISCONNECTED

0 commit comments

Comments
 (0)