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

feat(redis): add AsyncRedis support #434

Closed
wants to merge 11 commits into from

Conversation

bearrito
Copy link
Contributor

@bearrito bearrito commented Feb 29, 2024

Adds support for async redis

Discussed somewhat here - #374

Tested in the recently fixed devcontainers.

(testcontainers-py3.11) vscode ➜ /workspaces/testcontainers-python (async-redis) $ poetry run pytest -v --cov=testcontainers.$* modules/redis/tests
====================================================================== test session starts =======================================================================
platform linux -- Python 3.11.8, pytest-7.4.3, pluggy-1.4.0 -- /home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/bin/python
cachedir: .pytest_cache
rootdir: /workspaces/testcontainers-python
configfile: pyproject.toml
plugins: cov-4.1.0, anyio-4.3.0
collected 6 items                                                                                                                                                

modules/redis/tests/test_redis.py::test_docker_run_redis 
------------------------------------------------------------------------- live log call --------------------------------------------------------------------------
INFO     testcontainers.core.container:container.py:63 Pulling image redis:latest
INFO     testcontainers.core.container:container.py:75 Container started: c79a46b1796e
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: c79a46b1796e> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: c79a46b1796e> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: c79a46b1796e> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: c79a46b1796e> with image redis:latest to be ready ...
PASSED                                                                                                                                                     [ 16%]
modules/redis/tests/test_redis.py::test_docker_run_redis_with_password 
------------------------------------------------------------------------- live log call --------------------------------------------------------------------------
INFO     testcontainers.core.container:container.py:63 Pulling image redis:latest
INFO     testcontainers.core.container:container.py:75 Container started: e76e6a81f80a
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: e76e6a81f80a> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: e76e6a81f80a> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: e76e6a81f80a> with image redis:latest to be ready ...
PASSED                                                                                                                                                     [ 33%]
modules/redis/tests/test_redis.py::test_key_set_in_async_redis[asyncio] 
------------------------------------------------------------------------- live log call --------------------------------------------------------------------------
INFO     testcontainers.core.container:container.py:63 Pulling image redis:latest
INFO     testcontainers.core.container:container.py:75 Container started: e648a9a48944
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: e648a9a48944> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: e648a9a48944> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: e648a9a48944> with image redis:latest to be ready ...
PASSED                                                                                                                                                     [ 50%]
modules/redis/tests/test_redis.py::test_docker_run_async_redis[asyncio] SKIPPED (Need to sort out async pub/sub)                                           [ 66%]
modules/redis/tests/test_redis.py::test_docker_run_async_redis_with_password[asyncio] 
------------------------------------------------------------------------- live log call --------------------------------------------------------------------------
INFO     testcontainers.core.container:container.py:63 Pulling image redis:latest
INFO     testcontainers.core.container:container.py:75 Container started: 5587e82c125f
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: 5587e82c125f> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: 5587e82c125f> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: 5587e82c125f> with image redis:latest to be ready ...
PASSED                                                                                                                                                     [ 83%]
modules/redis/tests/test_redis.py::test_key_set_in_async[asyncio] 
------------------------------------------------------------------------- live log call --------------------------------------------------------------------------
INFO     testcontainers.core.container:container.py:63 Pulling image redis:latest
INFO     testcontainers.core.container:container.py:75 Container started: cc514d9a57f5
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: cc514d9a57f5> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: cc514d9a57f5> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: cc514d9a57f5> with image redis:latest to be ready ...
INFO     testcontainers.core.waiting_utils:waiting_utils.py:52 Waiting for container <Container: cc514d9a57f5> with image redis:latest to be ready ...
PASSED                                                                                                                                                     [100%]/home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/lib/python3.11/site-packages/coverage/inorout.py:503: CoverageWarning: Module testcontainers. was never imported. (module-not-imported)
  self.warn(f"Module {pkg} was never imported.", slug="module-not-imported")
/home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/lib/python3.11/site-packages/coverage/control.py:885: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
WARNING: Failed to generate report: No data to report.

/home/vscode/.cache/pypoetry/virtualenvs/testcontainers-_53phrdA-py3.11/lib/python3.11/site-packages/pytest_cov/plugin.py:312: CovReportWarning: Failed to generate report: No data to report.

  warnings.warn(CovReportWarning(message))


---------- coverage: platform linux, python 3.11.8-final-0 -----------


================================================================== 5 passed, 1 skipped in 4.15s ==================================================================

There is currently no working tests for pub/sub.

@bearrito bearrito changed the title Adds AsyncRedis support feat: Adds AsyncRedis support Feb 29, 2024
@totallyzen
Copy link
Collaborator

hey @bearrito thanks for the contrib! Apologies for the failures on the different module things, I'll double check my mistake on it. Will fix so you can rebase and have your checks passing! :)

@bearrito
Copy link
Contributor Author

bearrito commented Mar 1, 2024

@totallyzen I'm 99% sure I did the wrong thing with dependencies. I can see they should go under the module group extras.

In another issue (#436) I'm trying to create a new module.
But am having trouble with module discovery and therefore dependency management.

I think the docs are out of date on this - https://testcontainers-python.readthedocs.io/en/latest/README.html

pyproject.toml Outdated
Comment on lines 86 to 87
anyio = "^4.3.0"
pre-commit = "^3.6.2"
Copy link
Collaborator

@totallyzen totallyzen Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these,

  • make anyio a dev dependency for now - you don't actually need anyio to run redis
  • I tend not to install pre-commit under poetry because then you will need poetry-ception - just use pip install pre-commit for that one!
  • the rest should be fine, and in fact after fix(build): early exit strategy for modules #437 you seem to be just fine so fixing these two should be all you need.

@totallyzen
Copy link
Collaborator

I fixed the early-exit strat in #437 - was a doozy but I'm happy with the results! (dynamic matrix, no errors!)

@totallyzen totallyzen changed the title feat: Adds AsyncRedis support feat(redis): add AsyncRedis support Mar 1, 2024
@bearrito
Copy link
Contributor Author

bearrito commented Mar 2, 2024

Updated.

max-pfeiffer and others added 6 commits March 4, 2024 18:56
…v and CI (testcontainers#438)

I could not install pre-commit handler because the package was missing
in [tool.poetry.group.dev.dependencies].

I also updated the configuration for the pre-commit handler as black and
ruff packages were outdated. Also removed deprecation for ruff v0.3.0
config in pyproject.toml.

---------

Co-authored-by: Balint Bartha <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants