-
Notifications
You must be signed in to change notification settings - Fork 83
Implement a fake status client for testing #192
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
Implement a fake status client for testing #192
Conversation
Hi @tomasaschan. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
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.
It is not recommended the usage of the fakeClient from controller runtime (submariner-io/submariner-operator#1236)
It would be removed but the community ask for not to break their tests. (kubernetes-sigs/controller-runtime#768)
The recommendation is to use ENV Test instead to test the controllers. WDYT about we change this project to start to use EnvTest instead?
@camilamacedo86 Where can I read more about using ENV Test instead? Note that the |
@camilamacedo86 Also, see #1101 where the |
Hi @tomasaschan, It was undeprecated, however, still not recommended. See: https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/client/fake/doc.go#L30-L36 Also, this project is used in the kubebuilder as well. We can scaffold by using the declarative plugin. See the sample: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/project-v3-addon. Kubebuilder scaffold the suite test for the controllers using the ENV Test, see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v3-addon/controllers/suite_test.go In this way, if this project is providing test features, could we try to move forward here to use env test instead? WDYT? Could you please confirm and share where the fake client here would be used? /ok-to-test |
/ok-to-test |
@camilamacedo86 Two things 🙂
|
This does seem consistent with what we have already, so I am going to approve. I don't think bringing up a kube-apiserver can ever be the only test strategy; fault injection, or checking the actual calls made, is very difficult without a mock client. Personally, I have found the tests that bring up kube-apiserver seem to primarily testing kubebuilder & controller-runtime, and not the actual operator. I would prefer to see a lot more golden testing for operators - they are much more understandable, and tend to be much higher performance also :-) /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb, tomasaschan 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 this PR does / why we need it:
This adds a
FakeStatusClient
with noop implementations ofUpdate
andPatch
, to enable doing things likeclient.Status().Update(...)
in methods being tested.I don't know if there was any special reason this was not already in place, other than "it hadn't been needed yet" - if there are any special considerations that need to be taken care of when updating status, this PR might not be good enough. But given that
FakeClient.Update
and similar methods also justreturn nil
, this should probably be OK for most use cases.