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

Improvements to the hybrid_setup example #400

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/userguide/examples/hybrid_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ The following diagram lists the relevant files in the project.
├── test_hybrid_setup.py
└── vendors/
├── __init__.py
├── memcached.py
├── rabbitmq.py
├── redis_backend.py
└── workers/
├── __init__.py
├── gevent.Dockerfile
Expand Down Expand Up @@ -119,8 +119,8 @@ For this example, we have the following test cases.
in the failover test case. When used without the :func:`celery_setup <pytest_celery.fixtures.setup.celery_setup>`
fixture, the components will run independently and might not be aware of each other.

rabbitmq.py and memcached.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rabbitmq.py and redis_backend.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The brokers and result backend are defined as independent components that are being configured into the setup
using the ``conftest.py`` file. They add **session scope** fixtures and integrate using the matching :ref:`node class <test-nodes>`.
Expand All @@ -135,9 +135,9 @@ Main | Failover Brokers
Result Backend
--------------

.. literalinclude:: ../../../examples/hybrid_setup/tests/vendors/memcached.py
.. literalinclude:: ../../../examples/hybrid_setup/tests/vendors/redis_backend.py
:language: python
:caption: examples.hybrid_setup.tests.vendors.memcached.py
:caption: examples.hybrid_setup.tests.vendors.redis_backend.py

gevent.py and gevent.Dockerfile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion examples/hybrid_setup/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pytest>=7.4.4
pytest-xdist>=3.5.0
pytest-subtests>=0.11.0
pytest-rerunfailures>=14.0
celery[gevent]
celery[gevent]>=5.5.0b3
pytest-celery[all]@git+https://github.com/celery/pytest-celery.git
8 changes: 4 additions & 4 deletions examples/hybrid_setup/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from pytest_celery import CeleryBrokerCluster
from pytest_celery import CeleryTestWorker
from pytest_celery import CeleryWorkerCluster
from pytest_celery import MemcachedTestBackend
from tests.vendors.memcached import *
from pytest_celery import RedisTestBackend
from tests.vendors.rabbitmq import *
from tests.vendors.redis_backend import *
from tests.vendors.workers.gevent import *
from tests.vendors.workers.legacy import *

Expand All @@ -34,8 +34,8 @@ def celery_broker_cluster(


@pytest.fixture
def celery_backend_cluster(session_memcached_backend: MemcachedTestBackend) -> CeleryBackendCluster:
cluster = CeleryBackendCluster(session_memcached_backend)
def celery_backend_cluster(session_redis_backend: RedisTestBackend) -> CeleryBackendCluster:
cluster = CeleryBackendCluster(session_redis_backend)
yield cluster
cluster.teardown()

Expand Down
29 changes: 0 additions & 29 deletions examples/hybrid_setup/tests/vendors/memcached.py

This file was deleted.

29 changes: 29 additions & 0 deletions examples/hybrid_setup/tests/vendors/redis_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
from pytest_docker_tools import container
from pytest_docker_tools import fetch

from pytest_celery import REDIS_CONTAINER_TIMEOUT
from pytest_celery import REDIS_ENV
from pytest_celery import REDIS_IMAGE
from pytest_celery import REDIS_PORTS
from pytest_celery import RedisContainer
from pytest_celery import RedisTestBackend

redis_image = fetch(repository=REDIS_IMAGE)
redis_test_container = container(
# name="Redis-Session-Backend", # Optional | Incompatible with parallel execution
image="{redis_image.id}",
scope="session",
ports=REDIS_PORTS,
environment=REDIS_ENV,
network="{hybrid_setup_example_network.name}",
wrapper_class=RedisContainer,
timeout=REDIS_CONTAINER_TIMEOUT,
)


@pytest.fixture
def session_redis_backend(redis_test_container: RedisContainer) -> RedisTestBackend:
backend = RedisTestBackend(redis_test_container)
yield backend
backend.teardown()
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ENV WORKER_QUEUE=$CELERY_WORKER_QUEUE

# Install packages
RUN pip install --no-cache-dir --upgrade pip
RUN pip install "celery[gevent]" "pytest-celery[all]==1.0.0"
RUN pip install "celery[gevent]>=5.5.0b3" "pytest-celery[all]>=1.0.0"

# The workdir must be /app
WORKDIR /app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ENV WORKER_QUEUE=$CELERY_WORKER_QUEUE

# Install packages
RUN pip install --no-cache-dir --upgrade pip \
celery==4.4.7 "pytest-celery[all]==1.0.0"
celery==4.4.7 "pytest-celery[all]>=1.0.0"

# The workdir must be /app
WORKDIR /app
Expand Down