Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection manager transition order test using IOSimPOR #3640

Merged
merged 3 commits into from
Mar 14, 2022

Conversation

coot
Copy link
Contributor

@coot coot commented Feb 28, 2022

This PR adds a quickcheck property test which validates order of connection manager transitions using IOSimPOR. It also fixes a connection manager bug discovered thanks to the new test.

Fixes #3613.

  • connection-manager-tests: test transition order
  • connection-manager: don't blindly override state
  • connection-manager-tests: code style

@coot coot requested a review from karknu as a code owner February 28, 2022 08:10
@coot coot added connection-manager Issues / PRs related to connection-manager io-sim-discovered Issue discovered by IOSim networking labels Feb 28, 2022
@coot coot requested a review from bolt12 February 28, 2022 08:10
@coot coot changed the title CM's transition order test using IOSimPOR Connection manager transition order test using IOSimPOR Feb 28, 2022
Comment on lines +1660 to +1693
case connState of
ReservedOutboundState -> do
let connState' = UnnegotiatedState provenance connId connThread
writeTVar connVar connState'
return ( Just $ mkTransition connState connState'
, Nothing
)
TerminatingState {} ->
return (Nothing, Nothing)
TerminatedState {} ->
return (Nothing, Nothing)
_ ->
return ( Nothing
, Just (CM.TrUnexpectedlyFalseAssertion
(RequestOutboundConnection
(Just connId)
(abstractState (Known connState))
)
)
)

traceWith trTracer (TransitionTrace peerAddr trans)
traverse_ (traceWith trTracer . TransitionTrace peerAddr) trans
traverse_ (traceWith tracer >=> evaluate . assert True)
mbAssertion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, is there an open issue for this found bug?

Copy link
Contributor Author

@coot coot Mar 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, instead I just added io-sim-discovered flag to this PR, there's just one bug which is described in the commit so it's should be enough.

Copy link
Contributor

@bolt12 bolt12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 😄

When we fork outbound connection handler we need to update the state to
`UnnegotiatedState`, but we should not do that blindly.  It could happen
that the connection broke and was put in `TerminatedState` (or
`TerminatingState`) in the meantime by the connection handler thread.

This bug was discovered by *IOSimPOR*.
@coot
Copy link
Contributor Author

coot commented Mar 14, 2022

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 14, 2022

Build succeeded:

@iohk-bors iohk-bors bot merged commit 62dee5b into master Mar 14, 2022
@iohk-bors iohk-bors bot deleted the coot/cm-io-sim-por-2 branch March 14, 2022 12:42
coot added a commit that referenced this pull request May 16, 2022
3640: Connection manager transition order test using IOSimPOR r=coot a=coot

This PR adds a quickcheck property test which validates order of connection manager transitions using *IOSimPOR*.  It also fixes a connection manager bug discovered thanks to the new test.

Fixes #3613.

- connection-manager-tests: test transition order
- connection-manager: don't blindly override state
- connection-manager-tests: code style


3662: Removed ST effects from IOSimPOR r=coot a=coot

ST effects are thread local, they never race with other steps.  This patch
reverts a previous fix commited in PR #3647.

Thanks for `IOSimPOR` we also found out that the transition:
`UnnegotiatedSt Inbound → TerminatingSt` should be valid, similarly to one for
outbound connections (see PR #3652, commit fbcb6aa).


Co-authored-by: Marcin Szamotulski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connection-manager Issues / PRs related to connection-manager io-sim-discovered Issue discovered by IOSim
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IOSimPOR version of CM valid transitions tests
2 participants