aio-libs / aiobotocore

asyncio support for botocore library using aiohttp
https://aiobotocore.rtfd.io
Apache License 2.0
1.14k stars 179 forks source link

2.12.3: pytest fails #1108

Open kloczek opened 4 months ago

kloczek commented 4 months ago

Describe the bug A clear and concise description of what the bug is.

Checklist

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

List of installed modules in build env: ```console Package Version ----------------------------- ----------- aiohttp 3.9.3 aioitertools 0.11.0 aiosignal 1.3.1 alabaster 0.7.16 async-timeout 4.0.3 attrs 23.2.0 Babel 2.14.0 blinker 1.7.0 boto3 1.34.84 botocore 1.34.84 build 1.2.1 cffi 1.16.0 charset-normalizer 3.3.2 click 8.1.7 cryptography 42.0.5 dill 0.3.8 docker 7.0.0 docutils 0.20.1 exceptiongroup 1.1.3 Flask 3.0.3 Flask-Cors 4.0.0 frozenlist 1.4.1 idna 3.7 imagesize 1.4.1 importlib_metadata 7.1.0 iniconfig 2.0.0 installer 0.7.0 itsdangerous 2.1.2 Jinja2 3.1.3 jmespath 1.0.1 jsonschema 4.20.0 jsonschema-path 0.3.2 jsonschema-specifications 2023.12.1 lazy-object-proxy 1.10.0 MarkupSafe 2.1.5 moto 4.1.0.dev0 multidict 6.0.5 openapi-schema-validator 0.6.2 openapi-spec-validator 0.7.1 packaging 24.0 pathable 0.4.3 pluggy 1.4.0 ply 3.11 pycparser 2.22 Pygments 2.17.2 pyproject_hooks 1.0.0 pytest 8.1.1 pytest-asyncio 0.23.6 python-dateutil 2.9.0.post0 PyYAML 6.0.1 referencing 0.32.0 requests 2.31.0 responses 0.25.0 rfc3339_validator 0.1.4 rpds-py 0.18.0 s3transfer 0.10.1 setuptools 69.4.0 snowballstemmer 2.2.0 Sphinx 7.2.6 sphinxcontrib-applehelp 1.0.8 sphinxcontrib-devhelp 1.0.6 sphinxcontrib-htmlhelp 2.0.5 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.7 sphinxcontrib-serializinghtml 1.1.10 tokenize_rt 5.2.0 tomli 2.0.1 typing_extensions 4.11.0 urllib3 2.2.1 Werkzeug 3.0.2 wheel 0.43.0 wrapt 1.16.0 xmltodict 0.13.0 yarl 1.9.4 zipp 3.18.1 ```

Please let me know if you need more details or want me to perform some diagnostics.

kloczek commented 4 months ago

Something should be started on localhost before start testing? 🤔

