-
Notifications
You must be signed in to change notification settings - Fork 126
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
Adding test for KNNWeight #759
Adding test for KNNWeight #759
Conversation
@@ -165,6 +165,9 @@ dependencies { | |||
api group: 'com.google.guava', name: 'guava', version:'30.0-jre' | |||
api group: 'commons-lang', name: 'commons-lang', version: '2.6' | |||
testFixturesImplementation "org.opensearch.test:framework:${opensearch_version}" | |||
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.12.22' | |||
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.2' | |||
testImplementation group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.12.22' |
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 required to mock static classes/methods
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.
Quick feedback on this:
- Is there a possibility that we fix src so that we don't need to mock static functions.
- Are we using junit4 or junit5 here?
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.
Making changes in source will be problematic, there are many such classes involved in call chain.
We're using junit4, 4.13 to be precise.
@@ -196,6 +199,7 @@ test { | |||
dependsOn buildJniLib | |||
systemProperty 'tests.security.manager', 'false' | |||
systemProperty "java.library.path", "$rootDir/jni/release" | |||
systemProperty "jdk.attach.allowAttachSelf", true |
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 required to mock static classes/methods
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.
Add a comment in the file itself.
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.
ack
167bf29
to
3ee085e
Compare
Signed-off-by: Martin Gaievski <[email protected]>
3ee085e
to
6396272
Compare
src/test/java/org/opensearch/knn/index/query/KNNWeightTests.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Martin Gaievski <[email protected]>
try { | ||
testQueryScore(space::scoreTranslation, SEGMENT_FILES_NMSLIB, Map.of(SPACE_TYPE, space.getValue())); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); |
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 catch this?
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.
that's the syntax required in case we're using forEach. Let me change it to something less verbose and without required catch.
Signed-off-by: Martin Gaievski <[email protected]>
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 thanks for adding these @martin-gaievski! This improves our coverage greatly!
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.x 1.x
# Navigate to the new working tree
cd .worktrees/backport-1.x
# Create a new branch
git switch --create backport/backport-759-to-1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 5b06cfe8902920161f6515347b49fcb2eae3e4e7
# Push it to GitHub
git push --set-upstream origin backport/backport-759-to-1.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.x Then, create a pull request where the |
* Adding test for KNNWeight Signed-off-by: Martin Gaievski <[email protected]> (cherry picked from commit 5b06cfe)
* Adding test for KNNWeight Signed-off-by: Martin Gaievski <[email protected]> (cherry picked from commit 5b06cfe) Co-authored-by: Martin Gaievski <[email protected]>
Signed-off-by: Martin Gaievski [email protected]
Description
We do not have unit tests for KNNWeight, having it would help to catch issues with size of DocIdSetBuilder, like #500 and #751. Along with test adding dependencies for doing mocks of static classes and/or methods.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.