-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Scaffolded controller test needs fixing #639
Comments
/kind bug |
This comment has been minimized.
This comment has been minimized.
Actually, we cannot remove the "expect reconcile" part, because the scaffolded test reconciler writes requests to a request channel: kubebuilder/pkg/scaffold/controller/controllersuitetest.go Lines 83 to 93 in e904181
This will cause problems when Reconcile loop fails and requeues. While writing tests, we don't know whether the Reconcile will return an error or not; for example, we cannot expect an object's status to be updated after a single Reconcile -- it may eventually happen, but just not at the first Reconcile. It's possible to write tests that workaround this issue, by making sure Reconcile never fails in the tests, but that's pretty limiting and makes tests less robust. |
To overcome cached client issue, I added several |
@cizixs It is supported. Please check kubernetes-sigs/controller-runtime#327. I can probably use a non-cached client to address the 1st issue mentioned in #639 (comment) |
We no longer scaffold controller tests at the moment. Closing this, we'll keep it in mind as we add those back in. |
The scaffolded controller test has several issues:
mgr.GetClient()
instead of a client that directly reads from apiserver.kubebuilder/pkg/scaffold/controller/controllertest.go
Line 106 in e904181
Expect reconcile doesn't really do anything -- it should be removed. We only need to check some condition to happen, instead of a reconcile.Updated: Allow users to test a condition to eventually happen without having to expect Reconcile to happen first.kubebuilder/pkg/scaffold/controller/controllertest.go
Line 128 in e904181
kubebuilder/pkg/scaffold/controller/controllersuitetest.go
Line 67 in e904181
ginkgo
.@DirectXMan12
The text was updated successfully, but these errors were encountered: