Skip to content

Commit

Permalink
Skip mode tests (#67)
Browse files Browse the repository at this point in the history
* Fix test discovery error

* Improve integration test

* Tidy of functional test
  • Loading branch information
MetRonnie authored Nov 15, 2024
1 parent 9855cd3 commit f5aa5ea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
26 changes: 13 additions & 13 deletions tests/functional/cylc-set/09-set-skip/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand All @@ -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
"""
7 changes: 2 additions & 5 deletions tests/functional/cylc-set/09-set-skip/reference.log
Original file line number Diff line number Diff line change
@@ -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
32 changes: 15 additions & 17 deletions tests/integration/run_modes/test_mode_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
Empty file.

0 comments on commit f5aa5ea

Please sign in to comment.