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

Additional check for not-leader slots in LeadershipSchedule tests #5110

Merged

Conversation

carbolymer
Copy link
Contributor

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)

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
Copy link
Contributor Author

@carbolymer carbolymer Apr 17, 2023

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

@carbolymer carbolymer force-pushed the mgalazyn/fix/check-for-missing-epochs-in-leadershipschedule branch from 5712fa8 to 45657ed Compare April 17, 2023 16:05
@carbolymer carbolymer added this pull request to the merge queue Apr 17, 2023
Merged via the queue into master with commit d8e0b71 Apr 17, 2023
@iohk-bors iohk-bors bot deleted the mgalazyn/fix/check-for-missing-epochs-in-leadershipschedule branch April 17, 2023 16:53
if k == "TraceNodeIsLeader"
then TraceNodeIsLeader k <$> (v .: "val" >>= (.: "slot"))
else fail $ "Expected kind was TraceNodeIsLeader, found " <> show k <> "instead"
data TraceNode
Copy link
Contributor

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.

Copy link
Contributor Author

@carbolymer carbolymer Apr 18, 2023

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:

  1. create another similar type, with the same fields, duplicate ToJSON instance
  2. rename the type, create two constructors TraceNodeIsLeader and TraceNodeNotLeader , both with fields slot and kind
  3. 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])
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants