-
Notifications
You must be signed in to change notification settings - Fork 722
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
Add --shutdown-on-slot-synced test and ensure ExitSuccess #3670
Conversation
Just (ExceptionInLinkedThread _ eInner) | ||
| Just ExitSuccess <- fromException eInner | ||
-> throwIO ExitSuccess | ||
_ -> throwIO full |
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.
How does propagating ExitSuccess
this way change the observed behaviour of the program?
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've added info in the PR description. See point 2.
cardano-node/src/Cardano/Node/Run.hs
Outdated
@@ -105,6 +106,23 @@ runNode | |||
:: PartialNodeConfiguration | |||
-> IO () | |||
runNode cmdPc = do | |||
-- Workaround to ensure that the main thread throws an async exception on | |||
-- receiving a SIGTERM signal. | |||
#ifdef UNIX |
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.
Does this only work on POSIX?
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, so I've limited scope of the PR to posix, aiming to leave the windows behavior unchanged. I'm honestly not sure what the counterpart is on windows or if one even exits.
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.
The primary user of this is system-level benchmarking -- and we don't really run that on Windows, since that platform is wallet-only, @newhoggy.
So we're perfectly fine with #ifdef UNIX
Can you document in the PR how the test fails without the changes so it's easier to understand what this PR does to the behaviour of |
015c47e
to
1239b0d
Compare
I've removed one commit that is already in another PR: #3641 |
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.
Thanks a lot @DavidEichmann!
1239b0d
to
f3e2451
Compare
I've increased the timeout of the test while checking for termination every second in hopes that the test will succeed on CI. |
757ca4a
to
3d46a68
Compare
80f30c4
to
e22d290
Compare
I've added a new commit "Allow tests to specify custom node CLI options for local testnet" and used this to greatly simplify the test added in this PR. |
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.
Nice 👍. A couple of minor comments.
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE RecordWildCards #-} |
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.
Can we use NamedFieldPuns
instead? I find RecordWildCards
too opaque.
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 just get rid of it and use projection functions
mExitCodeRunning === Right ExitSuccess | ||
log <- H.readFile nodeStdout | ||
slotTip <- H.noteShow | ||
$ read @Integer |
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.
Let's also catch this potential exception here and fail properly. *** Exception: Prelude.read: no parse
can be a nightmare to debug.
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 sure what the "proper" way of handling this is, but I'll use fail
and explicit error messages.
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.
Apologies, I wasn't clear. I mean fail using failMessage
: https://github.com/input-output-hk/hedgehog-extras/blob/4190fe64c9269ff10cb7cb363b82c521b8e1093b/src/Hedgehog/Extras/Test/Base.hs#L128
So we can see in the output where the failure took place.
e22d290
to
8e13f1c
Compare
I had to increase the running time of the test as it seems that some times the test would finish without any log messages re. chain tip. |
…`ExitSuccess` This is needed to a achieve the correct exit code when using the --shutdown-on-slot-synced option
8e13f1c
to
980bdc5
Compare
Fixes #3646
This does 2 things:
--shutdown-on-slot-synced x
and checks that (A) the exit code is0
and that (B) the chain tip slot is close tox
.ExceptionInLinkedThread _ ExitSuccess
exception as an an unwrappedExitSuccess
exception. This means the process's exit code will be0
rather than1
(this is asserted by the new test).Without the changes of this PR, property 1.A fails (the exit code is
1
) but 1.B succeeds.