Skip to content

Commit

Permalink
connection-manager: fix test
Browse files Browse the repository at this point in the history
When running connection manager with two outbound connection, the second
overlapping with the first one we now do (in the specified order):

* `unregisterInboundConncection`: `TimeoutExpired` transition
* `unregisterOutboundConnection`: `DemotedToCold^{Duplex}_{Local}
                                    : OutboundState df
                                    → PreTerminatingState df`
   which terminates the connection after reset delay (5s)

Rather than the other way around, which would do:

* `unregisterOutboundConnection`: `DemotedToCold^{Duplex}_{Local}
                                    : OutboundState df
                                    → InboundIdleState df`
* `unregisterInboundConnection`: `DemotedToCold^{Duplex}_{Remote}
                                    : InboundIdleState df
                                    → TerminatingState`
   which terminates the connection without a delay

This change is needed because in the second case the connection is
closed and the test environment is expected to return an fd, but
since the schedule for the second connection has set 'siExists' to
'True' an fd is not present, which results in test environment failure.

Another reason to switch the order is that the second case is already
tested when there's an inbound connection.
  • Loading branch information
coot committed Jun 8, 2021
1 parent 51a7e03 commit fa3d4a4
Showing 1 changed file with 16 additions and 11 deletions.
Expand Up @@ -1995,16 +1995,19 @@ prop_connectionManagerSimulation (SkewedBool bindToLocalAddress) scheduleMap =
case seActiveDelay conn of
Left _ -> killThread (hThreadId handle)
Right _ -> do
(res, _) <-
unregisterOutboundConnection
connectionManager addr
`concurrently`
(when ( not (siReused (seExtra conn))
&& seDataFlow conn == Duplex ) $
void $
unregisterInboundConnection
connectionManager addr
)
when ( not (siReused (seExtra conn))
&& seDataFlow conn == Duplex ) $
-- we need to perform the @TimeoutExpired@
-- transition, in order for
-- 'unregisterOutboundConnection' to be
-- successful.
void $
unregisterInboundConnection
connectionManager addr

res <-
unregisterOutboundConnection
connectionManager addr
case res of
UnsupportedState st ->
throwIO (UnsupportedStateError
Expand Down Expand Up @@ -2105,8 +2108,10 @@ prop_connectionManagerSimulation (SkewedBool bindToLocalAddress) scheduleMap =
-- will fail.
Just (SomeConnectionManagerError e@ImpossibleConnection {}) -> throwIO e
Just (SomeConnectionManagerError e@ImpossibleState {}) -> throwIO e
-- the test environment can requests outbound connection when there is
-- one in 'PreTerminatingState'
Just (SomeConnectionManagerError (ForbiddenOperation _
(OutboundIdleSt Unidirectional) _))
(OutboundIdleSt _) _))
-> pure ()
Just (SomeConnectionManagerError e@ForbiddenOperation {}) -> throwIO e
Just (SomeConnectionManagerError e@UnknownPeer {}) -> throwIO e
Expand Down

0 comments on commit fa3d4a4

Please sign in to comment.