From f5aa5ea749df85a5d5f263c70df9ef1608daedce Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:42:15 +0000 Subject: [PATCH] Skip mode tests (#67) * Fix test discovery error * Improve integration test * Tidy of functional test --- .../functional/cylc-set/09-set-skip/flow.cylc | 26 +++++++-------- .../cylc-set/09-set-skip/reference.log | 7 ++-- .../run_modes/test_mode_overrides.py | 32 +++++++++---------- tests/unit/run_modes/__init__.py | 0 4 files changed, 30 insertions(+), 35 deletions(-) create mode 100644 tests/unit/run_modes/__init__.py diff --git a/tests/functional/cylc-set/09-set-skip/flow.cylc b/tests/functional/cylc-set/09-set-skip/flow.cylc index ef74c362773..17813d64d63 100644 --- a/tests/functional/cylc-set/09-set-skip/flow.cylc +++ b/tests/functional/cylc-set/09-set-skip/flow.cylc @@ -14,18 +14,18 @@ [[graph]] R1 = """ # Optional out not created by set --out skip - foo:no? => not_this_task? + foo:no? => not_this_task # set --out skip creates required, started, submitted # and succeeded (unless failed is set): - foo:yes => require_this_task - foo:submitted => submitted_emitted - foo:succeeded => succeeded_emitted - foo:started => skip_foo + foo:yes => foo_done + foo:submitted => foo_done + foo:succeeded => foo_done + foo:started => do_skip # set --out skip creates failed if that is required # by skip mode settings: - bar:started => skip_bar + bar:started => do_skip bar:failed? => bar_failed """ @@ -35,16 +35,16 @@ [[[skip]]] outputs = yes [[[outputs]]] - no = 'Don\'t require this task' - yes = 'Require this task' + no = Don't require this task + yes = Require this task [[bar]] script = sleep 100 [[[skip]]] outputs = failed - [[skip_foo]] - script = cylc set ${CYLC_WORKFLOW_ID}//1/foo --out skip - - [[skip_bar]] - script = cylc set ${CYLC_WORKFLOW_ID}//1/bar --out skip + [[do_skip]] + script = """ + cylc set --out skip ${CYLC_WORKFLOW_ID}//1/foo \ + ${CYLC_WORKFLOW_ID}//1/bar + """ diff --git a/tests/functional/cylc-set/09-set-skip/reference.log b/tests/functional/cylc-set/09-set-skip/reference.log index 6e7b636f540..7db64d9f47c 100644 --- a/tests/functional/cylc-set/09-set-skip/reference.log +++ b/tests/functional/cylc-set/09-set-skip/reference.log @@ -1,8 +1,5 @@ 1/bar -triggered off [] in flow 1 1/foo -triggered off [] in flow 1 -1/submitted_emitted -triggered off ['1/foo'] in flow 1 -1/skip_bar -triggered off ['1/bar'] in flow 1 -1/skip_foo -triggered off ['1/foo'] in flow 1 -1/succeeded_emitted -triggered off ['1/foo'] in flow 1 +1/do_skip -triggered off ['1/bar', '1/foo'] in flow 1 +1/foo_done -triggered off ['1/foo', '1/foo', '1/foo'] in flow 1 1/bar_failed -triggered off ['1/bar'] in flow 1 -1/require_this_task -triggered off ['1/foo'] in flow 1 diff --git a/tests/integration/run_modes/test_mode_overrides.py b/tests/integration/run_modes/test_mode_overrides.py index 9b67f58e618..25cdf6cf68a 100644 --- a/tests/integration/run_modes/test_mode_overrides.py +++ b/tests/integration/run_modes/test_mode_overrides.py @@ -32,6 +32,8 @@ from cylc.flow.cycling.iso8601 import ISO8601Point from cylc.flow.run_modes import WORKFLOW_RUN_MODES, RunMode +from cylc.flow.scheduler import Scheduler, SchedulerStop +from cylc.flow.task_state import TASK_STATUS_WAITING @pytest.mark.parametrize('workflow_run_mode', sorted(WORKFLOW_RUN_MODES)) @@ -102,12 +104,7 @@ async def test_force_trigger_does_not_override_run_mode( assert foo.run_mode.value == 'skip' -async def test_run_mode_skip_abides_by_held( - flow, - scheduler, - run, - complete -): +async def test_run_mode_skip_abides_by_held(flow, scheduler, run): """Tasks with run mode = skip will continue to abide by the is_held flag as normal. @@ -118,21 +115,22 @@ async def test_run_mode_skip_abides_by_held( 'scheduling': {'graph': {'R1': 'foo'}}, 'runtime': {'foo': {'run mode': 'skip'}} }) - schd = scheduler(wid, run_mode="live", paused_start=False) + schd: Scheduler = scheduler(wid, run_mode="live", paused_start=False) async with run(schd): foo = schd.pool.get_tasks()[0] - assert foo.state.is_held is False + assert not foo.state.is_held # Hold task, check that it's held: - schd.pool.hold_tasks('1/foo') - assert foo.state.is_held is True - - # Run to completion, should happen if task isn't held: - with pytest.raises( - Exception, - match="Timeout waiting for workflow to shut down" - ): - await complete(schd, timeout=5) + schd.pool.hold_tasks(['1/foo']) + assert foo.state.is_held + await schd._main_loop() + assert foo.state(TASK_STATUS_WAITING) + + schd.pool.release_held_tasks(['1/foo']) + assert not foo.state.is_held + with pytest.raises(SchedulerStop): + # Will shut down as foo has run + await schd._main_loop() async def test_run_mode_override_from_broadcast( diff --git a/tests/unit/run_modes/__init__.py b/tests/unit/run_modes/__init__.py new file mode 100644 index 00000000000..e69de29bb2d