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

e2e test utilities update #2799

Merged
merged 6 commits into from
Jun 14, 2022
Merged

Conversation

perdasilva
Copy link
Collaborator

@perdasilva perdasilva commented Jun 13, 2022

Description of the change:
This PR makes the following changes:

  • Moves the TestContext to use the new E2EClient with resource tracking and clean-up
  • Adds CRD garbage collection to E2EClient
  • Refactors the MagicCatalog implementation to remove the superfluous interface adds a factory method to create one directly from the file, obviating the need to create a file provider
  • Adds a DeterminedE2EClient which wraps calls around an Eventually loop
  • Adds E2ETestHelper. A dedicated class for OLM resource assertions with some initial assertions for Subscriptions and CatalogSource

Motivation for the change:

  • E2EClient helps keep the cluster clean throughout the e2e test execution
  • Having a DeterminedClient avoids the need for tests to wrap client calls in Eventually loops, keeping them leaner and easier to read/understand
  • E2ETestHelper will eventually remove the disparate helper functions that are peppered throughout the e2e tests, gives a single place to add and find assertions (e.g. assert that a subscription has reached a particular state, a catalog source is ready, etc.)
    BugFix: removes resource catching from update call in e2e client. This should not be done since it may be updating a resource that is not managed by the client.

Architectural changes:
None

Testing remarks:
Manually tested against e2e tests

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 13, 2022
@perdasilva perdasilva force-pushed the e2e_util_update branch 2 times, most recently from f5a8d7d to de529f0 Compare June 13, 2022 11:25
}

func (m *DeterminedE2EClient) Update(context context.Context, obj k8scontrollerclient.Object, options ...k8scontrollerclient.UpdateOption) error {
m.keepTrying(func() error {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should we check for conflict failures and get the latest resource version before trying again?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think so, otherwise this will be pretty brittle.

We could use the SSA client, or maybe an merge update strategy would work?

Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 13, 2022
@openshift-bot
Copy link
Contributor

/retest-required

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

Copy link
Member

@exdx exdx left a comment

Choose a reason for hiding this comment

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

Very nice. I had some nits, nothing blocking. I saw @njhale lgtm'd so it's fine to go in as-is.

I respun CI, I think there may be another flake.


"github.com/onsi/ginkgo/v2"
k8serror "k8s.io/apimachinery/pkg/api/errors"
extensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Copy link
Member

Choose a reason for hiding this comment

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

nit: we use apiextensionsv1 for this import elsewhere in the codebase


Logf("deleting %s/%s", namespace, obj.GetName())
if err := k8scontrollerclient.IgnoreNotFound(m.Delete(context.Background(), obj)); err != nil {
Logf("error deleting object %s/%s: %s", namespace, obj.GetName(), obj)
Copy link
Member

Choose a reason for hiding this comment

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

nit: should the last argument here be the error instead of the obj?

Comment on lines +92 to +93
if err := m.Client.Delete(context.Background(), &crd); err != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

CRDs may take some time to delete, especially on openshift, if there are CRs associated with that CRD as well. Would it make sense to block after Deletion and wait for a apierrors.NotFound(m.Client.Get(crd))?

}

func (m *DeterminedE2EClient) Update(context context.Context, obj k8scontrollerclient.Object, options ...k8scontrollerclient.UpdateOption) error {
m.keepTrying(func() error {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think so, otherwise this will be pretty brittle.

We could use the SSA client, or maybe an merge update strategy would work?

@openshift-ci
Copy link

openshift-ci bot commented Jun 13, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: exdx, njhale, perdasilva

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-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 13, 2022
@exdx
Copy link
Member

exdx commented Jun 14, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2022
@openshift-bot
Copy link
Contributor

/retest-required

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

@exdx
Copy link
Member

exdx commented Jun 14, 2022

Should we squash the commits before merging?

@openshift-bot
Copy link
Contributor

/retest-required

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

5 similar comments
@openshift-bot
Copy link
Contributor

/retest-required

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

@openshift-bot
Copy link
Contributor

/retest-required

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

@openshift-bot
Copy link
Contributor

/retest-required

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

@openshift-bot
Copy link
Contributor

/retest-required

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

@openshift-bot
Copy link
Contributor

/retest-required

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

@timflannagan
Copy link
Contributor

Holding so the bot doesn't go crazy retesting.

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 14, 2022
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2022
* Update unpack job security

Signed-off-by: perdasilva <perdasilva@redhat.com>

* Refactor catsrc pod creation to use security package

Signed-off-by: perdasilva <perdasilva@redhat.com>
…method to create from file

Signed-off-by: perdasilva <perdasilva@redhat.com>
…llection

Signed-off-by: perdasilva <perdasilva@redhat.com>
Signed-off-by: perdasilva <perdasilva@redhat.com>
Signed-off-by: perdasilva <perdasilva@redhat.com>
Signed-off-by: perdasilva <perdasilva@redhat.com>
Copy link
Member

@exdx exdx left a comment

Choose a reason for hiding this comment

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

/lgtm

// ApplyPodSpecSecurity applies the standard security profile to a pod spec
func ApplyPodSpecSecurity(spec *corev1.PodSpec) {
var containerSecurityContext = &corev1.SecurityContext{
Privileged: pointer.Bool(privileged),
Copy link
Member

Choose a reason for hiding this comment

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

This pointer.T() pattern is nice

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

util.Logf("expecting catalog source last connection state '%s' to be '%s'", actual.Status.GRPCConnectionState.LastObservedState, s.Expected)
return s.EqualMatcher.Match(actual.Status.GRPCConnectionState.LastObservedState)
default:
return false, fmt.Errorf("actual %v is not a subscription", actual)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return false, fmt.Errorf("actual %v is not a subscription", actual)
return false, fmt.Errorf("actual %v is not a catalogsource", actual)

*matchers.EqualMatcher
}

func (s *CatalogSourceGrpcConnectionLastConnectionStateMatcher) FailureMessage(actual interface{}) (message string) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we use client.Object instead of the interface{} type as an argument? Since we know we are dealing with a kube object.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the Matcher interface =S would be nice tho!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2022
@perdasilva
Copy link
Collaborator Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 14, 2022
@openshift-ci openshift-ci bot merged commit a538831 into operator-framework:master Jun 14, 2022
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.

5 participants