mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-02 21:15:34 +00:00
Fix: ensure import bulk_edit tasks in Celery workers (#14653)
This commit is contained in:
1 parent
1b8b861a60
commit
936f9363a0
2 files changed
+42
No files matched your search
@@ -690,6 +690,9 @@ logging.config.dictConfig(LOGGING)
|
||||
|
||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html
|
||||
|
||||
# Tasks outside tasks.py must be loaded even when Django skips checks
|
||||
CELERY_IMPORTS = ("documents.bulk_edit",)
|
||||
|
||||
CELERY_BROKER_URL = _CELERY_REDIS_URL
|
||||
CELERY_RESULT_BACKEND = _CELERY_REDIS_URL
|
||||
CELERY_RESULT_SERIALIZER = "signed-pickle"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import hmac
|
||||
import os
|
||||
import pickle
|
||||
import subprocess
|
||||
import sys
|
||||
from hashlib import sha256
|
||||
from pathlib import Path
|
||||
|
||||
@@ -11,6 +14,42 @@ from paperless.celery import signed_pickle_loads
|
||||
from paperless.signed_pickle import HMAC_SIZE
|
||||
|
||||
|
||||
def test_tasks_registered_without_system_checks() -> None:
|
||||
# Use a fresh interpreter: Django checks and other tests can import views,
|
||||
# hiding tasks that the worker would otherwise never register.
|
||||
result = subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
"""
|
||||
import sys
|
||||
|
||||
from paperless.celery import app
|
||||
|
||||
app.loader.import_default_modules()
|
||||
expected = {
|
||||
"documents.bulk_edit.delete",
|
||||
"documents.bulk_edit.restore_archive_serial_numbers_task",
|
||||
"documents.signals.handlers.process_cf_select_update",
|
||||
"documents.workflows.webhooks.send_webhook",
|
||||
"paperless_mail.mail.apply_mail_action",
|
||||
"paperless_mail.mail.error_callback",
|
||||
}
|
||||
missing = expected - set(app.tasks)
|
||||
assert not missing, f"Unregistered tasks: {sorted(missing)}"
|
||||
assert "paperless.urls" not in sys.modules
|
||||
""",
|
||||
],
|
||||
env={**os.environ, "CELERY_SKIP_CHECKS": "1"},
|
||||
cwd=Path(__file__).resolve().parents[2],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=60,
|
||||
check=False,
|
||||
)
|
||||
assert result.returncode == 0, result.stdout + result.stderr
|
||||
|
||||
|
||||
class TestSignedPickleSerializer:
|
||||
def test_roundtrip_simple_types(self) -> None:
|
||||
"""Signed pickle can round-trip basic JSON-like types."""
|
||||
|
||||
Reference in new issue
Block a user