-
Notifications
You must be signed in to change notification settings - Fork 61
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
🌱 (catalogd) add unit tests for indexing algo for query endpoint #1702
🌱 (catalogd) add unit tests for indexing algo for query endpoint #1702
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -50,20 +50,6 @@ func (s *section) UnmarshalJSON(b []byte) error { | |||
return nil | |||
} | |||
|
|||
func (i index) Size() int64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we removing this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I realized it's not being used anywhere, so at least in the context of existing code, it's dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I was using that in my prototype to estimate how big the index would be in memory. No need for it anymore.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1702 +/- ##
==========================================
+ Coverage 67.47% 67.66% +0.18%
==========================================
Files 59 59
Lines 5003 4991 -12
==========================================
+ Hits 3376 3377 +1
+ Misses 1380 1367 -13
Partials 247 247
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
24bc1a1
to
b280e81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Closes operator-framework#1697 Signed-off-by: Anik Bhattacharjee <[email protected]>
b280e81
to
8bf3528
Compare
HI @anik120 Nit: I hope that you do not mind I update the emoji with the title to 🌱 because that means no changes to end users Just sort out the lint then it seems good to fly 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
@camilamacedo86 thanks for the lgtm! lint is passing now too. |
} | ||
|
||
// createBlob is a helper function that creates a JSON blob with a trailing newline | ||
func createBlob(t *testing.T, data map[string]interface{}) []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use the declcfg.WriteJSON method in operator-registry which utilizes the underlying JSON encoder which turns each blob into a JSONLines-compliant format by appending a newline suffix here.
This is how catalogd ends up coincidentally JSONLines-compliant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I studied the WriteJSON function and looks like it requires a declCfg.DeclConfig
as an argument. Overkill imho if we create a declCfg.DeclConfig
from test data just to use WriteJSON
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how catalogd ends up coincidentally JSONLines-compliant.
On a side note this sounds fragile because it looks like they only add the /n
to make the output look nicer and could easily pull this out in a future release in which case WriteJSON
will stop being JSONLines compliant.
Not sure how many places this function is actually being used, but I guess at this point this is a "we'll cross the bridge if we ever get there" case :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I initially included the note just for the context because this is totally an accident and could just as easily go away. So we used to have tests to ensure we would recognize any change from that accident.
We need to restore those tests, since presumably any behavior change will come from a dependency bump, so we want the CI to fail early/loud if the behavior changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't related to this PR, so I created #1709 for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
reader := idx.Get(fullData, tt.schema, tt.packageName, tt.blobName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blobName
and packageName
are not consistently provided in the tests. Are they needed?
Looks like blobName
is actually bundleName
. Rename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSection()
code handles these cases:
func (i *index) getSectionSet(schema, packageName, name string) sets.Set[section] {
.
.
// Filter by package name if specified
if packageName != "" {
.
.
}
// Filter by name if specified
if name != "" {
.
.
}
return sectionSet
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
@grokspawn, it seems fine to me.
@anik120 shows that answers your concerns.
But @anik120 I think it would be nice just ensure that @grokspawn is also OK within
Closes #1697
Description
Reviewer Checklist