Hi Stephen,
Testing controller interactions with pods, especially within a StatefulSet, can indeed be challenging.
EnvTest Examples:
I would like to suggest to check out examples generated with the DeployImage plugin [1] in Kubebuilder’s testdata, which can help manage status conditions set by the controller in tests. These examples illustrate how to use Envtest to observe status updates. Here are some useful links:
PS: Regarding the fake client, as you noted, it’s generally not recommended due to its limitations and it can be removed/deprecated any time on the future. More info: controller-runtime issue #768.
To address your need:
Based on your requirements, it sounds like you may benefit more from creating a full e2e integration test of your project rather than just testing the controller implementation. Kubebuilder scaffolds basic e2e tests to help users get started, allowing you to run kubectl commands that set predefined conditions (for example to create the Pods with the status and etc that you need) and observe the reconciliation of your project.
Here are a few relevant resources for e2e tests as examples:
Default Scaffolded e2e Tests: project e2e tests [4].
Kubebuilder Project e2e Tests: e2e tests implemented in Kubebuilder [5], used to validate its features and solutions.
GitHub Action Workflow for e2e Tests: test-e2e.yml [6], which provides a comprehensive CI setup to run these tests on any pull request. So that, it is possible to validate if the project will still working well after the changes.
I hope this helps! Let me know if you need further clarification or if there’s anything specific you’re aiming to test.
Also, please feel free to reach out via the Slack channel—join us on the #kubebuilder [7] channel.
Best regards,
Camila Macedo
--
You received this message because you are subscribed to the Google Groups "kubebuilder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubebuilder...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/kubebuilder/0e9342ac-643e-4234-a919-acfd4ed283fbn%40googlegroups.com.