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

Scaffolded controller test needs fixing #639

Closed
janetkuo opened this issue Mar 19, 2019 · 6 comments
Closed

Scaffolded controller test needs fixing #639

janetkuo opened this issue Mar 19, 2019 · 6 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@janetkuo
Copy link
Member

janetkuo commented Mar 19, 2019

The scaffolded controller test has several issues:

@DirectXMan12

@DirectXMan12
Copy link
Contributor

/kind bug
/priority important-soon

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Mar 20, 2019
@Ready305

This comment has been minimized.

@janetkuo
Copy link
Member Author

janetkuo commented Apr 2, 2019

Actually, we cannot remove the "expect reconcile" part, because the scaffolded test reconciler writes requests to a request channel:

// SetupTestReconcile returns a reconcile.Reconcile implementation that delegates to inner and
// writes the request to requests after Reconcile is finished.
func SetupTestReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan reconcile.Request) {
requests := make(chan reconcile.Request)
fn := reconcile.Func(func(req reconcile.Request) (reconcile.Result, error) {
result, err := inner.Reconcile(req)
requests <- req
return result, err
})
return fn, requests
}

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.

cc @mengqiy @droot

@cizixs
Copy link

cizixs commented Apr 29, 2019

To overcome cached client issue, I added several time.Sleep statement for now. I wonder if there is a non-cached client for mgr?

@janetkuo @DirectXMan12

@mengqiy
Copy link
Member

mengqiy commented May 6, 2019

I wonder if there is a non-cached client for mgr?

@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)

@DirectXMan12
Copy link
Contributor

We no longer scaffold controller tests at the moment. Closing this, we'll keep it in mind as we add those back in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

No branches or pull requests

6 participants