|
19 | 19 | Note: see also functional tests
|
20 | 20 | """
|
21 | 21 |
|
| 22 | +import logging |
| 23 | +import pytest |
| 24 | + |
22 | 25 | from cylc.flow.cycling.integer import IntegerPoint
|
23 | 26 | from cylc.flow.data_messages_pb2 import PbTaskProxy
|
24 | 27 | from cylc.flow.data_store_mgr import TASK_PROXIES
|
25 | 28 | from cylc.flow.scheduler import Scheduler
|
26 | 29 | from cylc.flow.task_state import TASK_STATUS_SUCCEEDED, TASK_STATUS_WAITING
|
27 | 30 |
|
| 31 | +from typing import Callable |
| 32 | + |
28 | 33 |
|
29 | 34 | async def test_set_parentless_spawning(
|
30 | 35 | flow,
|
@@ -164,3 +169,32 @@ async def test_pre_all(flow, scheduler, run):
|
164 | 169 | schd.pool.set_prereqs_and_outputs(['1/z'], [], ['all'], ['all'])
|
165 | 170 | warn_or_higher = [i for i in log.records if i.levelno > 30]
|
166 | 171 | assert warn_or_higher == []
|
| 172 | + |
| 173 | + |
| 174 | +async def test_bad_prereq( |
| 175 | + flow: 'Callable', |
| 176 | + scheduler: 'Callable', |
| 177 | + run: 'Callable', |
| 178 | + complete: 'Callable', |
| 179 | + caplog: 'pytest.LogCaptureFixture' |
| 180 | +): |
| 181 | + """Attempting to set an invalid prerequisite should not leave a trace in |
| 182 | + the DB that prevents the target task from spawning. later on. |
| 183 | + """ |
| 184 | + id_ = flow({ |
| 185 | + 'scheduling': { |
| 186 | + 'graph': {'R1': 'a => b => c'}, |
| 187 | + }, |
| 188 | + }) |
| 189 | + schd = scheduler(id_, paused_start=False) |
| 190 | + async with run(schd): |
| 191 | + schd.pool.set_prereqs_and_outputs(['1/c'], [], ['1/a'], []) |
| 192 | + assert schd.pool.get_task_ids() == {'1/a'} |
| 193 | + assert '1/c does not depend on "1/a:succeeded"' in caplog.text |
| 194 | + |
| 195 | + schd.workflow_db_mgr.process_queued_ops() |
| 196 | + |
| 197 | + # This will fail if the previous set left 1/c in the DB: |
| 198 | + schd.pool.set_prereqs_and_outputs(['1/c'], [], ['1/b'], []) |
| 199 | + assert schd.pool.get_task_ids() == {'1/a', '1/c'} |
| 200 | + await complete(schd, '1/c', timeout=5) |
0 commit comments