-
Notifications
You must be signed in to change notification settings - Fork 720
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
Additional check for not-leader slots in LeadershipSchedule tests #5110
Additional check for not-leader slots in LeadershipSchedule tests #5110
Conversation
getRelevantLeaderSlots :: FilePath -> Int -> H.PropertyT (ReaderT IntegrationState (ResourceT IO)) [Int] | ||
getRelevantLeaderSlots poolNodeStdoutFile slotLowerBound = do | ||
getRelevantSlots :: FilePath -> Int -> H.PropertyT (ReaderT IntegrationState (ResourceT IO)) ([Int], [Int]) | ||
getRelevantSlots poolNodeStdoutFile slotLowerBound = 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.
This function now returns all slots seen in the logs. This is useful to double check if we didn't omit any slot, especially those with TraceNodeNotLeader
entries in logs.
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.
Are TraceNodeIsLeader
and TraceNodeNotLeader
definitely the only two TraceNode
kinds?
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's also TraceNodeCannotForge
- should we check for it as well?
5712fa8
to
45657ed
Compare
if k == "TraceNodeIsLeader" | ||
then TraceNodeIsLeader k <$> (v .: "val" >>= (.: "slot")) | ||
else fail $ "Expected kind was TraceNodeIsLeader, found " <> show k <> "instead" | ||
data TraceNode |
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 the rename? TraceNodeIsLeader
was a good name.
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 needed a type which would also capture TraceNodeNotLeader
. So my options were:
- create another similar type, with the same fields, duplicate
ToJSON
instance - rename the type, create two constructors
TraceNodeIsLeader
andTraceNodeNotLeader
, both with fieldsslot
andkind
- rename the type and the constructor, add
isLeader
flag
3rd looked like the least amount of duplication. Which alternative would you propose?
|
||
instance FromJSON Kind where | ||
parseJSON = Aeson.withObject "Kind" $ \v -> | ||
Kind <$> v .: "kind" | ||
|
||
getRelevantLeaderSlots :: FilePath -> Int -> H.PropertyT (ReaderT IntegrationState (ResourceT IO)) [Int] | ||
getRelevantLeaderSlots poolNodeStdoutFile slotLowerBound = do | ||
getRelevantSlots :: FilePath -> Int -> H.PropertyT (ReaderT IntegrationState (ResourceT IO)) ([Int], [Int]) |
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.
Returning something like data LeadershipSlots = LeadershipSlots { leaderSlots :: [Int], notLeaderSlots :: [Int] }
would make this more readable.
This change introduces additional check for not-leader slots in the tests.
related discussion: https://input-output-rnd.slack.com/archives/CR599HMFX/p1681424630819669 (internal access only)