From db2374f0ea14d7a08578f21eca5a1a5c1ef4fb45 Mon Sep 17 00:00:00 2001 From: Maksim Liksakov <67663774+maxim-lixakov@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:27:03 +0300 Subject: [PATCH] [DOP-22266] - change celery queue name from queue.name to queue.slug (#167) --- syncmaster/backend/api/v1/runs.py | 2 +- syncmaster/scheduler/transfer_job_manager.py | 2 +- tests/test_integration/test_run_transfer/conftest.py | 1 + .../test_scheduler/scheduler_fixtures/transfer_fixture.py | 1 + tests/test_unit/test_runs/test_create_run.py | 4 ++-- tests/test_unit/test_scheduler/test_transfer_job_manager.py | 2 +- tests/test_unit/utils.py | 3 ++- 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/syncmaster/backend/api/v1/runs.py b/syncmaster/backend/api/v1/runs.py index d6bf1b16..b72df10a 100644 --- a/syncmaster/backend/api/v1/runs.py +++ b/syncmaster/backend/api/v1/runs.py @@ -135,7 +135,7 @@ async def start_run( celery.send_task, "run_transfer_task", kwargs={"run_id": run.id}, - queue=transfer.queue.name, + queue=transfer.queue.slug, ) except KombuError as e: async with unit_of_work: diff --git a/syncmaster/scheduler/transfer_job_manager.py b/syncmaster/scheduler/transfer_job_manager.py index 36469972..1c432a16 100644 --- a/syncmaster/scheduler/transfer_job_manager.py +++ b/syncmaster/scheduler/transfer_job_manager.py @@ -78,7 +78,7 @@ async def send_job_to_celery(transfer_id: int) -> None: celery.send_task, "run_transfer_task", kwargs={"run_id": run.id}, - queue=transfer.queue.name, + queue=transfer.queue.slug, ) except KombuError as e: async with unit_of_work: diff --git a/tests/test_integration/test_run_transfer/conftest.py b/tests/test_integration/test_run_transfer/conftest.py index 22280f3a..28ebae09 100644 --- a/tests/test_integration/test_run_transfer/conftest.py +++ b/tests/test_integration/test_run_transfer/conftest.py @@ -951,6 +951,7 @@ async def queue( session=session, name=request.param, group_id=group.id, + slug=request.param, ) yield result await session.delete(result) diff --git a/tests/test_integration/test_scheduler/scheduler_fixtures/transfer_fixture.py b/tests/test_integration/test_scheduler/scheduler_fixtures/transfer_fixture.py index cd689feb..22e12b7c 100644 --- a/tests/test_integration/test_scheduler/scheduler_fixtures/transfer_fixture.py +++ b/tests/test_integration/test_scheduler/scheduler_fixtures/transfer_fixture.py @@ -47,6 +47,7 @@ async def group_transfer_integration_mock( session=session, name="test_queue", group_id=group.id, + slug="test_queue", ) members: list[MockUser] = [] diff --git a/tests/test_unit/test_runs/test_create_run.py b/tests/test_unit/test_runs/test_create_run.py index 426b4b12..2811a4e0 100644 --- a/tests/test_unit/test_runs/test_create_run.py +++ b/tests/test_unit/test_runs/test_create_run.py @@ -61,7 +61,7 @@ async def test_developer_plus_can_create_run_of_transfer_his_group( mock_send_task, "run_transfer_task", kwargs={"run_id": run.id}, - queue=group_transfer.queue.name, + queue=group_transfer.queue.slug, ) @@ -163,7 +163,7 @@ async def test_superuser_can_create_run( mock_send_task, "run_transfer_task", kwargs={"run_id": run.id}, - queue=group_transfer.queue.name, + queue=group_transfer.queue.slug, ) diff --git a/tests/test_unit/test_scheduler/test_transfer_job_manager.py b/tests/test_unit/test_scheduler/test_transfer_job_manager.py index e8b54071..9e56846d 100644 --- a/tests/test_unit/test_scheduler/test_transfer_job_manager.py +++ b/tests/test_unit/test_scheduler/test_transfer_job_manager.py @@ -96,7 +96,7 @@ async def test_send_job_to_celery_with_success( mock_send_task, "run_transfer_task", kwargs={"run_id": run.id}, - queue=group_transfer.queue.name, + queue=group_transfer.queue.slug, ) diff --git a/tests/test_unit/utils.py b/tests/test_unit/utils.py index 7a9a38ab..1e932613 100644 --- a/tests/test_unit/utils.py +++ b/tests/test_unit/utils.py @@ -95,13 +95,14 @@ async def create_queue( session: AsyncSession, name: str, group_id: int, + slug: str | None = None, description: str | None = None, ) -> Queue: queue = Queue( name=name, description=description, group_id=group_id, - slug=f"{group_id}-{name}", + slug=slug if slug is not None else f"{group_id}-{name}", ) session.add(queue) await session.commit()