-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reconsider deprecation of pkg/client/fake #768
Comments
/assign @DirectXMan12 |
As an aside, I'm happy to sign up to help maintain and support the fake client if it is a matter of needing someone to do so. |
For what it's worth we rely a lot on the fake client in https://github.com/elastic/cloud-on-k8s. With a quick and dirty Doing the same by spawning a local apiserver + etcd env test would make running unit tests much longer and happened to be a bit unreliable in busy CI environments. Obviously this does not prevent us from also running integration/E2E tests with a real Kubernetes environment. |
We talked about this a bit at the in-person meeting @ kubecon. The notes are on the kuebuilder ML for reference. TL;DR:
|
It sounds like you are reconsidering deprecating fakeClient, which is great. But we wanted to put on the record why fakeClient is important to us. Removal of fakeClient would be very disruptive to our team (Greenplum for Kubernetes). We do extensive test driven development, and currently have 108 test cases that use either
https://engineering.pivotal.io/post/gp4k-kubebuilder-tdd/ func BenchmarkEnvtest(b *testing.B) {
for i := 0; i < b.N; i++ {
testEnv := &envtest.Environment{}
if _, err := testEnv.Start(); err != nil {
b.Error(err)
}
if err := testEnv.Stop(); err != nil {
b.Error(err)
}
}
}
|
…eases 🏃 use latest beta releases of cr/ct
Similarly my team has test coverage metrics that need to be hit, often times getting over that hump means covering a few lines that handle errors on |
/kind design We're holding off deprecating the fake client for the time being. We'll need design documents and folks that can maintain the client going forward. |
/priority important-longterm |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
FWIW, I have written several test frameworks/harnesses that execute unit tests with I find |
So I think at the moment, the consensus that we have (which probably needs to be written in the deprecation comment) is that we're gonna keep fake client around, but we want to overhaul it a bit to be a little less clunky in certain areas. |
As stated at controller-runtime docs ([1], [2]) FakeClient is going to be deprecated at 1.0.0, re-implementation of controller-runtime client that's is not being maintained and missing features, the replacement is envtest. The envtest do a etcd/kube-apiserver binaries start/stop and allow you to prepare a real runtime-controller client or k8s clientset, allowing you to test the code with a real client but without a full cluster. Another interesting features is that with some flag setting same tests can be run at a proper cluster. [1] https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/client/fake [2] kubernetes-sigs/controller-runtime#768 (comment) Signed-off-by: Quique Llorente <ellorent@redhat.com>
As stated at controller-runtime docs ([1], [2]) FakeClient is going to be deprecated at 1.0.0, re-implementation of controller-runtime client that's is not being maintained and missing features, the replacement is envtest. The envtest do a etcd/kube-apiserver binaries start/stop and allow you to prepare a real runtime-controller client or k8s clientset, allowing you to test the code with a real client but without a full cluster. Another interesting features is that with some flag setting same tests can be run at a proper cluster. [1] https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/client/fake [2] kubernetes-sigs/controller-runtime#768 (comment) Signed-off-by: Quique Llorente <ellorent@redhat.com>
Replace FakeClient with envtest As stated at controller-runtime docs ([1], [2]) FakeClient is going to be deprecated at 1.0.0, re-implementation of controller-runtime client that's is not being maintained and missing features, the replacement is envtest. The envtest do a etcd/kube-apiserver binaries start/stop and allow you to prepare a real runtime-controller client or k8s clientset, allowing you to test the code with a real client but without a full cluster. Another interesting features is that with some flag setting same tests can be run at a proper cluster. [1] https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/client/fake [2] kubernetes-sigs/controller-runtime#768 (comment) Signed-off-by: Quique Llorente <ellorent@redhat.com>
- remove the deprecation warning as per issue kubernetes-sigs#768 - minor typo fixes
- remove the deprecation warning as per issue kubernetes-sigs#768 - minor typo fixes
* add a known limitations section to `fake.Client` - remove the deprecation warning as per issue #768 - minor typo fixes * fixing comments from PR * reword the limitation around injectable errors * Update pkg/client/fake/doc.go Co-authored-by: Vince Prignano <vince@vincepri.com> * Update pkg/client/fake/doc.go Co-authored-by: Vince Prignano <vince@vincepri.com> Co-authored-by: Vince Prignano <vince@vincepri.com>
When I transferring For example, my controller can react differently to the status of the k8s job. Then, by using the But The above finding is based on my testing. If the |
You should be able to set the status within Eg Call |
@JoelSpeed |
Please do not deprecate pkg/client/fake as using real environment for unit tests creates lots of issues with writing unit tests. Our current project, one of which is CRD controller currently has over 700+ unit tests and their execution time is about 12 seconds. |
It appears fake client does not support listing object with options client.MatchingFields and client.MatchingFieldsSelector. If this is true then maybe the "limitations" in the doc should be expanded to include these missing features in the fake client. |
controller-runtime v0.6.4 has a deprecation on `pkg/client/fake` which makes `golangci-lint` complain. This deprecation was reversed as per kubernetes-sigs/controller-runtime#768 and no longer exists in later releases. Add a `nolint` tag to skip this check until we update to a newer `controller-runtime`.
controller-runtime v0.6.4 has a deprecation on `pkg/client/fake` which makes `golangci-lint` complain. This deprecation was reversed as per kubernetes-sigs/controller-runtime#768 and no longer exists in later releases. Add a `nolint` tag to skip this check until we update to a newer `controller-runtime`.
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
/remove-lifecycle stale I'm using fake-client to synthesise particular ordering of events arriving; a real api-server cannot do this. |
I think we should probably close this issue, the Fake client isn't deprecated anymore and the new builder syntax has fixed some of the worst problems. I think any remaining issues should move to their own tickets so users aren't misled by the history here. |
Can you post a link to the commit/PR where it was un-deprecated please? |
We're still looking for the fake client codebase, if anyone is interested please open a PR with a new OWNERS file |
This was undeprecated in #1101, I don't think there is anything left to do here. As Vince mentioned, if you are interested in owning some or all of the fake client, please add yourself to an OWNERS file there. |
I went ahead and started a PR to add an OWNERS file and related OWNERS_ALIASES for the fake client here: #1494 I started by adding just myself, but happy to add others who may be interested in helping maintain the fake client as well. |
Currently
pkg/client/fake
is marked as Deprecated and thatpkg/envtest
should be used for all testing by v1.0.0, however there are use cases whereenvtest
is not a proper replacement for the fake client.For example, if using Test Driven Development(TDD) to build functionality with a controller-runtime based controller it is quite painful to debug issues with the controller implementation. Rather than just running the tests using a debugger such as delve, it becomes necessary to either debug the controller implementation using printf-style debugging or one would have to somehow wire up a remote debugger.
Instead, I believe a better approach would be to document the limitations and use cases for using the fake client rather than removing it.
The text was updated successfully, but these errors were encountered: