-
Notifications
You must be signed in to change notification settings - Fork 584
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
Increase unit test coverage for AWSCluster controller #3073
Increase unit test coverage for AWSCluster controller #3073
Conversation
/area testing |
b5df3c2
to
23746ad
Compare
/test ? |
@Ankitasw: The following commands are available to trigger required jobs:
The following commands are available to trigger optional jobs:
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/retest |
29d2813
to
e74461e
Compare
3fadc84
to
9f7f2c6
Compare
I am confused by this statement. I've used both fakeClient and envTest before and know that there are pros and cons of using one vs. another. See https://cluster-api.sigs.k8s.io/developer/testing.html?highlight=envtest#envtest. However, I don't think the choice affects the number of mocking calls. Could you help me understand what mocking calls were avoided by using a fakeClient in TestAWSClusterReconcileOperations? |
For integration tests, we should define couple of realistic scenarios. And checking conditions to see if they are as expected is a good signal. The scenarios I am thinking are: For unhappy path: @pydctw please add further suggestion on the unhappy path testing. |
@sedefsavas For happy path, we already have delete scenario in PR, and the unmanaged VPC test case covers happy path just that it wont reconcile VPC, rest all flows it goes through. Do you suggest to add separate case to PR to test happy path fully? |
@pydctw If you check mocking in |
@Ankitasw, first of all, thanks for all the hard work and great discussion. I had an impression that envTest is a preferred way and CAPI is moving away from fakeClient but after more discussion with some folks (@fabriziopandini, @yastij, @sedefsavas), the recommendation is to pick a right approach depending on test cases. You probably know but to summarize the pros and cons of two approaches here - fakeClient
envTest
What I was trying to ask here was the whys of choosing fakeClient vs. envTest for different unit tests (not across unit vs. integration tests). As long as we understand tradeoffs of using fakeClient vs. envTest and picks an appropriate one, I am ok with the choices. And if we change our mind, we can always iterate and refactor later 😄 |
As discussed, let's split the integration test out of this PR so that we can merge unit tests first. |
@pydctw I hope I answered your question correctly here 😄
Thanks @pydctw I hope the current tests are ok for now and I agree we can always refactor it later based on what is good for our tests and how good is the maintainability of mocks
I will do that |
9f7f2c6
to
d0d508b
Compare
The scope of the PR is now changed, added separate PR for integration tests |
/lgtm |
@Madhur97: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sedefsavas 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 |
What type of PR is this?
/area testing
What this PR does / why we need it:
This PR increases the unit tests coverage for AWSCluster controller. All the scenarios covered are listed here.
Coverage of
controllers
pkg increased from 42.5% to 60%.Which issue(s) this PR fixes (optional, in fixes #(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #2910
Special notes for your reviewer:
Plan to submit a separate PR per each controller.
Checklist:
Release note: