-
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
Refactor integ tests that access model index #1423
Conversation
Refactors integration tests that directly access the model system index. End users should not be directly accessing the model system index. It is supposed to be an implementation detail. We have written restful integration tests that directly access the model system index in order to initialize the cluster state. However, we should not do this because users should not be able to interact with it through restful APIs That being said, some of this implementation detail leaks out into the interface. For instance, in k-NN stats we have a stat that is the model system index status. So, in order to test this, we do need direct access to the system index. Similarly, for search, we execute the search against the system index and directly return the results. This is probably a bug - but we still need to test it. Signed-off-by: John Mazanec <[email protected]>
01b1a54
to
f3302d2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1423 +/- ##
============================================
- Coverage 84.92% 84.80% -0.12%
+ Complexity 1274 1273 -1
============================================
Files 167 167
Lines 5186 5186
Branches 491 491
============================================
- Hits 4404 4398 -6
- Misses 573 579 +6
Partials 209 209 ☔ View full report in Codecov by Sentry. |
Failure related to #1413 |
In a lot of the tests, the only change is removing the |
src/test/java/org/opensearch/knn/plugin/action/RestDeleteModelHandlerIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/knn/plugin/action/RestDeleteModelHandlerIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/knn/plugin/action/RestGetModelHandlerIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/knn/plugin/action/RestGetModelHandlerIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/knn/plugin/action/RestSearchModelHandlerIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/knn/plugin/action/RestSearchModelHandlerIT.java
Outdated
Show resolved
Hide resolved
public void testNoModelExists() throws Exception { | ||
createModelSystemIndex(); | ||
public void testSearch_whenNoModelExists_thenReturnEmptyResults() throws Exception { | ||
// Currently, if the model index exists, we will return empty hits. If it does not exist, we will |
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.
Can we create an issue to fix 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.
Sure, #1425
…HandlerIT.java Co-authored-by: Heemin Kim <[email protected]> Signed-off-by: John Mazanec <[email protected]>
…dlerIT.java Co-authored-by: Heemin Kim <[email protected]> Signed-off-by: John Mazanec <[email protected]>
…HandlerIT.java Co-authored-by: Heemin Kim <[email protected]> Signed-off-by: John Mazanec <[email protected]>
…HandlerIT.java Co-authored-by: Heemin Kim <[email protected]> Signed-off-by: John Mazanec <[email protected]>
…dlerIT.java Co-authored-by: Heemin Kim <[email protected]> Signed-off-by: John Mazanec <[email protected]>
…HandlerIT.java Co-authored-by: Heemin Kim <[email protected]> Signed-off-by: John Mazanec <[email protected]>
Currently, for training, if the model does not exist, then it is supposed to create the system index. So, for many tests that were already doing the training, it didnt do anything |
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!
Signed-off-by: John Mazanec <[email protected]>
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-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1423-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 2b963b4ae2ae06f0108e3c80e7b9d8785b9033b3
# Push it to GitHub
git push --set-upstream origin backport/backport-1423-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
Refactors integration tests that directly access the model system index. End users should not be directly accessing the model system index. It is supposed to be an implementation detail. We have written restful integration tests that directly access the model system index in order to initialize the cluster state. However, we should not do this because users should not be able to interact with it through restful APIs That being said, some of this implementation detail leaks out into the interface. For instance, in k-NN stats we have a stat that is the model system index status. So, in order to test this, we do need direct access to the system index. Similarly, for search, we execute the search against the system index and directly return the results. This is probably a bug - but we still need to test it. Signed-off-by: John Mazanec <[email protected]> (cherry picked from commit 2b963b4)
Refactors integration tests that directly access the model system index. End users should not be directly accessing the model system index. It is supposed to be an implementation detail. We have written restful integration tests that directly access the model system index in order to initialize the cluster state. However, we should not do this because users should not be able to interact with it through restful APIs That being said, some of this implementation detail leaks out into the interface. For instance, in k-NN stats we have a stat that is the model system index status. So, in order to test this, we do need direct access to the system index. Similarly, for search, we execute the search against the system index and directly return the results. This is probably a bug - but we still need to test it. Signed-off-by: John Mazanec <[email protected]> (cherry picked from commit 2b963b4)
Description
Refactors integration tests that directly access the model system index. End users should not be directly accessing the model system index. It is supposed to be an implementation detail. We have written restful integration tests that directly access the model system index in order to initialize the cluster state. However, we should not do this because users should not be able to interact with it through restful APIs. In fact, in some cluster configurations, it should not be possible.
That being said, some of this implementation detail leaks out through the interface. For instance, in k-NN stats we have a stat that is the model system index status. So, in order to test this, we do need direct access to the system index. Similarly, for search, we execute the search against the system index and directly return the results. This is probably a bug - but we still need to test it. So, for these cases, we check if the index exists.
Additionally, I deleted the test
RestDeleteModelHandlerIT.testDeleteTrainingModel
. This test had an inherit race condition that model that was got trained did not complete until a few lines later. This will lead to flakiness, so I deleted it. This functionality is also already unit tested in ModelDaoTests.Along with this, I did some test renaming to make test logic more clear using test*_when*_then* convention.
Issues Resolved
#1365 , #888
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.