Test Optimization Proposal (SC-736)#1188
Merged
Merged
Conversation
TheRealFalcon
suggested changes
Jan 13, 2022
Contributor
TheRealFalcon
left a comment
There was a problem hiding this comment.
Good idea. These tests have bugged me in the past too.
My only concern is when it comes to separating concerns, I'm not a big fan of having functions that combine taking cli/argparse args with additional logic, because those arguments can pretty hard to construct outside of calling from the CLI. That makes reuse and testing harder.
Can we instead have the render_cloudcfg function take arguments like variant, template, and output_file (or whatever), and leave all of the argument parsing where it was?
Member
Author
|
Good feedback, I agree. Fixed in the latest commit. |
TheRealFalcon
approved these changes
Jan 14, 2022
Contributor
TheRealFalcon
left a comment
There was a problem hiding this comment.
Looks good, thanks!
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional Context
Pytest consistently shows the parametrized template rendering tests as the most time-consuming in the unit test suite (0.5s per test). Profile analysis shows that nearly all of the time spent is in one-time setup tasks (importing modules). Currently each test invokes a subprocess to execute the test.
This change should be non-functional. It simply moves the rendering code into the
templatermodule and uses function calls in place of spawning a new process per parametrized test (function calls share the setup cost of module import). A single test that calls the tool as a subprocess was added to maintain test coverage.This saves ~7s on my machine (which is 13% of the total unittest runtime).