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

Remove Kubebuilder Generated Tests #358

Merged
merged 3 commits into from
Jun 24, 2019
Merged

Remove Kubebuilder Generated Tests #358

merged 3 commits into from
Jun 24, 2019

Conversation

kensipe
Copy link
Member

@kensipe kensipe commented Jun 19, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:
/kind cleanup
/kind enhancement

What this PR does / why we need it:
Removes generated kubebuilder tests and TestMains

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that kubebuilder test harness actually brings a lot of value to the table. I wouldn't know how to mock the API server (or if it is even possible) and relying solely on SI tests is IMHO not an option. If anything, we should add more tests, especially for the controllers.

@jbarrick-mesosphere
Copy link
Member

I think that kubebuilder test harness actually brings a lot of value to the table. I wouldn't know how to mock the API server (or if it is even possible) and relying solely on SI tests is IMHO not an option. If anything, we should add more tests, especially for the controllers.

@zen-dog we do have efforts to increase our integration testing landing nearly concurrently to this (see KEP-0008 and KEP-0004), this is simply removing autogenerated tests that do nothing except for start the control plane and cause flakiness.

@zen-dog
Copy link
Contributor

zen-dog commented Jun 20, 2019

@zen-dog we do have efforts to increase our integration testing landing nearly concurrently to this (see KEP-0008 and KEP-0004), this is simply removing autogenerated tests that do nothing except for start the control plane and cause flakiness.

Two things:

  1. I believe relying solely on the SI is the wrong approach. These tests require provisioning actual clusters and are slow and expensive. As a general rule of thumb, one should test code at the lowest level possible.
  2. I don't have issues with removing the autogenerated stubs. However, I'm working on an instance_controller_test.go as we speak, so whatever issue @kensipe has with build tags and those stubs - won't we have it again, once I merge my test?

See this #363 for more context.

@jbarrick-mesosphere
Copy link
Member

I believe relying solely on the SI is the wrong approach. These tests require provisioning actual clusters and are slow and expensive. As a general rule of thumb, one should test code at the lowest level possible.

Yeah.... See: https://github.com/kudobuilder/kudo/blob/master/keps/0004-add-testing-infrastructure.md#tests

The test harness itself supports integration (using only a mocked etcd and kubernetes API) as well as end-to-end tests (for testing frameworks). You can also write Go-based integration and unit tests.

I don't have issues with removing the autogenerated stubs. However, I'm working on an instance_controller_test.go as we speak, so whatever issue @kensipe has with build tags and those stubs - won't we have it again, once I merge my test?

Nothing prevents you from writing these tests, this PR only removes these autogenerated stubs. They currently start the envtest environment for each of these stubs (each takes around 5 seconds), so it just adds wasted time as well as making it more likely for us to hit issues like #302.

We should of course fix flakes as they come up, but keeping these stubs around is not the way to do that IMO.

@jbarrick-mesosphere
Copy link
Member

jbarrick-mesosphere commented Jun 20, 2019

I don't have issues with removing the autogenerated stubs. However, I'm working on an instance_controller_test.go as we speak, so whatever issue @kensipe has with build tags and those stubs - won't we have it again, once I merge my test?

We have some tests that do this already that are not being removed: https://github.com/kudobuilder/kudo/blob/master/pkg/test/utils/kubernetes_test.go#L55

Though, note that your test could be written as a regular integration test using the KUDO test harness and doesn't actually need to be written in Go, see:

Those integration tests are run against the envtest environment and not a Kubernetes cluster.

@zen-dog
Copy link
Contributor

zen-dog commented Jun 20, 2019

hey currently start the envtest environment for each of these stubs (each takes around 5 seconds),

Agreed, let's remove the "unused" TestMains. However, my PR uses the one in instance_controller_test_suite so let's leave the instance controller tests out to not produce unnecessary conflicts /cc @kensipe

@jbarrick-mesosphere
Copy link
Member

I'd prefer if we could use the declarative test harness for writing your test. And leave this PR as is.

@kensipe kensipe merged commit 31bb65a into master Jun 24, 2019
@alenkacz alenkacz deleted the ken/remove-kubebuilder branch October 30, 2019 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants