-
Notifications
You must be signed in to change notification settings - Fork 730
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
Make leadership-schedule test less flaky #4671
Make leadership-schedule test less flaky #4671
Conversation
72ec149
to
777a5a1
Compare
assertByDeadlineMCustom str deadline f | ||
else do | ||
H.annotateShow currentTime | ||
failMessage GHC.callStack $ "Condition not met by deadline: " <> str |
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.
Replace assertByDeadlineMCustom
with byDeadlineM
. The latter is better because it catches assertions and retries whereas an assertion in the block of the former will fail the test.
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.
byDeadlineM
will also take a poll interval so we don't needlessly poll too often which clutters the output.
8346dc5
to
6eff178
Compare
@@ -28,7 +28,7 @@ tests = pure $ T.testGroup "test/Spec.hs" | |||
-- [ H.ignoreOnMacAndWindows "leadership-schedule" Test.Cli.Alonzo.LeadershipSchedule.hprop_leadershipSchedule | |||
-- ] | |||
, T.testGroup "Babbage" | |||
[ H.ignoreOnMacAndWindows "leadership-schedule" Test.Cli.Babbage.LeadershipSchedule.hprop_leadershipSchedule |
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.
Re-enable leadership schedule test on MacOS.
df58013
to
05b7fbe
Compare
H.assert $ not (L.null expectedLeadershipSlotNumbers) | ||
|
||
leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime | ||
|
||
H.assertByDeadlineMCustom "Leader schedule is correct" leadershipDeadline $ do | ||
-- Leader schedule is correct | ||
H.byDeadlineM 10 leadershipDeadline $ do |
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.
"Condition not met by deadline"
is a somewhat opaque error. Can we implement a custom byDeadlineM
to maintain the custom error messages used by assertByDeadlineMCustom
?
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.
Will require this change: input-output-hk/hedgehog-extras#16
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.
Updated to include better assertion messages.
05b7fbe
to
0ae574f
Compare
H.assert $ not (L.null expectedLeadershipSlotNumbers) | ||
|
||
leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime | ||
|
||
H.assertByDeadlineMCustom "Leader schedule is correct" leadershipDeadline $ do | ||
-- Leader schedule is correct | ||
H.byDeadlineM 10 leadershipDeadline "Wait for a leadership at least as new as the highest one we expect" $ do |
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.
Why do we bother with this check if we already assert the following: H.assert $ L.length (expectedLeadershipSlotNumbers \\ leaderSlots) <= 1
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.
We have to wait until a time when all the slots we expect should exist. The assertion doesn't do the wait. Without the wait we would check too early and the slots won't be there.
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.
"Wait for a leadership at least as new as the highest one we expect"
is opaque to me. I think here some verbosity is fine because it will make failure diagnosis easier, especially to those unfamiliar with the code. What about "Wait for chain to surpass all expected leadership slots". And we can add a comment as follows: "We need enough time to pass such that the expected leadership slots generated by the leadership-schedule
command have actually occurred."
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.
Updated!
0ae574f
to
bd2d757
Compare
3141ca1
to
84de454
Compare
84de454
to
4281970
Compare
This PR replaces
assertByDeadlineMCustom
withbyDeadlineM
. The latter is better because it catches assertions and retries whereas an assertion in the block of the former will fail the test.byDeadlineM
will also take a poll interval so we don't needlessly poll too often which clutters the output.The test
Babbage.leadership-schedule
is re-enabled on MacOS.The binding
maxSlotExpected
is moved higher so it is not re-computed unnecessarily.