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

Add helper wrapping envtest #2995

Merged
merged 2 commits into from
May 5, 2020

Conversation

benmoss
Copy link

@benmoss benmoss commented May 1, 2020

What this PR does / why we need it:
Trying to make envtest it a simpler API, less copypasta. I think we should be able to keep it up to date with the full set of our CRDs.

I only updated the controllers package tests, but others can be updated as needed.

Split out from #2975

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 1, 2020
@k8s-ci-robot k8s-ci-robot requested review from ncdc and vincepri May 1, 2020 19:43
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 1, 2020
@benmoss benmoss force-pushed the envtest-wrapper branch 3 times, most recently from 1450fc9 to c200d4e Compare May 1, 2020 20:29
Comment on lines +340 to +341
err := testEnv.Get(ctx, key, machine)
Expect(apierrors.IsNotFound(err)).To(BeTrue())
Copy link
Author

Choose a reason for hiding this comment

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

Calling out that this is the only substantive change, I am not sure why remediated machines were not being deleted before in this test but now they error with NotFound. Maybe the sync interval was different and so reconciliation didn't happen?

Copy link
Member

Choose a reason for hiding this comment

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

That's interesting, the new check looks better though

@benmoss
Copy link
Author

benmoss commented May 1, 2020

Not sure what to do about the apidiff failure

sigs.k8s.io/cluster-api/util/kubeconfig
  Incompatible changes:
  - CreateEnvTestSecret: removed

Doesn't look like any of the providers use this test code

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

@benmoss
I like the idea of having util for envtest, but I find a little bit confusing the fact that TestEnvironment is also a Manager and a Client.

return err
}

func (t *TestEnvironment) initManager() error {
Copy link
Member

Choose a reason for hiding this comment

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

IMO this should return the manager and the client

Copy link
Author

Choose a reason for hiding this comment

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

I inlined this since we don't really need it as a separate method at all

return err
}

func (t *TestEnvironment) StartManager() error {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to merge this into init manager?

Copy link
Author

Choose a reason for hiding this comment

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

You have to register reconcilers before you start the manager, so we can't start it when we initialize it

test/helpers/envtest.go Outdated Show resolved Hide resolved
@benmoss
Copy link
Author

benmoss commented May 4, 2020

I like the idea of having util for envtest, but I find a little bit confusing the fact that TestEnvironment is also a Manager and a Client.

I just did this as a convenience, to reduce the verbosity of using it. We could not embed those structs though, the main win here is to avoid our tests having 5 pieces of state, instead we just wrap up everything in the environment object.

util/kubeconfig/testing.go Outdated Show resolved Hide resolved
test/helpers/envtest.go Outdated Show resolved Hide resolved
test/helpers/envtest.go Outdated Show resolved Hide resolved
@benmoss
Copy link
Author

benmoss commented May 4, 2020

/test pull-cluster-api-e2e

@benmoss benmoss force-pushed the envtest-wrapper branch from 21cfedd to f7e4453 Compare May 5, 2020 14:19
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/milestone v0.3.6
/assign @ncdc @fabriziopandini
for final LGTM

@k8s-ci-robot k8s-ci-robot added this to the v0.3.6 milestone May 5, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benmoss, vincepri

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 5, 2020
@ncdc
Copy link
Contributor

ncdc commented May 5, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 5, 2020
@k8s-ci-robot k8s-ci-robot merged commit 730f6a4 into kubernetes-sigs:master May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants