diff --git a/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_worker.py b/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_worker.py index c52b842516dc..e4c56b3b88a2 100644 --- a/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_worker.py +++ b/services/director-v2/tests/unit/with_dbs/comp_scheduler/test_worker.py @@ -7,6 +7,8 @@ # pylint:disable=no-name-in-module # pylint: disable=too-many-statements +import asyncio +from typing import Awaitable, Callable from unittest import mock import pytest @@ -47,7 +49,7 @@ def mocked_get_scheduler_worker( ) -async def test_worker_properly_calls_scheduler_api( +async def test_worker_properly_autocalls_scheduler_api( with_disabled_auto_scheduling: mock.Mock, initialized_app: FastAPI, mocked_get_scheduler_worker: mock.Mock, @@ -69,3 +71,34 @@ async def test_worker_properly_calls_scheduler_api( project_id=published_project.project.uuid, iteration=1, ) + + +@pytest.fixture +async def mocked_scheduler_api(mocker: MockerFixture) -> mock.Mock: + return mocker.patch( + "simcore_service_director_v2.modules.comp_scheduler._scheduler_base.BaseCompScheduler.schedule_pipeline" + ) + + +async def test_worker_scheduling_parallelism( + with_disabled_auto_scheduling: mock.Mock, + mocked_scheduler_api: mock.Mock, + initialized_app: FastAPI, + publish_project: Callable[[], Awaitable[PublishedProject]], + run_metadata: RunMetadataDict, +): + with_disabled_auto_scheduling.assert_called_once() + + mocked_scheduler_api.side_effect = asyncio.sleep(10) + + published_project = await publish_project() + assert published_project.project.prj_owner + await run_new_pipeline( + initialized_app, + user_id=published_project.project.prj_owner, + project_id=published_project.project.uuid, + cluster_id=DEFAULT_CLUSTER_ID, + run_metadata=run_metadata, + use_on_demand_clusters=False, + ) + mocked_scheduler_api.assert_called_once()