-
Notifications
You must be signed in to change notification settings - Fork 739
Do not merge: Remove Integration Monad #6346
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
base: master
Are you sure you want to change the base?
Conversation
b99bb37 to
0bf6d79
Compare
0f61855 to
d7b60ca
Compare
|
|
||
| liftIOAnnotated :: (HasCallStack, MonadIO m) => IO a -> m a | ||
| liftIOAnnotated action = GHC.withFrozenCallStack $ | ||
| liftIO $ action `catch` (\(e :: SomeException) -> throwM $ exceptionWithCallStack e) No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is catch from Prelude right? So this should work with watchdog exceptions I think. Could you add a comment here that we're catching async exceptions here as well intentionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of copying code downstream. Have you given a thought how we could reconcile your changes with hedgehog-extras, so possibly we could avoid the duplication?
My main issue with that is having to fix issues in both places, because we're using similar code in cardano-cli as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open a PR.
| -- The port number if it is obtained using 'H.randomPort', it is firstly bound to and then closed. The closing | ||
| -- and release in the operating system is done asynchronously and can be slow. Here we wait until the port | ||
| -- is out of CLOSING state. | ||
| H.note_ $ "Waiting for port " <> show port <> " to be available before starting node" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a useful trace. I don't remember if we weren't experiencing hangups long time ago at this place. In general it would be nice to have a tracer available here so we could emit traces about the progress of the node startup.
| liftToIntegration :: RIO ResourceMap a -> H.Integration a | ||
| liftToIntegration r = do | ||
| rMap <- lift $ lift getInternalState | ||
| liftIOAnnotated $ runRIO rMap r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that be evalIO instead? Or at least evalIO . liftIOAnnotated?
| liftIOAnnotated $ runRIO rMap r | |
| H.evalIO $ runRIO rMap r |
I think regular liftIO (which inside liftIOAnnotated) was losing some location information for me when reporting in the hedgehog. I don't know if that's still the case here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, good catch
| -- Here we assume, very optimistically, that the user has already | ||
| -- instantiated it with a concrete topology file. | ||
| H.note_ $ "Could not decode topology file. This may be okay. Reason for decoding failure is:\n" ++ e | ||
| -- TODO: It is suspicious that this decoding can fail. Investigate further. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be irrelevant very soon, because non-p2p topology is gone and this double decoding will be removed in: https://github.com/IntersectMBO/cardano-node/pull/6331/files#diff-079ade366e18980b6232319946cc005904a8c865dadf467951da1d30f2069055R268
That's why it would be better to rebase this PR onto 10.6 integration PR. I expect you'll have a lot of conflicts.
The comment needs an update though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm waiting for the 10.6 PR to get merged into master so I will only have to rebase once.
| , mkConf | ||
| , mkConfigAbs | ||
| , mkConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we have mkConf, mkConfig and mkConfigAbs now. This is a bit confusing. I'm wondering if the naming could be improved here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed mkConf from the exports and added a haddock.
cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/SanityCheck.hs
Show resolved
Hide resolved
| (_,asyncA) <- asyncRegister_ (threadDelay 10_000_000) | ||
| let tId = asyncThreadId asyncA | ||
| return (s,tId) | ||
| afterForkedThread <- getCurrentTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI You can use https://hackage-content.haskell.org/package/hedgehog-extras-0.10.1.0/docs/Hedgehog-Extras-Test-TestWatchdog.html to verify if code paths were reached.
This differs from hedgehog-extras's asyncRegister function in that the thread is linked before it is cancelled.
568a7ac to
9709995
Compare
| Nothing -> error $ "missing \"bin-file\" key in plan component: " <> show component <> " in the plan in: " <> planJsonFile | ||
| [] -> error $ "Cannot find \"component-name\" key with the value \"exe:" <> pkg <> "\" in the plan in: " <> planJsonFile | ||
| Left message -> error $ "Cannot decode plan in " <> planJsonFile <> ": " <> message | ||
| where matching :: Component -> Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an old buggy version of binDist which sometimes is unable to find an executable in plan.json. A fixed one is here: https://github.com/input-output-hk/hedgehog-extras/blob/c1130836a55f662b17d2e86daae04362d65655e1/src/Hedgehog/Extras/Test/Process.hs#L305
9709995 to
c0c3365
Compare
c0c3365 to
4a2c1dc
Compare
4a2c1dc to
6806869
Compare
ffcf2d2 to
6806869
Compare
44b4f2f to
b31495b
Compare
b31495b to
2e4b895
Compare
2e4b895 to
43697cc
Compare
|
|
||
|
|
||
| -- | Runs an action in background, and registers its cancellation to 'MonadResource'. | ||
| asyncRegister_ :: HasCallStack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be upstreamed to hedgehog-extras too. In the end I think there is hardly a benefit of using evalM there which requires MonadTest constraint: https://github.com/input-output-hk/hedgehog-extras/blob/c1130836a55f662b17d2e86daae04362d65655e1/src/Hedgehog/Extras/Test/Concurrent.hs#L97
I'm not sure what would have happened to make async throw right away (resource exhaustion perhaps, but that would signal larger problems anyway).
| liftToIntegration :: (HasCallStack, MonadCatch m, MonadResource m, MonadTest m) | ||
| => (forall n. (MonadCatch n, MonadResource n, MonadUnliftIO n, MonadFail n) => n a) | ||
| -> m a | ||
| liftToIntegration act = do | ||
| internalState <- liftResourceT getInternalState | ||
| catch @_ @SomeException (liftIO $ runInternalState act internalState) (withFrozenCallStack $ failException . toException . stringException . displayException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have generalised liftToIntegration in the latest commit Generalise liftToIntegration so it's not tied to RIO or Integration. This way we could add it to hedgehog-extras together.
Small caveat: one has to foresee what constraints for act are needed upfront, otherwise GHC will not be happy.
We could use now a better (shorter preferably) name now.
| runRIO () $ createTestnetEnv | ||
| testnetOptions genesisOptions def | ||
| conf | ||
| withResourceMap (\rm -> void . runRIO rm $ cardanoTestnet testnetOptions conf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage over:
| withResourceMap (\rm -> void . runRIO rm $ cardanoTestnet testnetOptions conf) | |
| void . runResourceT $ cardanoTestnet testnetOptions conf |
?


Description
Remove
Integrationmonad from functions that we also want to use outside of property tests.Introduce annotated exceptions (via
liftIOAnnotated) where theIntegrationmonad has been removed in order to preserve debugging information.Checklist
See Runnings tests for more details
CHANGELOG.mdfor affected package.cabalfiles are updatedhlint. See.github/workflows/check-hlint.ymlto get thehlintversionstylish-haskell. See.github/workflows/stylish-haskell.ymlto get thestylish-haskellversionghc-9.6andghc-9.12Note on CI
If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.