-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
fake client for unit testing #524
Comments
That would be a great feature. Im using go-client for k8s and im able to do integration tests in memory. Saves a lot of time. |
is this on the radar / roadmap? it would be extremely useful! |
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 |
I have to write some automation using Python (I wish it could be in Golang) and a fake client or, at the very least, some documentation on how to write tests when using this library would be helpful. Can a maintainer at least touch on this subject? |
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 |
Any exact roadmap on this one? |
Totally agree. Usually I just look at a repos unit tests to see how the contributors have mocked out their class etc but blank stubs when look in the test folder. Any update on this one. |
just saying that i need that too, i'm currently mocking my usages of the API and this is alot of work |
/assign |
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 |
Just been bitten by this too. I wrote an ad-hoc fake for the things I use. But not very happy with that. Looking online I couldn't find any evidence of anyone doing anything better 😢 In some cases I'd just write integration tests, but my current scenario isn't really easy to run as an integration test. |
Back to Go it is |
+1 for this feature - one option may be like |
I agree this would be useful if provided first-hand by the client. I've been able to streamline mocked responses by doing things like: class FakeResponse:
def __init__(self, filename):
with open(filename) as file:
self.data = file.read()
configmaps = client.CoreV1Api().api_client.deserialize(FakeResponse('my-fixture.json'), 'V1ConfigMapList') I build the fixtures by using kubectl:
Hope this helps someone fill the gap until this library has a better solution. |
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. |
@palnabarun it looks you self-assigned this. It seems like a tough nut to crack. Have you made any progress? Is there anything I can do to help? |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
+1 for this feature very useful |
/remove-lifecycle rotten |
@kdebisschop -- No, I haven't been able to devote time to this. In the meanwhile, if you or anyone wants to take a dig at it, please feel free to do so and update the findings here. |
/lifecycle frozen (applying the label to not mark it as stale again until we have some mock designs) |
That would be an awesome feature for operator testing. |
@askreet Am I reading this right that you're loading the yaml into a json or was that a typo? |
I would appreciate this feature too. |
Any progress on this? |
Yes, this would be great if it's in progress |
+1 on this |
another +1 on this |
another +2 |
Kubernetes's client-go includes a powerful "fake" library (https://godoc.org/k8s.io/client-go/kubernetes/fake), which provides a mock API client that handles reads and writes without a cluster. It enables unit testing of code that uses client-go. This blog post has examples of how it's used: https://medium.com/@e_frogers/unit-testing-with-kubernetes-client-go-283b11aaa7db
Could this library provide a similar mock interface? I think a fake
kubernetes.client.ApiClient
that works in-process instead of over HTTP (like the go fake client) would be perfect: it would be injectable into the existing clients to allow full testing.The text was updated successfully, but these errors were encountered: