Skip to content

Commit

Permalink
creation of parallel test
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Nov 28, 2024
1 parent ac4372a commit 2b9c756
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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()

0 comments on commit 2b9c756

Please sign in to comment.