Skip to content

Releases: celery/pytest-celery

v1.0.0

11 Apr 23:55
cab6df7
Compare
Choose a tag to compare

v1.0.0 Official Release

User Manual: https://pytest-celery.readthedocs.io/en/latest/
PyPI: https://pypi.org/project/pytest-celery/
Source: https://github.com/celery/pytest-celery/

Install with pip install -U "pytest-celery[all]".

Key Highlights

Simple

The plugin provides a single entry point to the test case and makes sure everything is configured according to the selected architecture and requirements.

By default, all of the supported architecture components are added to a matrix of all possible combinations.
Pytest will generate a test case for each combination, and will run it in an isolated environment.

This allows separation of concerns, and makes it simple to access different architectures in a single test case, for example:

def test_hello_world(celery_setup: CeleryTestSetup):
    assert celery_setup.ready()

This code will generate test cases for all possible combinations of the supported brokers and backends, using the latest
version of Celery. Under the context of the test, each combination will be available as a celery_setup fixture,
with access to all of the required components, and will run in an isolated environment.

Flexible

The plugin is highly configurable, and can be used to test a wide range of Celery architectures.
It can be configured to use a specific version of Celery, or to use a specific version of a broker or backend.
It can also be configured to use a custom broker or backend, or to use a custom Celery application.

For basic usage, the plugin provides default components that can be configured and extended.

For more advanced use cases, the plugin uses the pytest fixtures mechanism to allow injecting custom components into the environment and build a custom Celery architecture for your project.

For example, see the rabbitmq-management example, which demonstrates how to replace the default broker matrix with a single RabbitMQ Management broker.

Fast

The plugin is designed to run tests in parallel using isolated environments. It supports the pytest-xdist plugin to run tests in parallel and scales well with available resources to improve the overall test suite performance.

Annotated

The codebase is fully annotated with type hints and is tested with mypy to ensure type safety across the board, allowing for a better development experience.

Supports

  • Workers

    • Latest Celery version.
    • Custom worker.
  • Brokers

    • RabbitMQ.
    • Redis.
    • Custom broker.
  • Backends

    • Redis.
    • Memcached.
    • Custom backend.
  • Clusters

    • Worker clusters.
    • Broker clusters.
    • Backend clusters.

Features

Architecture Injection

By default, a set of predefined components is used to build the Celery architecture for each test.
Each built-in component can be either configured or completely replaced with a custom implementation.

Architecture Injection can be done at different layers, and can be used to replace only specific elements of the architecture pipeline, or to replace the entire pipeline altogether.

Docker Based

The plugin uses docker containers to build the Celery architecture for each test.
This means that the plugin is not limited to specific versions and can be used to test potentially any Celery setup.

It uses the pytest-docker-tools plugin to manage the docker containers which is useful for accessing the docker containers in the test case during the test run and assert on their state with high granularity.

Batteries Included

The plugin provides a set of built-in components that can be used to test ideas quickly.
You can start with the default settings and gradually modify the configurations to fine-tune the test environment. By focusing on the test case, you can quickly iterate and test ideas, without wasting time on the overhead of setting up different environments manually.

Code Generation

One of the challenges in testing production Celery applications is the need to inject testing infrastructure into the Celery worker container at runtime. The plugin provides a Code Generation mechanism that can be used to inject code into the Celery worker container at runtime according to the test case. This opens the door to a wide range of testing scenarios, and allows higher level of control over the tested Celery application.

Isolated Environments

Each test case is executed in an isolated environment. This means that each test case has its own Celery architecture, and is not affected by other test cases. Tests may run in parallel and take care of tearing down themselves when they are done, regardless of the test result.

Tests as First-Class Citizens

The plugin is designed to enhance testing capabilities by treating tests as first-class citizens. It uses advanced mechanisms to encapsulate the complexity of setting up a Celery environment, thus allowing the developer to focus on the test case itself and leave the hard lifting to the plugin.

Extensible

The plugin is designed to be extensible to fit a wide range of use cases and provides a set of built-in components that can be extended to fit more advanced use cases.

It's based on the S.O.L.I.D principles and provides APIs for developing high-quality test suites. It combines the sophistication of the pytest fixtures mechanism with OOP principles to create separation of concerns between each layer of the infrastructure and its elements, which allow a higher level of granularity and control when extending the plugin.

What's Changed

Full Changelog: v1.0.0rc4...v1.0.0

v1.0.0rc4

11 Apr 21:57
6591cfd
Compare
Choose a tag to compare
v1.0.0rc4 Pre-release
Pre-release

What's Changed

Full Changelog: v1.0.0rc3...v1.0.0rc4

v1.0.0rc3

05 Apr 16:13
24c7e99
Compare
Choose a tag to compare
v1.0.0rc3 Pre-release
Pre-release

What's Changed

Full Changelog: v1.0.0rc2...v1.0.0rc3

v1.0.0rc2

27 Mar 12:06
4a64360
Compare
Choose a tag to compare
v1.0.0rc2 Pre-release
Pre-release

What's Changed

Full Changelog: v1.0.0rc1...v1.0.0rc2

v1.0.0rc1

20 Mar 15:44
b43f739
Compare
Choose a tag to compare
v1.0.0rc1 Pre-release
Pre-release

After so long, the first release candidate for v1.0.0 !

Highlights

  • Getting Started documentation is ready!
  • User Guide documentation is ready!
  • New Examples
    • worker_pool: Using gevent and solo pools.
    • vhost: Using a single Redis instance for both broker & backend, each on different vhost.
    • hybrid_setup: Executing a canvas on Celery 5 and Celery 4 workers, collaborating to process their respective segments of the workflow. This involves utilizing distinct pools and queues, along with two brokers set up with failover configurations.

In addition, the documentation provides a new way to report a Celery bug, which will be integrated into the standard bug report template at a later stage: Standalone Celery Bug Report.

Lastly, from now on, the release dates for the plugin will be described on the Milestones page.

What's Changed

Full Changelog: v1.0.0b4...v1.0.0rc1

v1.0.0b4

11 Mar 14:22
a451140
Compare
Choose a tag to compare
v1.0.0b4 Pre-release
Pre-release

What's Changed

Full Changelog: v1.0.0b3...v1.0.0b4

v1.0.0b3

09 Mar 08:41
d5ef231
Compare
Choose a tag to compare
v1.0.0b3 Pre-release
Pre-release

The celery package is now installed by default again, reverting the decision from v1.0.0b2.

To install the plugin in your environment, please follow the new Advanced Installation Guide.

What's Changed

Full Changelog: v1.0.0b2...v1.0.0b3

v1.0.0b2

12 Feb 23:41
5b5ca39
Compare
Choose a tag to compare
v1.0.0b2 Pre-release
Pre-release

Celery is no longer installed by default. Install manually in your test environment, or use the “celery” extra.

  • Do not install Celery by default, use extra [celery] instead by @Nusnus in #172

What's Changed

  • Bump sphinx-celery from 2.1.1 to 2.1.3 by @dependabot in #168
  • Added examples/range by @Nusnus in #169
  • Added examples/rabbitmq_management by @Nusnus in #170
  • Cleanups and hotfixes by @Nusnus in #171
  • Do not install Celery by default, use extra [celery] instead by @Nusnus in #172
  • Fixed pip deprecation warning about egg fragment with a non-PEP 508 name by @Nusnus in #173
  • Reduced installed packages in tox and CI by @Nusnus in #174
  • Bump black from 23.12.1 to 24.1.0 by @dependabot in #175
  • Packages upgrade by @Nusnus in #176
  • [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in #178
  • Added initial devguide by @Nusnus in #179
  • Bump pytest-sugar from 0.9.7 to 1.0.0 by @dependabot in #181
  • Fix typos discovered by codespell by @cclauss in #183
  • Added codespell to pre-commit by @Nusnus in #184
  • Enhancing Pytest Celery with BSD-Licensed Software by @imSanko in #185
  • Upgrade to codecov/codecov-action@v4 by @cclauss in #186
  • Initial Getting Started tutorial by @Nusnus in #187
  • [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in #188
  • Moved examples from getting-started to userguide by @Nusnus in #189
  • Added “Next-Steps” to the Getting Started tutorial by @Nusnus in #190
  • Hotfix: Moved "Useful Resources" from "Getting Started" to "User Guide" by @Nusnus in #191
  • Documentation Enhancement by @Nusnus in #192
  • Added documentation to all vendors fixtures by @Nusnus in #193
  • Revert "Upgrade to codecov/codecov-action@v4" by @Nusnus in #195
  • Bump setuptools from 69.0.3 to 69.1.0 by @dependabot in #194
  • Bump codecov/codecov-action from 3 to 4 by @dependabot in #180
  • Bugfix: Disabled clusters raised exception on access from setup instead of returning None by @Nusnus in #196
  • Bugfix: Disabled clusters raised exception on len(celery_setup) by @Nusnus in #197
  • Bugfix: Typo celery_version -> default_worker_celery_version in range example by @Nusnus in #198
  • Bugfix: Renamed env() -> initial_env() by @Nusnus in #199
  • Removed pytest-lazy-fixture dependency by @Nusnus in #200
  • Bump pytest from 7.4.4 to 8.0.0 by @dependabot in #177
  • Prepare for (pre) release: v1.0.0b2 by @Nusnus in #201

New Contributors

Full Changelog: v1.0.0b1...v1.0.0b2

v1.0.0b1

14 Jan 18:04
22ad9bc
Compare
Choose a tag to compare
v1.0.0b1 Pre-release
Pre-release

First beta version!
Featuring the MVP requirements for Celery’s new smoke tests.

v1.0.0a12 [YANKED]

08 Jan 03:25
f9085ae
Compare
Choose a tag to compare
v1.0.0a12 [YANKED] Pre-release
Pre-release

What's Changed

Full Changelog: v1.0.0a11...v1.0.0a12