Skip to content

Commit 4679bd1

Browse files
committed
creation of parallel test
1 parent 1a9fe6b commit 4679bd1

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_worker.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# pylint:disable=no-name-in-module
88
# pylint: disable=too-many-statements
99

10+
import asyncio
11+
from typing import Awaitable, Callable
1012
from unittest import mock
1113

1214
import pytest
@@ -47,7 +49,7 @@ def mocked_get_scheduler_worker(
4749
)
4850

4951

50-
async def test_worker_properly_calls_scheduler_api(
52+
async def test_worker_properly_autocalls_scheduler_api(
5153
with_disabled_auto_scheduling: mock.Mock,
5254
initialized_app: FastAPI,
5355
mocked_get_scheduler_worker: mock.Mock,
@@ -69,3 +71,34 @@ async def test_worker_properly_calls_scheduler_api(
6971
project_id=published_project.project.uuid,
7072
iteration=1,
7173
)
74+
75+
76+
@pytest.fixture
77+
async def mocked_scheduler_api(mocker: MockerFixture) -> mock.Mock:
78+
return mocker.patch(
79+
"simcore_service_director_v2.modules.comp_scheduler._scheduler_base.BaseCompScheduler.schedule_pipeline"
80+
)
81+
82+
83+
async def test_worker_scheduling_parallelism(
84+
with_disabled_auto_scheduling: mock.Mock,
85+
mocked_scheduler_api: mock.Mock,
86+
initialized_app: FastAPI,
87+
publish_project: Callable[[], Awaitable[PublishedProject]],
88+
run_metadata: RunMetadataDict,
89+
):
90+
with_disabled_auto_scheduling.assert_called_once()
91+
92+
mocked_scheduler_api.side_effect = asyncio.sleep(10)
93+
94+
published_project = await publish_project()
95+
assert published_project.project.prj_owner
96+
await run_new_pipeline(
97+
initialized_app,
98+
user_id=published_project.project.prj_owner,
99+
project_id=published_project.project.uuid,
100+
cluster_id=DEFAULT_CLUSTER_ID,
101+
run_metadata=run_metadata,
102+
use_on_demand_clusters=False,
103+
)
104+
mocked_scheduler_api.assert_called_once()

0 commit comments

Comments
 (0)