Closed willie-yao closed 1 year ago
/assign
My 2c on how I think we should go about this effort to make the most of it:
That being said, I'd propose we do the following:
azure/
, so I'd prioritize looking for uncovered code elsewhere in the short-term.@willie-yao @CecileRobertMichon Please let me know if any of that is off-base, just looking to level-set before we get too deep in this effort.
IMO one of the important things with code coverage is to set a % overall of coverage baseline of where you are today and have CI enforcement to keep things at that % level. This way you're not allowing regression of the quality of code for new contributions.
After taking another pass through the codebase, it seems like there are several functions and important edge cases not being tested in many of the webhooks despite having a high code coverage %. I think ensuring that the webhooks are working as intended is a high priority.
Will also take a closer look at the controllers
package, which has overall lower code coverage but requires extensive use of mocks to test properly.
Wonder if we could use something like https://github.com/go-gremlins/gremlins to measure the effectiveness of tests to, not just coverage.
After taking a closer look at the codecov dashboard, I've listed a few findings about the overall code coverage of the project:
azure
package will be replaced due to the adoption of ASO. Thus, we should focus our efforts to other packages.Because of this, I've narrowed down the effort into two areas of the highest priority to be tested:
Going forward, I would like to focus our efforts on one of the two areas first. It would be easier to start with the webhooks as most of the test cases will be trivial. While the controller tests will be harder to implement due to extensive mocking, it has much less code coverage and is a critical part of the codebase. @CecileRobertMichon @nojnhuh @mboersma @dtzar and any others have any thoughts on this?
Edit: Will also use tools to calculate code churn in order to identify which files are used most often. This can be another metric to decide which files we should add tests to first.
- As pointed out by @nojnhuh, most files within the
azure
package will be replaced due to the adoption of ASO. Thus, we should focus our efforts to other packages.
@CecileRobertMichon made a good point in office hours last week about the value in having a solid set of baseline tests in azure/
before the ASO migration to catch regressions. I'm not sure that means that's all necessarily high priority, but I think we can at least keep the ASO migration from being a deterrent to adding test coverage there. It's probably wise to make auditing and improving coverage in an existing implementation one of the first steps in migrating a service over to ASO.
Closed as all overall tasks have been completed. Sub-issues will be created to track unit test progress in each package.
webhooks: #3648 controllers: #3649
/kind cleanup
Detailed Description
This is a larger "Epic" issue that tracks overall efforts to improve and increase the current code coverage in CAPZ. The current state of code coverage can be viewed on the codecov dashboard. The current average unit tests coverage sits at about 40%.
Goals & Desired Outcomes
UPDATE This issue will be closed once all overall tasks are completed. The goal has shifted from increasing code coverage overall to improving the metrics and visibility of code coverage across the project. Efforts to increase code coverage for specific packages will be moved to its own separate issue to decrease the scope of this issue.