Skip to content

Commit f54b4c1

Browse files
committed
test improved
1 parent cd9de5b commit f54b4c1

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,7 @@ async def test_run_new_pipeline_called_twice_prevents_duplicate_runs(
22812281
ComputationalBackendTaskResultsNotReadyError,
22822282
],
22832283
)
2284-
async def test_getting_task_result_raises_exception_does_not_fail_task(
2284+
async def test_getting_task_result_raises_exception_does_not_fail_task_and_retries(
22852285
exception_type: Exception,
22862286
with_disabled_auto_scheduling: mock.Mock,
22872287
with_disabled_scheduler_publisher: mock.Mock,
@@ -2317,10 +2317,27 @@ async def mocked_get_task_result(_job_id: str) -> TaskOutputData:
23172317
project_id=running_project.project.uuid,
23182318
iteration=1,
23192319
)
2320-
# calling again should not raise neither
2321-
assert running_project.project.prj_owner
2322-
await scheduler_api.apply(
2323-
user_id=running_project.project.prj_owner,
2324-
project_id=running_project.project.uuid,
2325-
iteration=1,
2320+
assert mocked_dask_client.get_task_result.call_count == len(
2321+
[t for t in running_project.tasks if t.node_class is NodeClass.COMPUTATIONAL]
23262322
)
2323+
mocked_dask_client.get_task_result.reset_mock()
2324+
# calling again should not raise neither but try again
2325+
assert running_project.project.prj_owner
2326+
for _ in range(3):
2327+
await scheduler_api.apply(
2328+
user_id=running_project.project.prj_owner,
2329+
project_id=running_project.project.uuid,
2330+
iteration=1,
2331+
)
2332+
assert mocked_dask_client.get_task_result.call_count == (
2333+
len(
2334+
[
2335+
t
2336+
for t in running_project.tasks
2337+
if t.node_class is NodeClass.COMPUTATIONAL
2338+
]
2339+
)
2340+
- 1
2341+
)
2342+
mocked_dask_client.get_task_result.reset_mock()
2343+
await asyncio.sleep(0.5) # wait a bit to ensure the retry decorator has reset

0 commit comments

Comments
 (0)