Here is pytest summary output: ```console ================================================================================== short test summary info ================================================================================== XFAIL tests/test_basic_s3.py::test_put_object_sha256[False-https] - moto does not yet support Checksum: https://github.com/spulec/moto/issues/5719 XFAIL tests/test_basic_s3.py::test_put_object_sha256[False-https] - moto does not yet support Checksum: https://github.com/spulec/moto/issues/5719 ERROR tests/test_basic_s3.py::test_can_get_bucket_location - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:58557/ybtodjnqwzlaichpefvxsumgkr" ERROR tests/test_basic_s3.py::test_can_get_bucket_location - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:58557/ybtodjnqwzlaichpefvxsumgkr?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_delete_urlencoded_object - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:34151/ohmfxlgawkruqzipnejybdvcst" ERROR tests/test_basic_s3.py::test_can_delete_urlencoded_object - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:34151/ohmfxlgawkruqzipnejybdvcst?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_paginate - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:50193/cakuiyqdfvpbwghlzmeosrnxtj" ERROR tests/test_basic_s3.py::test_can_paginate - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:50193/cakuiyqdfvpbwghlzmeosrnxtj?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_paginate_with_page_size - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:42695/eljwkdtgorpymhnzcvfquxsbai" ERROR tests/test_basic_s3.py::test_can_paginate_with_page_size - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:42695/eljwkdtgorpymhnzcvfquxsbai?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_search_paginate - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:44009/ybwrvqdtnfazjimhkcpoxlsueg" ERROR tests/test_basic_s3.py::test_can_search_paginate - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:44009/ybwrvqdtnfazjimhkcpoxlsueg?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_paginate_iterator - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:48513/dczrubqnwetoyiskvmghpxjalf" ERROR tests/test_basic_s3.py::test_can_paginate_iterator - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:48513/dczrubqnwetoyiskvmghpxjalf?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_result_key_iters - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:42873/cxdybsrfqtapvehjunkiglwmoz" ERROR tests/test_basic_s3.py::test_result_key_iters - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:42873/cxdybsrfqtapvehjunkiglwmoz?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_get_and_put_object - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53283/huwprtjdaqxigolsezbfncmvky" ERROR tests/test_basic_s3.py::test_can_get_and_put_object - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53283/huwprtjdaqxigolsezbfncmvky?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_adaptive_retry - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:55537/yiphswuqmjaonefbxzcvdrtklg" ERROR tests/test_basic_s3.py::test_adaptive_retry - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:55537/yiphswuqmjaonefbxzcvdrtklg?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_get_object_stream_wrapper - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:38019/keucinvgxbjosatzqdrhwpylmf" ERROR tests/test_basic_s3.py::test_get_object_stream_wrapper - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:38019/keucinvgxbjosatzqdrhwpylmf?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_get_object_stream_context - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:40089/hsdptiynbwumrflcvxgakeozjq" ERROR tests/test_basic_s3.py::test_get_object_stream_context - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:40089/hsdptiynbwumrflcvxgakeozjq?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_paginate_max_items - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:39889/jatxezksfcdwunqlyvhrobmipg" ERROR tests/test_basic_s3.py::test_paginate_max_items - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:39889/jatxezksfcdwunqlyvhrobmipg?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_paginate_within_page_boundaries - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:39313/xdytrasozkmgivbnlqufhpcejw" ERROR tests/test_basic_s3.py::test_paginate_within_page_boundaries - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:39313/xdytrasozkmgivbnlqufhpcejw?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_non_normalized_key_paths - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:40289/ciqtwpluxjbrvzefhymgsnakod" ERROR tests/test_basic_s3.py::test_non_normalized_key_paths - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:40289/ciqtwpluxjbrvzefhymgsnakod?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_copy_with_quoted_char - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:52523/thsozalrnxicfejqywmpudbkvg" ERROR tests/test_basic_s3.py::test_copy_with_quoted_char - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:52523/thsozalrnxicfejqywmpudbkvg?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_copy_with_query_string - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53915/lqtjnpdfuowigkmvyrsbcahzex" ERROR tests/test_basic_s3.py::test_copy_with_query_string - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53915/lqtjnpdfuowigkmvyrsbcahzex?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_copy_with_dict_form - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:44801/nxkaotfjqwdyvbrzmhcilgeups" ERROR tests/test_basic_s3.py::test_can_copy_with_dict_form - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:44801/nxkaotfjqwdyvbrzmhcilgeups?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_can_copy_with_dict_form_with_version - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53651/yshgivkjlnprwequtzfcdambox" ERROR tests/test_basic_s3.py::test_can_copy_with_dict_form_with_version - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53651/yshgivkjlnprwequtzfcdambox?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_copy_with_s3_metadata - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:50131/nrcphykoiutdsvgzfwqxjaelbm" ERROR tests/test_basic_s3.py::test_copy_with_s3_metadata - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:50131/nrcphykoiutdsvgzfwqxjaelbm?versions&prefix=&encoding-type=url" ERROR tests/test_basic_s3.py::test_head_object_keys[s3v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:57279/hknxbczrgtyiwsomluqejpadfv" ERROR tests/test_basic_s3.py::test_head_object_keys[s3v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:57279/hknxbczrgtyiwsomluqejpadfv?versions&prefix=&encoding-type=url" ERROR tests/test_dynamodb.py::test_get_item[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:37679/" ERROR tests/test_dynamodb.py::test_get_item[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:37679/" ERROR tests/test_dynamodb.py::test_batch_write_scan[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:39433/" ERROR tests/test_dynamodb.py::test_batch_write_scan[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:39433/" ERROR tests/test_sns.py::test_topic_attributes - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:36799/" ERROR tests/test_sns.py::test_topic_attributes - botocore.exceptions.ParamValidationError: Parameter validation failed: ERROR tests/test_sns.py::test_creating_subscription - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:47047/" ERROR tests/test_sns.py::test_creating_subscription - botocore.exceptions.ParamValidationError: Parameter validation failed: ERROR tests/test_sns.py::test_publish_to_http - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:43591/" ERROR tests/test_sns.py::test_publish_to_http - botocore.exceptions.ParamValidationError: Parameter validation failed: ERROR tests/test_sqs.py::test_list_queues - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:36499/" ERROR tests/test_sqs.py::test_get_queue_name - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:33881/" ERROR tests/test_sqs.py::test_put_pull_delete_test - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:48055/" ERROR tests/test_sqs.py::test_put_pull_wait - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:47327/" FAILED tests/test_basic_s3.py::test_can_make_request - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:41419/" FAILED tests/test_basic_s3.py::test_can_make_request_no_verify[False] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:40971/" FAILED tests/test_batch.py::test_batch - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:57597/v1/describejobqueues" FAILED tests/test_dynamodb.py::test_create_waiter[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:39859/" FAILED tests/test_dynamodb.py::test_delete_table[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:40409/" FAILED tests/test_dynamodb.py::test_waiter_table_exists_failure[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53991/" FAILED tests/test_dynamodb.py::test_waiter_table_exists[v4] - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:43203/" FAILED tests/test_ec2.py::test_ec2_snapshot - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:60839/" FAILED tests/test_lambda.py::test_run_lambda - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:48791/" FAILED tests/test_monitor.py::test_monitor_response_received - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53401/" FAILED tests/test_patches.py::test_patches - assert False FAILED tests/test_sns.py::test_get_missing_endpoint_attributes - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:46935/" FAILED tests/test_sns.py::test_platform_applications - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:53159/" FAILED tests/test_waiter.py::test_sqs - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:35737/" =============================================== 14 failed, 141 passed, 22 deselected, 2 xfailed, 126 warnings, 54 errors in 702.50s (0:11:42) =============================================== ```

And in attachment ful pytest output python-aiobotocore.FAIL.txt

yan12125 commented 3 months ago

I got similar test failures. It seems the actual error is here:

  Traceback (most recent call last):
    File "/usr/lib64/python3.10/threading.py", line 1016, in _bootstrap_inner
      self.run()
    File "/usr/lib64/python3.10/threading.py", line 953, in run
      self._target(*self._args, **self._kwargs)
    File "/home/tkloczko/rpmbuild/BUILD/aiobotocore-2.12.3/tests/moto_server.py", line 97, in _server_entry
      self._main_app = moto.server.DomainDispatcherApplication(
  TypeError: DomainDispatcherApplication.__init__() got an unexpected keyword argument 'service'

The service argument is dropped in moto 5.0 (https://github.com/getmoto/moto/pull/7220). I got those errors with moto 5.0.5. Not sure why you also got them with moto 4.1.0.dev0.

yan12125 commented 3 months ago

It seems moto 5.x only allows auto detection of used AWS services from URLs (see infer_service_region_host and get_backend_for_host functions in moto.server.DomainDispatcherApplication), while some tests simply use http://127.0.0.1:random_port/ as the URL. As a result, moto cannot mock desired responses. I can get tests working by monkey patching moto to add back the functionality removed in https://github.com/getmoto/moto/pull/7220:

diff --git a/tests/moto_server.py b/tests/moto_server.py
index 7807401..8ce738a 100644
--- a/tests/moto_server.py
+++ b/tests/moto_server.py
@@ -28,6 +28,17 @@ def get_free_tcp_port(release_socket: bool = False):
     return sckt, port

+class DomainDispatcherApplication(moto.server.DomainDispatcherApplication):
+    def __init__(self, create_app, service):
+        super().__init__(create_app)
+        self.service = service
+
+    def get_backend_for_host(self, host):
+        if self.service:
+            return self.service
+
+        return super().get_backend_for_host(host)
+
 class MotoService:
     """Will Create MotoService.
     Service is ref-counted so there will only be one per process. Real Service will
@@ -94,7 +105,7 @@ class MotoService:
             await self._stop()

     def _server_entry(self):
-        self._main_app = moto.server.DomainDispatcherApplication(
+        self._main_app = DomainDispatcherApplication(
             moto.server.create_backend_app, service=self._service_name
         )
         self._main_app.debug = True
yan12125 commented 3 weeks ago

Looks like there is some progress with moto 5.x https://github.com/aio-libs/aiobotocore/commit/1b66a7a76e095c09c816d70bdda6a1d623fa6539. Thank you!

thehesiod commented 3 weeks ago

ya there are a bunch of errors still to go through. if you have time help appreciated!