Skip to content
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

tests(notebook-controller): use the direct (uncached) client to drive tests #7663

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jiridanek
Copy link
Member

Description

This is in accordance with the recommendations in the Kubebuilder Book.

Note that we set up both a "live" k8s client and a separate client from the manager.
This is because when making assertions in tests, you generally want to assert against the live state of the API server.
If you use the client from the manager (k8sManager.GetClient), you'd end up asserting against the contents of the cache instead, which is slower and can introduce flakiness into your tests.
We could use the manager's APIReader to accomplish the same thing, but that would leave us with two clients in our test assertions and setup (one for reading, one for writing), and it'd be easy to make mistakes.

Note that we keep the reconciler running against the manager's cache client, though – we want our controller to behave as it would in production, and we use features of the cache (like indices) in our controller which aren't available when talking directly to the API server.

(https://book.kubebuilder.io/cronjob-tutorial/writing-tests)

And also in this discusion

… tests

Signed-off-by: Jiri Daněk <jdanek@redhat.com>
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign thesuperzapper for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant