Open kloczek opened 4 months ago
Something should be started on localhost before start testing? 🤔
And in attachment ful pytest output python-aiobotocore.FAIL.txt
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.
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
Looks like there is some progress with moto 5.x https://github.com/aio-libs/aiobotocore/commit/1b66a7a76e095c09c816d70bdda6a1d623fa6539. Thank you!
ya there are a bunch of errors still to go through. if you have time help appreciated!
Describe the bug A clear and concise description of what the bug is.
Checklist
pip check
passes without errorspip freeze
resultsI'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.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulesinstaller
modulecut off from access to the public network
(pytest is executed with-m "not network"
)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.