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.
Part of #2400. Follow-up to #2368.
What
Extend the Celery coverage beyond the existing noop round-trip (
test_celery.py), using thecelery_workerfixture and focusing on the result backend and task lifecycle.Scope
AsyncResult.get()(andresult.failed()/.state == "FAILURE").task_track_started = True(set in theConfiginosism/tasks/__init__.py), a started task reportsSTARTEDbeforeSUCCESS.osism.utils.revoke_task(task_id)(osism/utils/__init__.py:421) revokes a running task; assert it ends upREVOKEDand returnsTrue.Notes / Where
Add to
tests/integration/test_celery.py(or a newtest_celery_lifecycle.py). TheansibleCelery 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 theansibleapp; if none is suitable, define a tiny test-only task in theansiblemodule guarded for test use, or skip the revoke part with a clear note.