Skip to content

test(e2e): patch installplans w/ server-side apply #1617

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

Merged
merged 1 commit into from
Jul 2, 2020

Conversation

njhale
Copy link
Member

@njhale njhale commented Jun 30, 2020

Use server-side apply to patch InstallPlans under test in order to prevent
update conflict flakes.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2020
@njhale
Copy link
Member Author

njhale commented Jun 30, 2020

/hold

Looks like the patch is still running into issues with resourceVersion.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 30, 2020

// Set the InstallPlan's approval mode to Manual
plan.Spec.Approval = v1alpha1.ApprovalManual
plan.Spec.Approved = false
plan, err = crc.OperatorsV1alpha1().InstallPlans(ref.Namespace).Update(context.TODO(), plan, metav1.UpdateOptions{})
require.NoError(GinkgoT(), err)
setTypeMeta := func(p *v1alpha1.InstallPlan) *v1alpha1.InstallPlan {
Copy link
Member

Choose a reason for hiding this comment

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

if this is in an eventually, it should work?

@exdx
Copy link
Member

exdx commented Jun 30, 2020

This is really interesting. Does it make any sense to consider turning this logic into a library such that more of the e2e tests can start to use server-side apply?

@njhale
Copy link
Member Author

njhale commented Jul 1, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 1, 2020
@njhale njhale force-pushed the fix-e2e branch 2 times, most recently from ea1cc4f to 18b5531 Compare July 1, 2020 17:31
@njhale
Copy link
Member Author

njhale commented Jul 1, 2020

This is really interesting. Does it make any sense to consider turning this logic into a library such that more of the e2e tests can start to use server-side apply?

@exdx The function is included with our e2e tests here, so it's already available to use in any of them.

@njhale
Copy link
Member Author

njhale commented Jul 1, 2020

/test e2e-gcp

return err
}
cp.GetObjectKind().SetGroupVersionKind(obj.GetObjectKind().GroupVersionKind())
cp.SetManagedFields(nil)
Copy link
Member

Choose a reason for hiding this comment

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

is this needed? shouldn't the ForceOwnership make test become the owner of any changed fields?

Copy link
Member Author

Choose a reason for hiding this comment

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

this came out of some red/green/refactor-ing -- an error is returned without it.

Use server-side apply to patch InstallPlans under test in order to prevent
update conflict flakes.
@njhale
Copy link
Member Author

njhale commented Jul 2, 2020

/retest

Copy link
Contributor

@benluddy benluddy left a comment

Choose a reason for hiding this comment

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

/lgtm

You've already addressed my sidechannel feedback, but I noticed a few nits on my last read.


// Apply returns a function that invokes a change func on an object and performs a server-side apply patch with the result and its status subresource.
// The given resource must only specify its Name, Namespace, APIVersion, and Kind.
// The given change function must be aunary, matching the signature: "func(<obj type>) error".
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The given change function must be aunary, matching the signature: "func(<obj type>) error".
// The given change function must be unary, matching the signature: "func(<obj type>) error".

}
var err error
if rt := changeType.Out(0); !rt.Implements(reflect.TypeOf((*error)(nil)).Elem()) {
panic(fmt.Sprintf("unexpected return type in change function signature: expected %t, preset %s", err, rt))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
panic(fmt.Sprintf("unexpected return type in change function signature: expected %t, preset %s", err, rt))
panic(fmt.Sprintf("unexpected return type in change function signature: expected %t, present %s", err, rt))

return err
}

reflect.ValueOf(obj).Elem().Set(cpv.Elem())
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the doc comment make it clear that the value addressed byobj will be updated?

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 2, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benluddy, njhale

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

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 53f6fa4 into operator-framework:master Jul 2, 2020
@njhale njhale deleted the fix-e2e branch July 2, 2020 12:54
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants