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

[BUG] Failing tests test_callable_in_request_session and test_basicauth_in_request_session #849

Open
drupol opened this issue Nov 20, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@drupol
Copy link

drupol commented Nov 20, 2024

What is the bug?

Official tests of the package are failing:

  • test_callable_in_request_session
  • test_basicauth_in_request_session

How can one reproduce the bug?

Run pytest

What is the expected behavior?

Tests should pass

What is your host/environment?

Linux, Python 3.12.5

Do you have any screenshots?

Log
============================= test session starts ==============================
platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
rootdir: /build/source
configfile: setup.cfg
plugins: asyncio-0.23.8, mock-3.14.0
asyncio: mode=Mode.AUTO
collected 853 items / 2 deselected / 851 selected                              

test_opensearchpy/test_async/test_client.py ...                          [  0%]
test_opensearchpy/test_async/test_helpers/test_document.py ............. [  1%]
.................................                                        [  5%]
test_opensearchpy/test_async/test_helpers/test_faceted_search.py ....... [  6%]
.....................                                                    [  9%]
test_opensearchpy/test_async/test_helpers/test_index.py .............    [ 10%]
test_opensearchpy/test_async/test_helpers/test_mapping.py ........       [ 11%]
test_opensearchpy/test_async/test_helpers/test_search.py ............... [ 13%]
.................                                                        [ 15%]
test_opensearchpy/test_async/test_helpers/test_update_by_query.py ...... [ 15%]
..                                                                       [ 16%]
test_opensearchpy/test_async/test_http.py ......                         [ 16%]
test_opensearchpy/test_async/test_http_connection.py ...FF               [ 17%]
test_opensearchpy/test_async/test_plugins_client.py .                    [ 17%]
test_opensearchpy/test_async/test_server_secured/test_security_plugin.py s [ 17%]
ssssssssssssss                                                           [ 19%]
test_opensearchpy/test_async/test_signer.py .........                    [ 20%]
test_opensearchpy/test_async/test_transport.py ......................... [ 23%]
.......                                                                  [ 24%]
test_opensearchpy/test_cases.py ...                                      [ 24%]
test_opensearchpy/test_client/test_cluster.py ...                        [ 24%]
test_opensearchpy/test_client/test_http.py ......                        [ 25%]
test_opensearchpy/test_client/test_indices.py .....                      [ 26%]
test_opensearchpy/test_client/test_overrides.py ...............          [ 27%]
test_opensearchpy/test_client/test_plugins/test_alerting.py ............ [ 29%]
                                                                         [ 29%]
test_opensearchpy/test_client/test_plugins/test_index_management.py .... [ 29%]
.....                                                                    [ 30%]
test_opensearchpy/test_client/test_plugins/test_plugins_client.py .      [ 30%]
test_opensearchpy/test_client/test_point_in_time.py ........             [ 31%]
test_opensearchpy/test_client/test_remote_store.py .                     [ 31%]
test_opensearchpy/test_client/test_requests.py ..                        [ 31%]
test_opensearchpy/test_client/test_search_pipeline.py ..                 [ 32%]
test_opensearchpy/test_client/test_urllib3.py ...                        [ 32%]
test_opensearchpy/test_client/test_utils.py ..............               [ 34%]
test_opensearchpy/test_connection/test_base_connection.py .............  [ 35%]
test_opensearchpy/test_connection/test_requests_http_connection.py ..... [ 36%]
........................................................................ [ 44%]
                                                                         [ 44%]
test_opensearchpy/test_connection/test_urllib3_http_connection.py ...... [ 45%]
.....................................................                    [ 51%]
test_opensearchpy/test_connection_pool.py ..............                 [ 53%]
test_opensearchpy/test_exceptions.py ..                                  [ 53%]
test_opensearchpy/test_helpers/test_actions.py .s...........             [ 54%]
test_opensearchpy/test_helpers/test_aggs.py ............................ [ 58%]
....                                                                     [ 58%]
test_opensearchpy/test_helpers/test_analysis.py ...........              [ 60%]
test_opensearchpy/test_helpers/test_document.py ........................ [ 62%]
.......................                                                  [ 65%]
test_opensearchpy/test_helpers/test_faceted_search.py .................. [ 67%]
..........                                                               [ 68%]
test_opensearchpy/test_helpers/test_field.py ...................         [ 71%]
test_opensearchpy/test_helpers/test_index.py ..............              [ 72%]
test_opensearchpy/test_helpers/test_mapping.py ........                  [ 73%]
test_opensearchpy/test_helpers/test_query.py ........................... [ 76%]
.....................................                                    [ 81%]
test_opensearchpy/test_helpers/test_result.py .................          [ 83%]
test_opensearchpy/test_helpers/test_search.py .......................... [ 86%]
............                                                             [ 87%]
test_opensearchpy/test_helpers/test_update_by_query.py .........         [ 88%]
test_opensearchpy/test_helpers/test_utils.py ...........                 [ 90%]
test_opensearchpy/test_helpers/test_validation.py ..........             [ 91%]
test_opensearchpy/test_helpers/test_wrappers.py ........................ [ 94%]
.                                                                        [ 94%]
test_opensearchpy/test_serializer.py .s..sssssssssss........             [ 96%]
test_opensearchpy/test_transport.py ...........................          [100%]

=================================== FAILURES ===================================
__________ TestAsyncHttpConnection.test_basicauth_in_request_session ___________

self = <test_opensearchpy.test_async.test_http_connection.TestAsyncHttpConnection object at 0x7ffff4c69100>
mock_request = <Mock name='request' id='140737295999408'>

    @pytest.mark.asyncio  # type: ignore
    @mock.patch("aiohttp.ClientSession.request", new_callable=mock.Mock)
    async def test_basicauth_in_request_session(self, mock_request: Any) -> None:
        async def do_request(*args: Any, **kwargs: Any) -> Any:
            response_mock = mock.AsyncMock()
            response_mock.headers = CIMultiDict()
            response_mock.status = 200
            return response_mock
    
        mock_request.return_value = aiohttp.client._RequestContextManager(do_request())
    
        c = AsyncHttpConnection(
            http_auth=("username", "password"),
            loop=get_running_loop(),
        )
        c.headers = {}
>       await c.perform_request("post", "/test")

test_opensearchpy/test_async/test_http_connection.py:75: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
opensearchpy/connection/http_async.py:241: in perform_request
    self._raise_warnings(warning_headers)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <AsyncHttpConnection: http://localhost:9200>
warning_headers = <coroutine object AsyncMockMixin._execute_mock_call at 0x7ffff47c1c40>

    def _raise_warnings(self, warning_headers: Any) -> None:
        """If 'headers' contains a 'Warning' header raise
        the warnings to be seen by the user. Takes an iterable
        of string values from any number of 'Warning' headers.
        """
        if not warning_headers:
            return
    
        # Grab only the message from each header, the rest is discarded.
        # Format is: '(number) OpenSearch-(version)-(instance) "(message)"'
        warning_messages = []
>       for header in warning_headers:
E       TypeError: 'coroutine' object is not iterable

opensearchpy/connection/base.py:165: TypeError
___________ TestAsyncHttpConnection.test_callable_in_request_session ___________

self = <test_opensearchpy.test_async.test_http_connection.TestAsyncHttpConnection object at 0x7ffff4c69340>
mock_request = <Mock name='request' id='140737296002048'>

    @pytest.mark.asyncio  # type: ignore
    @mock.patch("aiohttp.ClientSession.request", new_callable=mock.Mock)
    async def test_callable_in_request_session(self, mock_request: Any) -> None:
        def auth_fn(*args: Any, **kwargs: Any) -> Any:
            return {
                "Test": "PASSED",
            }
    
        async def do_request(*args: Any, **kwargs: Any) -> Any:
            response_mock = mock.AsyncMock()
            response_mock.headers = CIMultiDict()
            response_mock.status = 200
            return response_mock
    
        mock_request.return_value = aiohttp.client._RequestContextManager(do_request())
    
        c = AsyncHttpConnection(http_auth=auth_fn, loop=get_running_loop())
        c.headers = {}
>       await c.perform_request("post", "/test")

test_opensearchpy/test_async/test_http_connection.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
opensearchpy/connection/http_async.py:241: in perform_request
    self._raise_warnings(warning_headers)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <AsyncHttpConnection: http://localhost:9200>
warning_headers = <coroutine object AsyncMockMixin._execute_mock_call at 0x7ffff47c2840>

    def _raise_warnings(self, warning_headers: Any) -> None:
        """If 'headers' contains a 'Warning' header raise
        the warnings to be seen by the user. Takes an iterable
        of string values from any number of 'Warning' headers.
        """
        if not warning_headers:
            return
    
        # Grab only the message from each header, the rest is discarded.
        # Format is: '(number) OpenSearch-(version)-(instance) "(message)"'
        warning_messages = []
>       for header in warning_headers:
E       TypeError: 'coroutine' object is not iterable

opensearchpy/connection/base.py:165: TypeError
=============================== warnings summary ===============================
test_opensearchpy/test_async/test_transport.py:428
  test_opensearchpy/test_async/test_transport.py:428: PytestDeprecationWarning: test_sniff_after_n_seconds is asynchronous and explicitly requests the "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio.get_running_loop()" instead.
    async def test_sniff_after_n_seconds(self, event_loop: Any) -> None:

test_opensearchpy/test_async/test_transport.py:482
  test_opensearchpy/test_async/test_transport.py:482: PytestDeprecationWarning: test_sniff_on_start_error_if_no_sniffed_hosts is asynchronous and explicitly requests the "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio.get_running_loop()" instead.
    async def test_sniff_on_start_error_if_no_sniffed_hosts(

test_opensearchpy/test_async/test_transport.py:501
  test_opensearchpy/test_async/test_transport.py:501: PytestDeprecationWarning: test_sniff_on_start_waits_for_sniff_to_complete is asynchronous and explicitly requests the "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio.get_running_loop()" instead.
    async def test_sniff_on_start_waits_for_sniff_to_complete(

test_opensearchpy/test_async/test_transport.py:539
  test_opensearchpy/test_async/test_transport.py:539: PytestDeprecationWarning: test_sniff_on_start_close_unlocks_async_calls is asynchronous and explicitly requests the "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio.get_running_loop()" instead.
    async def test_sniff_on_start_close_unlocks_async_calls(

test_opensearchpy/test_async/test_helpers/test_faceted_search.py::test_date_histogram_facet_with_1970_01_01_date
test_opensearchpy/test_async/test_helpers/test_faceted_search.py::test_date_histogram_facet_with_1970_01_01_date
test_opensearchpy/test_helpers/test_faceted_search.py::test_date_histogram_facet_with_1970_01_01_date
test_opensearchpy/test_helpers/test_faceted_search.py::test_date_histogram_facet_with_1970_01_01_date
  /build/source/opensearchpy/helpers/faceted_search.py:227: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    return datetime.utcfromtimestamp(int(bucket["key"]) / 1000.0)  # type: ignore

test_opensearchpy/test_async/test_server_secured/test_security_plugin.py: 15 warnings
  /build/source/opensearchpy/_async/http_aiohttp.py:203: UserWarning: Connecting to https://localhost:9200 using SSL with verify_certs=False is insecure.
    warnings.warn(

test_opensearchpy/test_async/test_server_secured/test_security_plugin.py::TestSecurityPlugin::test_create_role
  /nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/linecache.py:52: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
    def checkcache(filename=None):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

test_opensearchpy/test_async/test_server_secured/test_security_plugin.py::TestSecurityPlugin::test_create_role
  /nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/traceback.py:265: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
    def __init__(self, filename, lineno, name, *, lookup_line=True,
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

test_opensearchpy/test_async/test_signer.py: 5 warnings
test_opensearchpy/test_connection/test_requests_http_connection.py: 5 warnings
test_opensearchpy/test_connection/test_urllib3_http_connection.py: 7 warnings
  /nix/store/7qs7b3cfsvxd806avf9am5qv57i7vf1f-python3.12-botocore-1.35.30/lib/python3.12/site-packages/botocore/auth.py:424: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    datetime_now = datetime.datetime.utcnow()

test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_create_one_point_in_time
  /build/source/opensearchpy/client/_patch.py:64: DeprecationWarning: The 'create_point_in_time' API is deprecated and will be removed in a future version. Use 'create_pit' API instead.
    warnings.warn(

test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_delete_all_point_in_time
test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_delete_one_point_in_time
  /build/source/opensearchpy/client/_patch.py:93: DeprecationWarning: The 'delete_point_in_time' API is deprecated and will be removed in a future version. Use 'delete_all_pits' or 'delete_pit' API instead.
    warnings.warn(

test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_list_all_point_in_time
  /build/source/opensearchpy/client/_patch.py:27: DeprecationWarning: The 'list_all_point_in_time' API is deprecated and will be removed in a future version. Use 'get_all_pits' API instead.
    warnings.warn(

test_opensearchpy/test_connection/test_urllib3_http_connection.py::TestUrllib3HttpConnection::test_uses_no_ca_certs
test_opensearchpy/test_connection/test_urllib3_http_connection.py::TestSignerWithFrozenCredentials::test_uses_no_ca_certs
  /build/source/opensearchpy/connection/http_urllib3.py:214: UserWarning: Connecting to https://localhost:9200 using SSL with verify_certs=False is insecure.
    warnings.warn(

test_opensearchpy/test_helpers/test_result.py::test_bucket_keys_get_deserialized
test_opensearchpy/test_helpers/test_result.py::test_bucket_keys_get_deserialized
test_opensearchpy/test_helpers/test_result.py::test_bucket_keys_get_deserialized
  /build/source/opensearchpy/helpers/field.py:295: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    return datetime.utcfromtimestamp(data / 1000.0)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED test_opensearchpy/test_async/test_http_connection.py::TestAsyncHttpConnection::test_basicauth_in_request_session - TypeError: 'coroutine' object is not iterable
FAILED test_opensearchpy/test_async/test_http_connection.py::TestAsyncHttpConnection::test_callable_in_request_session - TypeError: 'coroutine' object is not iterable
= 2 failed, 821 passed, 28 skipped, 2 deselected, 51 warnings in 220.02s (0:03:40) =
error: builder for '/nix/store/w8bwzlrk1brd4gj69gyh5zn0p7dkp587-python3.12-opensearch-py-2.7.1.drv' failed with exit code 1;
       last 50 log lines:
       >   /build/source/opensearchpy/_async/http_aiohttp.py:203: UserWarning: Connecting to https://localhost:9200 using SSL with verify_certs=False is insecure.
       >     warnings.warn(
       >
       > test_opensearchpy/test_async/test_server_secured/test_security_plugin.py::TestSecurityPlugin::test_create_role
       >   /nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/linecache.py:52: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
       >     def checkcache(filename=None):
       >   Enable tracemalloc to get traceback where the object was allocated.
       >   See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
       >
       > test_opensearchpy/test_async/test_server_secured/test_security_plugin.py::TestSecurityPlugin::test_create_role
       >   /nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/traceback.py:265: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
       >     def __init__(self, filename, lineno, name, *, lookup_line=True,
       >   Enable tracemalloc to get traceback where the object was allocated.
       >   See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
       >
       > test_opensearchpy/test_async/test_signer.py: 5 warnings
       > test_opensearchpy/test_connection/test_requests_http_connection.py: 5 warnings
       > test_opensearchpy/test_connection/test_urllib3_http_connection.py: 7 warnings
       >   /nix/store/7qs7b3cfsvxd806avf9am5qv57i7vf1f-python3.12-botocore-1.35.30/lib/python3.12/site-packages/botocore/auth.py:424: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
       >     datetime_now = datetime.datetime.utcnow()
       >
       > test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_create_one_point_in_time
       >   /build/source/opensearchpy/client/_patch.py:64: DeprecationWarning: The 'create_point_in_time' API is deprecated and will be removed in a future version. Use 'create_pit' API instead.
       >     warnings.warn(
       >
       > test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_delete_all_point_in_time
       > test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_delete_one_point_in_time
       >   /build/source/opensearchpy/client/_patch.py:93: DeprecationWarning: The 'delete_point_in_time' API is deprecated and will be removed in a future version. Use 'delete_all_pits' or 'delete_pit' API instead.
       >     warnings.warn(
       >
       > test_opensearchpy/test_client/test_point_in_time.py::TestPointInTime::test_list_all_point_in_time
       >   /build/source/opensearchpy/client/_patch.py:27: DeprecationWarning: The 'list_all_point_in_time' API is deprecated and will be removed in a future version. Use 'get_all_pits' API instead.
       >     warnings.warn(
       >
       > test_opensearchpy/test_connection/test_urllib3_http_connection.py::TestUrllib3HttpConnection::test_uses_no_ca_certs
       > test_opensearchpy/test_connection/test_urllib3_http_connection.py::TestSignerWithFrozenCredentials::test_uses_no_ca_certs
       >   /build/source/opensearchpy/connection/http_urllib3.py:214: UserWarning: Connecting to https://localhost:9200 using SSL with verify_certs=False is insecure.
       >     warnings.warn(
       >
       > test_opensearchpy/test_helpers/test_result.py::test_bucket_keys_get_deserialized
       > test_opensearchpy/test_helpers/test_result.py::test_bucket_keys_get_deserialized
       > test_opensearchpy/test_helpers/test_result.py::test_bucket_keys_get_deserialized
       >   /build/source/opensearchpy/helpers/field.py:295: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
       >     return datetime.utcfromtimestamp(data / 1000.0)
       >
       > -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
       > =========================== short test summary info ============================
       > FAILED test_opensearchpy/test_async/test_http_connection.py::TestAsyncHttpConnection::test_basicauth_in_request_session - TypeError: 'coroutine' object is not iterable
       > FAILED test_opensearchpy/test_async/test_http_connection.py::TestAsyncHttpConnection::test_callable_in_request_session - TypeError: 'coroutine' object is not iterable
       > = 2 failed, 821 passed, 28 skipped, 2 deselected, 51 warnings in 220.02s (0:03:40) =
@drupol drupol added bug Something isn't working untriaged Need triage labels Nov 20, 2024
@dblock
Copy link
Member

dblock commented Nov 20, 2024

Is this new? We had a passing CI 4 days ago.

@dblock dblock removed the untriaged Need triage label Nov 20, 2024
@drupol
Copy link
Author

drupol commented Nov 20, 2024

Sorry I have no clue, i have no experience with your package, I'm just fixing it Nix (NixOS/nixpkgs#357642).

@novmar
Copy link

novmar commented Nov 26, 2024

Hello,
@drupol did you solved that problem? i have same, when i am trying to build python3.12-opensearch-py-2.7.1

@drupol
Copy link
Author

drupol commented Nov 26, 2024

Somehow we fixed it by removing the broken tests from the package, see the thing at https://github.com/NixOS/nixpkgs/pull/357642/files#diff-080fddea0147db81623d702c1f6472c79886e769245bccd25489cfb9d2744dd5R82

@novmar
Copy link

novmar commented Nov 26, 2024

@drupol thank you, i'll wait till it drops to unstable.

@novmar
Copy link

novmar commented Nov 27, 2024

it is in nixos-unstable now.
(sorry for messing up opensearch issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants