-
Notifications
You must be signed in to change notification settings - Fork 42
Migrate controller tests to envtest for future SSA compatibility #45
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
Conversation
9af4828 to
e2edf84
Compare
Signed-off-by: Matthew F Leader <mleader@redhat.com> add comment on adding scheme and rename client Signed-off-by: Matthew F Leader <mleader@redhat.com> shorten comment Signed-off-by: Matthew F Leader <mleader@redhat.com> comment Signed-off-by: Matthew F Leader <mleader@redhat.com> fix comment Signed-off-by: Matthew F Leader <mleader@redhat.com>
ca2e8ec to
5dda57f
Compare
|
This pull request has merge conflicts that must be resolved before it can be merged. @mfleader please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork |
Signed-off-by: Matthew F Leader <mleader@redhat.com>
Signed-off-by: Matthew F Leader <mleader@redhat.com>
Signed-off-by: Matthew F Leader <mleader@redhat.com>
|
LGTM I wonder though if we are now duplicating tests with https://github.com/llamastack/llama-stack-k8s-operator/tree/main/tests/e2e that run against a cluster |
That's definitely a good spot for tidying. It would be good to minimize the quantity of tests that require an instantiated cluster. I think it's worth creating an issue. |
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.
Nice work!
Signed-off-by: Matthew F Leader <mleader@redhat.com>
…amastack#45) Switched the controller tests over to use [envtest](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest) to create a controller runtime client instead of using the [fake client](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/client/fake). ### Why? The fake client doesn't support Server-Side Apply (SSA), which we'll need for the Kustomize overlay integration coming up. `envtest` gives us a real (mini) Kubernetes API. ### What changed: * The test now runs against a Kubernetes API thanks to `envtest`. This means we had to: * Get `envtest` up and running. * Swap out the controller runtime client test double for a real client. * Made sure the tests play nice with `KUBEBUILDER_ASSETS` so `envtest` can find the k8s binaries. * Sprinkled in some comments to explain the `envtest`-specific bits. * **Important:** The actual tests for what the Deployment and PVC do haven't changed. ### Heads up for next steps (separate PRs): * Updating `reconcilePVC` to use Kustomize with those dynamic overlays. * Switching PVC management to proper SSA (`client.Patch(..., client.Apply, ...)`), which these new `envtest` tests will be able to handle. Approved-by: leseb
…f06ae0 (llamastack#45) Signed-off-by: konflux-internal-p02 <170854209+konflux-internal-p02[bot]@users.noreply.github.com> Co-authored-by: konflux-internal-p02[bot] <170854209+konflux-internal-p02[bot]@users.noreply.github.com>
Switched the controller tests over to use envtest to create a controller runtime client instead of using the fake client.
Why?
The fake client doesn't support Server-Side Apply (SSA), which we'll need for the Kustomize overlay integration coming up.
envtestgives us a real (mini) Kubernetes API.What changed:
envtest. This means we had to:envtestup and running.KUBEBUILDER_ASSETSsoenvtestcan find the k8s binaries.envtest-specific bits.Heads up for next steps (separate PRs):
reconcilePVCto use Kustomize with those dynamic overlays.client.Patch(..., client.Apply, ...)), which these newenvtesttests will be able to handle.