Remove HEAD-handling hack. (#794)

* remove HEAD -> GET workaround

Signed-off-by: dblock <[email protected]>

* Removed remaining HEAD-handling code.

Signed-off-by: dblock <[email protected]>

* Fixed remaining references to admin:admin.

Signed-off-by: dblock <[email protected]>

---------

Signed-off-by: dblock <[email protected]>
Co-authored-by: Vincent Castaneda <[email protected]>
This commit is contained in:
Daniel (dB.) Doubrovkine
2024-08-15 10:15:13 -04:00
committed by GitHub
co-authored by Vincent Castaneda
parent 19a911387c
commit 55f9940d51
11 changed files with 27 additions and 38 deletions
+1
View File
@@ -5,6 +5,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added
### Changed
- Removed deprecated `numpy.float_` and update NumPy/Pandas imports ([#762](https://github.com/opensearch-project/opensearch-py/pull/762))
- Removed workaround for [aiohttp#1769](https://github.com/aio-libs/aiohttp/issues/1769) ([#794](https://github.com/opensearch-project/opensearch-py/pull/794))
### Deprecated
### Removed
- Removed redundant dependency on six ([#781](https://github.com/opensearch-project/opensearch-py/pull/781))
+2 -1
View File
@@ -10,6 +10,7 @@
# GitHub history for details.
import asyncio
import os
import uuid
from typing import Any
@@ -42,7 +43,7 @@ async def test_async(client_count: int = 1, item_count: int = 1) -> None:
"""
host = "localhost"
port = 9200
auth = ("admin", "admin")
auth = ("admin", os.getenv("OPENSEARCH_PASSWORD", "admin"))
index_name = "test-index-async"
clients = []
+2 -1
View File
@@ -11,6 +11,7 @@
import logging
import os
import sys
import time
from typing import Any
@@ -34,7 +35,7 @@ def test(thread_count: int = 1, request_count: int = 1, client_count: int = 1) -
"""test to index with thread_count threads, item_count records and run client_count clients"""
host = "localhost"
port = 9200
auth = ("admin", "admin")
auth = ("admin", os.getenv("OPENSEARCH_PASSWORD", "admin"))
root = logging.getLogger()
# root.setLevel(logging.DEBUG)
+2 -1
View File
@@ -11,6 +11,7 @@
import json
import logging
import os
import sys
import time
import uuid
@@ -52,7 +53,7 @@ def test(thread_count: int = 1, item_count: int = 1, client_count: int = 1) -> N
"""test to index with thread_count threads, item_count records and run client_count clients"""
host = "localhost"
port = 9200
auth = ("admin", "admin")
auth = ("admin", os.getenv("OPENSEARCH_PASSWORD", "admin"))
index_name = "test-index-sync"
root = logging.getLogger()
+1 -1
View File
@@ -15,7 +15,7 @@ from unittest import SkipTest
from opensearchpy import AsyncOpenSearch
from opensearchpy.exceptions import ConnectionError
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "https://admin:admin@localhost:9200")
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "https://localhost:9200")
async def get_test_client(nowait: bool = False, **kwargs: Any) -> Any:
+1 -13
View File
@@ -246,14 +246,6 @@ class AIOHttpConnection(AsyncConnection):
else:
query_string = ""
# There is a bug in aiohttp that disables the re-use
# of the connection in the pool when method=HEAD.
# See: aio-libs/aiohttp#1769
is_head = False
if method == "HEAD":
method = "GET"
is_head = True
# Top-tier tip-toeing happening here. Basically
# because Pip's old resolver is bad and wipes out
# strict pins in favor of non-strict pins of extras
@@ -301,11 +293,7 @@ class AIOHttpConnection(AsyncConnection):
timeout=timeout,
fingerprint=self.ssl_assert_fingerprint,
) as response:
if is_head: # We actually called 'GET' so throw away the data.
await response.release()
raw_data = ""
else:
raw_data = await response.text()
raw_data = await response.text()
duration = self.loop.time() - start
# We want to reraise a cancellation or recursion error.
+1 -13
View File
@@ -167,14 +167,6 @@ class AsyncHttpConnection(AIOHttpConnection):
else:
query_string = ""
# There is a bug in aiohttp that disables the re-use
# of the connection in the pool when method=HEAD.
# See: https://github.com/aio-libs/aiohttp/issues/1769
is_head = False
if method == "HEAD":
method = "GET"
is_head = True
# Top-tier tip-toeing happening here. Basically
# because Pip's old resolver is bad and wipes out
# strict pins in favor of non-strict pins of extras
@@ -221,11 +213,7 @@ class AsyncHttpConnection(AIOHttpConnection):
timeout=timeout,
fingerprint=self.ssl_assert_fingerprint,
) as response:
if is_head: # We actually called 'GET' so throw away the data.
await response.release()
raw_data = ""
else:
raw_data = await response.text()
raw_data = await response.text()
duration = self.loop.time() - start
# We want to reraise a cancellation or recursion error.
+6 -5
View File
@@ -34,7 +34,7 @@ import opensearchpy.client
from opensearchpy import OpenSearch
from opensearchpy.exceptions import ConnectionError
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "https://admin:admin@localhost:9200")
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL", "https://localhost:9200")
def get_test_client(nowait: bool = False, **kwargs: Any) -> OpenSearch:
@@ -105,10 +105,11 @@ def opensearch_version(client: opensearchpy.client.OpenSearch) -> Any:
if "OPENSEARCH_VERSION" in os.environ:
OPENSEARCH_VERSION = _get_version(os.environ["OPENSEARCH_VERSION"])
else:
client = OpenSearch(
OPENSEARCH_URL,
verify_certs=False,
OPENSEARCH_VERSION = opensearch_version(
get_test_client(
verify_certs=False,
http_auth=("admin", os.getenv("OPENSEARCH_PASSWORD", "admin")),
)
)
OPENSEARCH_VERSION = opensearch_version(client)
__all__ = ["OpenSearchTestCase"]
+1 -1
View File
@@ -38,7 +38,7 @@ def main() -> None:
# Setup connection with the OpenSearch cluster
print("Setting up connection with OpenSearch cluster...")
opensearch_client: Any = OpenSearch(
"https://admin:admin@localhost:9200",
"https://localhost:9200",
use_ssl=True,
verify_certs=False,
ssl_show_warn=False,
@@ -7,6 +7,7 @@
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
import os
import re
from datetime import datetime
from typing import Any
@@ -36,7 +37,10 @@ pytestmark = pytest.mark.asyncio
@fixture(scope="function") # type: ignore
async def client() -> Any:
client = await get_test_client(verify_certs=False, http_auth=("admin", "admin"))
client = await get_test_client(
verify_certs=False,
http_auth=("admin", os.getenv("OPENSEARCH_PASSWORD", "admin")),
)
await add_connection("default", client)
return client
@@ -24,6 +24,7 @@
# specific language governing permissions and limitations
# under the License.
import os
import re
from datetime import datetime
from typing import Any
@@ -46,7 +47,10 @@ from .test_document import Comment, History, PullRequest, User
@fixture(scope="session") # type: ignore
def client() -> Any:
client = get_test_client(verify_certs=False, http_auth=("admin", "admin"))
client = get_test_client(
verify_certs=False,
http_auth=("admin", os.getenv("OPENSEARCH_PASSWORD", "admin")),
)
add_connection("default", client)
return client