|
| 1 | +.. _setup-matrix: |
| 2 | + |
| 3 | +=================== |
| 4 | + Test Setup Matrix |
| 5 | +=================== |
| 6 | + |
| 7 | +:Release: |version| |
| 8 | +:Date: |today| |
| 9 | + |
| 10 | +The plugin simplifies the setup of test environments by utilizing the |
| 11 | +`pytest fixtures mechanism <https://docs.pytest.org/en/latest/reference/fixtures.html#fixtures>`_ to configure |
| 12 | +each component of the test setup independently which allows for a high degree of flexibility in matching |
| 13 | +specific Celery architectures to each test case. |
| 14 | + |
| 15 | +In this guide we'll discuss how does the setup matrix work and how to use it. |
| 16 | + |
| 17 | +.. contents:: |
| 18 | + :local: |
| 19 | + :depth: 2 |
| 20 | + |
| 21 | +What is the setup matrix? |
| 22 | +========================= |
| 23 | + |
| 24 | +.. versionadded:: 1.0.0 |
| 25 | + |
| 26 | +The setup matrix is a combination of all of the possible Celery architectures that can be used |
| 27 | +with the available :ref:`vendors` for each test. It is automatically generated by the plugin |
| 28 | +to match the installed dependencies when using the default configuration, or it can be manually |
| 29 | +configured to set each test case separately. |
| 30 | + |
| 31 | +The matrix is configured using the :ref:`default-fixtures` of each component and is available |
| 32 | +to the test case using the :ref:`test-setup`. |
| 33 | + |
| 34 | +Common Setups |
| 35 | +============= |
| 36 | + |
| 37 | +.. versionadded:: 1.0.0 |
| 38 | + |
| 39 | +The following snippets show how to use the setup matrix to configure manual setups, overriding |
| 40 | +the default configuration using the built-in :ref:`vendors`. |
| 41 | + |
| 42 | +It may be used in conftest.py or in the test file itself. |
| 43 | + |
| 44 | +RabbitMQ Broker and No Backend |
| 45 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 46 | + |
| 47 | +1. Use only RabbitMQ as the broker. |
| 48 | + |
| 49 | +.. code-block:: python |
| 50 | +
|
| 51 | + @pytest.fixture |
| 52 | + def celery_broker_cluster(celery_rabbitmq_broker: RabbitMQTestBroker) -> CeleryBrokerCluster: |
| 53 | + cluster = CeleryBrokerCluster(celery_rabbitmq_broker) |
| 54 | + yield cluster |
| 55 | + cluster.teardown() |
| 56 | +
|
| 57 | +2. :ref:`Disable the backend <disable_backend>`. |
| 58 | + |
| 59 | +.. code-block:: python |
| 60 | +
|
| 61 | + @pytest.fixture |
| 62 | + def celery_backend_cluster(): |
| 63 | + return None |
| 64 | +
|
| 65 | +RabbitMQ Broker and Redis Backend |
| 66 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 67 | + |
| 68 | +1. Use only RabbitMQ as the broker. |
| 69 | + |
| 70 | +.. code-block:: python |
| 71 | +
|
| 72 | + @pytest.fixture |
| 73 | + def celery_broker_cluster(celery_rabbitmq_broker: RabbitMQTestBroker) -> CeleryBrokerCluster: |
| 74 | + cluster = CeleryBrokerCluster(celery_rabbitmq_broker) |
| 75 | + yield cluster |
| 76 | + cluster.teardown() |
| 77 | +
|
| 78 | +2. Use Redis as the backend. |
| 79 | + |
| 80 | +.. code-block:: python |
| 81 | +
|
| 82 | + @pytest.fixture |
| 83 | + def celery_backend_cluster(celery_redis_backend: RedisTestBackend) -> CeleryBackendCluster: |
| 84 | + cluster = CeleryBackendCluster(celery_redis_backend) |
| 85 | + yield cluster |
| 86 | + cluster.teardown() |
| 87 | +
|
| 88 | +Redis Broker and No Backend |
| 89 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 90 | + |
| 91 | +1. Use only Redis as the broker. |
| 92 | + |
| 93 | +.. code-block:: python |
| 94 | +
|
| 95 | + @pytest.fixture |
| 96 | + def celery_broker_cluster(celery_redis_broker: RedisTestBroker) -> CeleryBrokerCluster: |
| 97 | + cluster = CeleryBrokerCluster(celery_redis_broker) |
| 98 | + yield cluster |
| 99 | + cluster.teardown() |
| 100 | +
|
| 101 | +2. :ref:`Disable the backend <disable_backend>`. |
| 102 | + |
| 103 | +.. code-block:: python |
| 104 | +
|
| 105 | + @pytest.fixture |
| 106 | + def celery_backend_cluster(): |
| 107 | + return None |
| 108 | +
|
| 109 | +Redis Broker and Redis Backend |
| 110 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 111 | + |
| 112 | +1. Use only Redis as the broker. |
| 113 | + |
| 114 | +.. code-block:: python |
| 115 | +
|
| 116 | + @pytest.fixture |
| 117 | + def celery_broker_cluster(celery_redis_broker: RedisTestBroker) -> CeleryBrokerCluster: |
| 118 | + cluster = CeleryBrokerCluster(celery_redis_broker) |
| 119 | + yield cluster |
| 120 | + cluster.teardown() |
| 121 | +
|
| 122 | +2. Use Redis as the backend. |
| 123 | + |
| 124 | +.. code-block:: python |
| 125 | +
|
| 126 | + @pytest.fixture |
| 127 | + def celery_backend_cluster(celery_redis_backend: RedisTestBackend) -> CeleryBackendCluster: |
| 128 | + cluster = CeleryBackendCluster(celery_redis_backend) |
| 129 | + yield cluster |
| 130 | + cluster.teardown() |
0 commit comments