-
Notifications
You must be signed in to change notification settings - Fork 431
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
Add unit tests to azuremanagedcontrolplane reconciler #4303
Add unit tests to azuremanagedcontrolplane reconciler #4303
Conversation
a63149b
to
fabe9e8
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #4303 +/- ##
==========================================
+ Coverage 59.73% 60.45% +0.71%
==========================================
Files 192 191 -1
Lines 19303 19201 -102
==========================================
+ Hits 11531 11608 +77
+ Misses 7142 6949 -193
- Partials 630 644 +14 ☔ View full report in Codecov by Sentry. |
/ok-to-test |
/retest |
fabe9e8
to
282f237
Compare
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 your great work on this @troy0820! This is some really good stuff, but I might have a comment on the approach to this PR. This PR modifies many of the Azure services, which are in the middle of being refactored to use ASO in #3402 rather than the Azure SDK for Go. I'm not entirely sure if the same logic would translate to the new way of structuring services, as services will no longer have their own CreateOrUpdate functions.
Also, I'm not sure if those changes are entirely necessary. If the goal is to pass in scopes to reconcileNormal
, you can create them manually like how the azuremachine reconciler test does it: https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/main/controllers/azuremachine_controller_test.go#L338
This is definitely my bad as I misunderstood your proposal to use mocks, so I'm super sorry for misleading you! Do you think the approach used in the azuremachine_controller_test.go
would work for your case?
This doesn't change any of the logic that exists but makes the As far as the test in question, I would really only need to do the patch method for the I didn't want to use the mock for the type so I can follow the path in the method TLDR; I will remove the client mocks and test for the |
/hold |
aef204c
to
3ef9b57
Compare
/hold cancel |
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.
Looks good pending a few nits! Thanks for your patience here and I apologize again that the mocks didn't work out. I think we can still use them as a reference though in the future once ASO is implemented!
3ef9b57
to
454d632
Compare
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.
/lgtm
Great work @troy0820! 🚀
LGTM label has been added. Git tree hash: 4f52c269e6df7b61755a4a4a20ef8153edd697cf
|
9a3f61f
to
4e8dcc9
Compare
4e8dcc9
to
ced5d1c
Compare
Signed-off-by: Troy Connor <[email protected]>
ced5d1c
to
2c6ae38
Compare
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.
/lgtm
Thanks @troy0820!
LGTM label has been added. Git tree hash: 5d5d8f46ee6fa7a668fc489c3f47ff9628861960
|
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nojnhuh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This will increase coverage around the controller/reconciler code.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #4290
Special notes for your reviewer:
This test is marked as an error happening for the following reasons. When it hits the path to
StoreClusterInfo
it cannot create a remote client because that call is trying to reach out to do this. This is expected and not meant to derail the effort around coverage. However, this doesn't show the successful path around thereconcileNormal
. There are many functions/methods that I had to extract and refactor to become testable to reduce the level of abstraction around how nested theNew
funcs are within certain places where I can't inject but patch as done in a previous PR and as well as done here.I did create new mocks to test the clients that we export in the services package
AzureClient
which held azure-sdk-for-go clients and added coverage around this as well.I left the commits as a single point of reference if you want to review this within the context of the commits, however I can squash if this meets the satisfaction of the maintainers.
Also, the test for
CreateOrUpdateAsync
end in error (not failing) because the poller that is returned is something that I cannot inject toEXPECT
on the return value. The call cannot be done because the return value for runtime.Poller[] is not something that the azure-sdk-defined and cannot make that interface return value a thing to utilize in the test.TODOs:
Release note: