-
Notifications
You must be signed in to change notification settings - Fork 39k
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
[client-go] Fake Dynamic Client #45431
[client-go] Fake Dynamic Client #45431
Conversation
encountered this while trying to write unit tests for the custom metrics adapter for Prometheus. I'm still in the progress of writing those tests and making sure this is sufficient, but I think it should be. |
0c86a51
to
08ed9f3
Compare
08ed9f3
to
773b17d
Compare
I don't think dynamic client should return an interface just to enable testing. I think the library that wants to test it's interaction with the dynamic client should assign the return value from |
That's what the "normal" clients do. I was under the impression that it was a pretty well-established pattern. |
773b17d
to
3263d91
Compare
That's true, it is a pattern. I have the opinion that it's a mistake, but not a completely terrible one. As it is the current pattern, it would fit it. I'm also not the reviewer (anymore). |
3263d91
to
8534f5d
Compare
I'd stick with the pattern we already have in place in the generated clientset, where there's a |
8534f5d
to
f5c47fe
Compare
I wanted to avoid a mass renaming, and wanted to follow the pattern established with |
f5c47fe
to
196ccc9
Compare
196ccc9
to
b325102
Compare
b325102
to
cdb35ad
Compare
ping @kubernetes/sig-api-machinery-pr-reviews when you get a chance |
/lgtm |
@smarterclayton approved? |
/approve no-issue |
1 similar comment
/approve no-issue |
/retest |
1 similar comment
/retest |
This looks like it might actually be an issue with some code having gotten updated in the mean time. I'll rebase shortly. |
This adds an interface form of dynamic.Client and dynamic.ResourceClient, making those two follow the general client conventions: `Interface` is an interface, and `Client` is the concrete implementation. `ClientPool` retains it's interface status. This allows us to create a fake implemenation of dyanmic.Interface, dynamic.ResourceInterface, and dynamic.ClientPool for testing.
c8472a3
to
5763227
Compare
ok, this should fix the test issue -- someone updated the signature of DynamicClient in the mean time ;-). |
5763227
to
90092a2
Compare
/retest |
golint failures:
|
wow, golint is supremely nitpicky |
I'm adding this to the golint_failures file, since it follows the pattern in other fake clients |
This introduces fake implementations of dynamic.Client and dynamic.ClientPool. They function similarly to the fake generated clientsets, since they're also based in testing.Fake.
90092a2
to
3e6bf24
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, deads2k, sttts Associated issue requirement bypassed by: deads2k, sttts The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue (batch tested with PRs 48224, 45431, 45946, 48775, 49396) |
This commit converts
"k8s.io/client-go/dynamic".Client
to an interface, and implements fake versions of bothClientPool
andClient
. This allows components which make uses of these clients to be tested in the same way that clientset-based components can be tested, using the standardtesting.Fake
machinery.Release note: