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

Refactor integ tests that access model index #1423

Merged
merged 8 commits into from
Jan 26, 2024

Conversation

jmazanec15
Copy link
Member

@jmazanec15 jmazanec15 commented Jan 26, 2024

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

  • Commits are signed as per the DCO using --signoff

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.

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]>
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (47728ce) 84.92% compared to head (8902317) 84.80%.

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.
📢 Have feedback on the report? Share it here.

@jmazanec15
Copy link
Member Author

Failure related to #1413

@ryanbogan
Copy link
Member

In a lot of the tests, the only change is removing the createModelSystemIndex. For my understanding, was this method not necessary at all for the successful completion of these tests?

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
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, #1425

heemin32
heemin32 previously approved these changes Jan 26, 2024
jmazanec15 and others added 6 commits January 26, 2024 11:52
…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]>
@jmazanec15
Copy link
Member Author

In a lot of the tests, the only change is removing the createModelSystemIndex. For my understanding, was this method not necessary at all for the successful completion of these tests?

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

ryanbogan
ryanbogan previously approved these changes Jan 26, 2024
Copy link
Member

@ryanbogan ryanbogan left a comment

Choose a reason for hiding this comment

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

LGTM!

@jmazanec15 jmazanec15 requested a review from heemin32 January 26, 2024 19:58
Signed-off-by: John Mazanec <[email protected]>
@jmazanec15 jmazanec15 requested a review from ryanbogan January 26, 2024 21:34
@jmazanec15 jmazanec15 merged commit 2b963b4 into opensearch-project:main Jan 26, 2024
50 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

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 base branch is 2.x and the compare/head branch is backport/backport-1423-to-2.x.

jmazanec15 added a commit to jmazanec15/k-NN-1 that referenced this pull request Jan 26, 2024
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)
ryanbogan pushed a commit that referenced this pull request Jan 26, 2024
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x integ-test-failure Integration test failures
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants