Skip to content

Integration test: Celery error, state and revoke paths #2404

@berendt

Description

@berendt

Part of #2400. Follow-up to #2368.

What

Extend the Celery coverage beyond the existing noop round-trip (test_celery.py), using the celery_worker fixture and focusing on the result backend and task lifecycle.

Scope

  • A task that raises propagates the exception through AsyncResult.get() (and result.failed() / .state == "FAILURE").
  • Task state transitions: with task_track_started = True (set in the Config in osism/tasks/__init__.py), a started task reports STARTED before SUCCESS.
  • osism.utils.revoke_task(task_id) (osism/utils/__init__.py:421) revokes a running task; assert it ends up REVOKED and returns True.

Notes / Where

Add to tests/integration/test_celery.py (or a new test_celery_lifecycle.py). The ansible Celery app is the only one safe to import in CI (no NetBox / OpenStack / ansible-core import-time deps) — reuse it.

Constraint to be aware of: the worker runs in a separate process started from osism.tasks.ansible, so it only knows tasks registered in that module. A test-only task defined inside the test file is not registered in the worker. The revoke test therefore needs a short-lived blocking task that genuinely exists on the ansible app; if none is suitable, define a tiny test-only task in the ansible module guarded for test use, or skip the revoke part with a clear note.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions