-
Notifications
You must be signed in to change notification settings - Fork 183
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
Ignore name of index when fetching settings #823
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #823 +/- ##
==========================================
- Coverage 71.95% 70.34% -1.61%
==========================================
Files 91 113 +22
Lines 8001 8896 +895
==========================================
+ Hits 5757 6258 +501
- Misses 2244 2638 +394 ☔ View full report in Codecov by Sentry. |
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.
What's the value of _name
vs. what it is after the change here?
Can you please add a test?
263b708
to
2ed7b6e
Compare
Thank you @dblock for your quick response! The value of removing If it's wanted, I could add a check that the alias only points to one index to raise a more specific error. Would that be appreciated? I've added a test, but I'm a little skeptical of the coverage report as it's based off a 6-month-old commit. Thank you! |
Possibly, but doesn't have to block this PR. Give it a shot after I merge 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.
This all makes sense.
I think you have to do the same for the async code (see https://github.com/opensearch-project/opensearch-py/blob/main/opensearchpy/_async/helpers/index.py#L308). Add a test for that too.
e026aaf
to
50771c1
Compare
I've added support for async, the checks for multiple indices, and testing for these. |
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.
Looks good!
I have some small language asks for the error. Also check that the tests do run because CodeCov seems unhappy and complains that tests are missing which seems odd.
opensearchpy/helpers/test.py
Outdated
@@ -34,7 +34,7 @@ | |||
from opensearchpy import OpenSearch | |||
from opensearchpy.exceptions import ConnectionError | |||
|
|||
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "https://localhost:9200") | |||
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "http://localhost:9200") |
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.
What's the reason for this change? AFAIK it should always be https
.
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.
Oh sorry, didn't mean to commit that! I had noticed that the tests did not run, and had to uncomment these list values to get the tests to run:
opensearch-py/test_opensearchpy/run_tests.py
Lines 159 to 164 in a24b9f3
ignores = [ | |
"test_opensearchpy/test_server/", | |
"test_opensearchpy/test_server_secured/", | |
"test_opensearchpy/test_async/test_server/", | |
"test_opensearchpy/test_async/test_server_secured/", | |
] |
I am a little hesitant to commit such changes as I don't have much context as to why this has been done and if it'd break anything. Also, the base commit for Codecov is quite old.
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.
Ugh this looks like a mess. I opened #826 with a high level idea of what we should do here (maybe someone wants to help later, wink wink).
For this PR I'd like to ensure the tests you wrote actually run (and pass) in CI. Is this the 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.
The tests do pass locally with the files un-ignored (although this assertion is somewhat empty)
On GitHub Actions they would be skipped as there is no OpenSearch service for the tests to use.
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 whole point, integration tests should run on GHA in one of the workflows.
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 still here, do you want to revert this line?
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.
Reverted, sorry.
test_opensearchpy/test_async/test_server/test_helpers/test_index.py
Outdated
Show resolved
Hide resolved
d0b4bed
to
2edcaf3
Compare
I debugged the test failure but couldn't find a solution. You can rebase with the workaround in #828 for now (or maybe you know how to fix that failure?). |
@dblock Rebased. |
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.
There's still that http, want to fix it?
opensearchpy/helpers/test.py
Outdated
@@ -34,7 +34,7 @@ | |||
from opensearchpy import OpenSearch | |||
from opensearchpy.exceptions import ConnectionError | |||
|
|||
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "https://localhost:9200") | |||
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "http://localhost:9200") |
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 still here, do you want to revert this line?
This commit fixes a situation where an index cannot be updated through this client as the index is aliased, with the client pointing to the alias. As the `GET /<index>/_settings` request will only ever return the settings for the specified index (through the alias), it would only have one key, so the name of the key would not matter. We can pop the key to get the settings object for the index through the alias. Signed-off-by: Étienne Beaulé <beauleetienne0@gmail.com>
good work merci @tienne-B ! |
Description
This commit fixes a situation where an index cannot be updated through this client as the index is aliased, with the client pointing to the alias.
As the
GET /<index>/_settings
request will only ever return the settings for the specified index (through the alias), it would only have one key, so the name of the key would not matter. We can pop the key to get the settings object for the index through the alias.Describe what this change achieves.
Issues Resolved
Closes #822
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.