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

Bug 1867848: Return empty properties and dependencies in ListBundles responses. #417

Conversation

benluddy
Copy link
Contributor

Bundles that don't have any properties/dependencies should return nil
or [] for those fields, but due to an error in handling NULL column
values, a single zero-valued entry was being returned.

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Aug 11, 2020
@openshift-ci-robot
Copy link

@benluddy: This pull request references Bugzilla bug 1867848, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1867848: Return empty properties and dependencies in ListBundles responses.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

list = append(list, entry)
}
}
return list
}

func uniqueProps(props []*api.Property) []*api.Property {
keys := make(map[string]bool)
list := []*api.Property{}
keys := make(map[string]struct{})
Copy link
Member

Choose a reason for hiding this comment

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

👍

)

func TestListBundles(t *testing.T) {
const query = `SELECT DISTINCT channel_entry.entry_id, operatorbundle.bundle, operatorbundle.bundlepath,
Copy link
Member

Choose a reason for hiding this comment

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

Am I misreading something or is this const just not used? Is it injected into something somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, good catch. The ListBundles impl calls out to other methods on SQLQuerier, which in turn make other database queries, so I was originally going to set the stub behavior based on the query arg. I ended up stubbing based on invocation count instead and didn't use it.

Bundles that don't have any properties/dependencies should return nil
or [] for those fields, but due to an error in handling NULL column
values, a single zero-valued entry was being returned.
@benluddy benluddy force-pushed the listbundles-zero-dependencies-properties branch from 5601835 to 00b48a4 Compare August 11, 2020 18:43
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

Thanks for doing this, I definitely prefer DI-ing a mock data source over working w/ database files on-disk.

I'm also wondering if there's a generic ORM package (codegen?) we could use. Food for thought.

@@ -1,3 +1,5 @@
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -o sqlitefakes/fake_rowscanner.go . RowScanner
Copy link
Member

Choose a reason for hiding this comment

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

👍

bundlesMap := map[string]*api.Bundle{}
for rows.Next() {
var entryID sql.NullInt64
Copy link
Member

Choose a reason for hiding this comment

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

👍

"github.com/operator-framework/operator-registry/pkg/api"
"github.com/operator-framework/operator-registry/pkg/sqlite"
"github.com/operator-framework/operator-registry/pkg/sqlite/sqlitefakes"
"github.com/stretchr/testify/assert"
Copy link
Member

Choose a reason for hiding this comment

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

nit: import order

}

func unique(deps []*api.Dependency) []*api.Dependency {
keys := make(map[string]bool)
list := []*api.Dependency{}
keys := make(map[string]struct{})
Copy link
Member

Choose a reason for hiding this comment

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

👍

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

[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-merge-robot openshift-merge-robot merged commit d724d65 into operator-framework:master Aug 17, 2020
@openshift-ci-robot
Copy link

@benluddy: All pull requests linked via external trackers have merged: operator-framework/operator-registry#417. Bugzilla bug 1867848 has been moved to the MODIFIED state.

In response to this:

Bug 1867848: Return empty properties and dependencies in ListBundles responses.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants