Files
FabledCurator/tests/test_celery_routing.py
T
bvandeusenandClaude Opus 5.5 058fa85606
CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 3s
CI and images / frontend-build (push) Successful in 21s
CI and images / backend-lint-and-test (push) Successful in 33s
CI and images / integration (push) Successful in 2m21s
CI and images / sign-extension (push) Successful in 4s
CI and images / build-agent (push) Successful in 6s
CI and images / build-web (push) Successful in 1m47s
CI and images / smoke-web (push) Successful in 55s
CI and images / promote (push) Successful in 1s
fix: backfill_phash runs on the long maintenance lane, not the scheduler's quick one (4411)
A whole-library rehash with a 35-minute limit was matched by the
maintenance.* glob. It held a scheduler process for its whole run, and the
minute ticks queued behind it. An exact-name route now sends it to
maintenance_long.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR
2026-09-24 19:26:48 -04:00

53 lines
2.0 KiB
Python

"""Queue routing — the long one-shot maintenance tasks run on a dedicated
`maintenance_long` lane so a 30-min backup or a multi-chunk audit can't starve
the quick recovery sweeps / vacuum on the concurrency-1 `maintenance` lane
(operator-flagged 2026-06-07)."""
from backend.app.celery_app import celery
def test_long_one_shots_route_to_maintenance_long():
routes = celery.conf.task_routes
for prefix in (
"backend.app.tasks.backup.*",
"backend.app.tasks.admin.*",
"backend.app.tasks.library_audit.*",
):
assert routes[prefix]["queue"] == "maintenance_long"
def test_quick_maintenance_stays_on_maintenance():
routes = celery.conf.task_routes
assert routes["backend.app.tasks.maintenance.*"]["queue"] == "maintenance"
def test_queue_for_mirrors_external_to_download():
"""celery_signals._queue_for is a hand-maintained mirror of task_routes
that stamps TaskRun.queue. external.* routes to the download lane, so the
mirror must agree — else TaskRun.queue lies 'default' for external fetches
and per-queue dashboard filters / threshold overrides miss them
(operator-flagged 2026-06-17)."""
from backend.app.celery_signals import _queue_for
class _T:
name = "backend.app.tasks.external.fetch_external_link"
assert _queue_for(_T()) == "download"
assert (
celery.conf.task_routes["backend.app.tasks.external.*"]["queue"]
== "download"
)
def test_backfill_phash_runs_on_the_long_lane():
"""It lives in maintenance.py, so the quick-lane glob matches it too —
the router must pick the exact name. A 35-minute rehash on the scheduler
lane blocked the minute ticks behind it (2026-09-24)."""
route = celery.amqp.router.route(
{}, "backend.app.tasks.maintenance.backfill_phash",
)
assert route["queue"].name == "maintenance_long"
quick = celery.amqp.router.route(
{}, "backend.app.tasks.maintenance.recover_stalled_task_runs",
)
assert quick["queue"].name == "maintenance"