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

Allow unittesting indexes on the cache-backed reader #657

Open
alvaroaleman opened this issue Oct 23, 2019 · 9 comments
Open

Allow unittesting indexes on the cache-backed reader #657

alvaroaleman opened this issue Oct 23, 2019 · 9 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Milestone

Comments

@alvaroaleman
Copy link
Member

Currently, the only way of testing if:

  • An index actually gets added to the cache
  • Using the index yields the expected result

is to use envtest, which spins up an etcd and apiserver. Doing so works fine, but requires more setup (the binaries must be available) and has a decent chance of flaking in CI, e.G. due to CPU starvation.

It would be nice if there was a way to test the two cases above via pure unittests.

Discussion originally started here: kubernetes/test-infra#14830 (comment)
/kind feature

@DirectXMan12
Copy link
Contributor

I'm all ears for a good way to do this

@alvaroaleman
Copy link
Member Author

@DirectXMan12 So what I had in mind would be something like:

WDYT?

@DirectXMan12
Copy link
Contributor

All methods on that manager except for GetClient and GetFieldIndexer will error or panic

:-/ I'm not a huge fan of this, but if we can't figure out a better method, it might be a viable way forward. Usually, this means that there's an overbroad interface, but in this case it's "set of available dependencies", so it might be fine.

@vincepri
Copy link
Member

/help
/priority backlog

@k8s-ci-robot
Copy link
Contributor

@vincepri:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help
/priority backlog

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added priority/backlog Higher priority than priority/awaiting-more-evidence. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Feb 21, 2020
@vincepri vincepri added this to the Next milestone Feb 21, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 21, 2020
@vincepri
Copy link
Member

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 21, 2020
@alvaroaleman
Copy link
Member Author

For posterity, I did built something for this out-of tree some time ago that might be used as inspiration to add this to controller-runtime directly: https://github.com/kubernetes/test-infra/blob/682727078f0c86e556d9d766bd4ffbf3e2980a56/prow/tide/tide_test.go#L3836-L3923

@alvaroaleman
Copy link
Member Author

It should also be mentioned that the "interact with cluster" part has been decoupled form the "run stuff" part and moved into pkg/cluster from pkg/manager in the meantime. So having something like a pkg/cluster/fake might be a good way forward here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

5 participants