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

Magic catalog #2527

Merged

Conversation

perdasilva
Copy link
Collaborator

Description of the change:
This PR instroduces MagicCatalog, an easy(er) way to deploy custom/arbitrary catalogs for e2e tests. I've also refactored the utils_test.go to utils.go and started taking the first steps to cut the utilities out into its own package, if possible.

At the moment it only includes a single implementation of the FileBasedCatalogProvider, which serves up the FBC given by a filesystem path (the FileBasedFileBasedCatalogProvider). Other providers could be imagined that give a more programmatic approach to catalog building...

This PR could probably be improved by bringing in registry classes (maybe the FileBasedCatalogProvider could provide some FileBasedCatalog obj, etc.). Curious to know what you guys think.

Motivation for the change:
It's really hard to bring arbitrary

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive

Copy link
Member

@dinhxuanvu dinhxuanvu 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 Dec 16, 2021
@perdasilva
Copy link
Collaborator Author

/assign @kevinrizza

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 16, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 24, 2021
Signed-off-by: Per G. da Silva <perdasilva@redhat.com>
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 28, 2021
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.

Wow, thanks for putting this together! It should really help.

/approve

(reminder: we need to add @perdasilva to the approver set)

func (c *magicCatalog) makeCatalogSourcePod() *corev1.Pod {

const (
image = "quay.io/operator-framework/upstream-opm-builder"
Copy link
Member

Choose a reason for hiding this comment

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

I think this might need to be injectable for downstream CI at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's a very good point - we could think of using env vars or something like that

TeardownNamespace(generatedNamespace.GetName())
})

It("Deploys and Undeploys a File-based Catalog", func() {
Copy link
Member

Choose a reason for hiding this comment

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

Tests for the test harness 🙂

const catalogName = "test"
namespace := generatedNamespace.GetName()
kubeClient := ctx.Ctx().Client()
provider, err := NewFileBasedFiledBasedCatalogProvider("../test/e2e/testdata/fbc_catalog.json")
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I'd rather see the FBC JSON literal in the test case itself than in a golden file, but this works for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tbh - I'm not a huge fan of big string literals, especially when we can't nicely format them due to code formatting or indentation, etc. For small stuff sure, for bigger files it's start to get awkward for me. But this is a taste thing. I've tried to create an abstraction through this provider interface where we can plug-in different fbc sources (file, string, etc.). When I have a little more time, I'd like to have a way to create the fbcs programatically. Might be even more readable that way...idk...

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 30, 2021
Copy link
Contributor

@timflannagan timflannagan 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 there's a good chunk of potential linting errors (the golangci-lint work we just merged excludes the test/e2e package for now, but we'll remove that exclusion over time) that the sanity check isn't complaining about, so I'm not super concerned. I don't have any problem with the implementation, and we should even have an issue open for switching to FBC for test fixtures open somewhere. Thanks for renaming that test utilities package, I've had the urge to rename that for a while now.

/lgtm

Name: c.configMapName,
Namespace: c.namespace,
},
Immutable: &isImmutable,
Copy link
Contributor

Choose a reason for hiding this comment

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

Super unimportant: we likely have a test helper function (or at least we should) that returns a pointer to a bool somewhere.

}

func (c *magicCatalog) UndeployCatalog(ctx context.Context) []error {
var errs []error = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this appears to be redundant as var errs []error should be equivalent to an empty slice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right! old habits hehehe

Comment on lines +83 to +87
func waitFor(fn func() (bool, error)) error {
return wait.Poll(pollInterval, pollDuration, func() (bool, error) {
return fn()
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

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

openshift-ci bot commented Jan 2, 2022

[APPROVALNOTIFIER] This PR is APPROVED

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

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-merge-robot openshift-merge-robot merged commit bee0b68 into operator-framework:master Jan 2, 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.

6 participants