-
Notifications
You must be signed in to change notification settings - Fork 698
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
Optimize tests that run fix_rules.py #10968
Conversation
Change callback functions which name starts with `has_` so that these functions won't load YAML files inside them but instead they will consume a loaded YAML as a parameter. This will separate the logic from YAML parsing allow us to reuse these functions in a different context in future. The functions are used as a callback therefore they all need to have the same interface but that can lead to unused parameters in some of the functions.
This commit adds a new subcommand `test_all` to the `fix_rules.py` script. The subcommand will execute all checks that are present in this script on all rules in the product. In other words, it works like executing all currently existing subcommands in `--dry-run` mode at once. We currently call the subcomands of this script in `--dry-run` mode in our CTest test. This change will allow us to merge these tests in a single test case.
We currently have multiple CTest tests that run `fix_rules.py`. Each of the tests runs a different subcommand of `fix_rules.py`. These tests test various aspects of rule.yml files. Each test tests all rule.yml files in a product. That means that each test loads all rule.yml files to perform the check. This isn't efficient and takes a lot of time. Thanks to the new subcommand `test_all` that has been introduced to `fix_rules.py` recently, we can run all checks at once. Therefore, we will merge all the CTest tests that run `fix_rules.py` to a single test. This way, we will parse each rule.yml file just once, and that will save us a lot of time during testing.
Code Climate has analyzed commit a429d02 and detected 4 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 53.3% (0.0% change). View more on Code Climate. |
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 for the PR! I can confirm that the tests still work and the number of tests is reduced.
I'm waving the code climate finings as this was how the code was before. We look to refactor this later. |
Description:
We currently have multiple CTest tests that run
fix_rules.py
, eg.fix_rules-empty_identifiers
,fix_rules-invalid_identifiers
,fix_rules-duplicate_subkeys
. There is 8 of them and each runs for ~ 10 seconds.Each of the tests runs a different subcommand of
fix_rules.py
. These tests test various aspects of rule.yml files. Each testtests all rule.yml files in a product. That means that each test loads all rule.yml files to perform the check. This isn't
efficient and takes a lot of time.
We will introduce a new subcommand
test_all
tofix_rules.py
. This subcommand can run all checks at once. It iterates over rules and on each rule it runs multiple checks. Each rule.yml is loaded and parsed just once.Therefore, we will merge all the CTest tests that run
fix_rules.py
to a single test. This way, we will parse each rule.yml file single time instead of 8 times during the test run, and that will save us a lot of time during testing.Rationale:
GitHub Actions CI speed up.
Review Hints:
Modify some rules so that the test is trigerred, for example, break ordering of items in prodtype key or break soorting of references in rule.yml. Then run
ctest --verbose -R fix_rules
inbuild
directory.