From c00c17888c5b0d29236e756aa30c04bbfb367bf7 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:32:09 +0000 Subject: [PATCH 1/9] f --- tests/integration/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 120d64d24ce..51e1b8c581c 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -479,7 +479,7 @@ def _inner(source, **kwargs): @pytest.fixture -def reflog(): +def reflog(monkeypatch): """Integration test version of the --reflog CLI option. This returns a set which captures task triggers. @@ -512,6 +512,8 @@ def reflog(): """ def _reflog(schd, flow_nums=False): + nonlocal monkeypatch + submit_task_jobs = schd.task_job_mgr.submit_task_jobs triggers = set() From 9f11db2b8e8a074dc395c1600cb133b1e1cc805d Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 23 Nov 2023 11:42:12 +0000 Subject: [PATCH 2/9] stuff --- cylc/flow/scripts/trigger.py | 2 -- tests/integration/test_examples.py | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cylc/flow/scripts/trigger.py b/cylc/flow/scripts/trigger.py index 3e4a3da96f7..9818bae329a 100755 --- a/cylc/flow/scripts/trigger.py +++ b/cylc/flow/scripts/trigger.py @@ -140,7 +140,6 @@ def _validate(options): async def run(options: 'Values', workflow_id: str, *tokens_list): pclient = get_client(workflow_id, timeout=options.comms_timeout) - mutation_kwargs = { 'request_string': MUTATION, 'variables': { @@ -165,7 +164,6 @@ def main(parser: COP, options: 'Values', *ids: str): if options.flow is None: options.flow = [FLOW_ALL] # default to all active flows _validate(options) - call_multi( partial(run, options), *ids, diff --git a/tests/integration/test_examples.py b/tests/integration/test_examples.py index da8b156503d..005ab551982 100644 --- a/tests/integration/test_examples.py +++ b/tests/integration/test_examples.py @@ -260,6 +260,7 @@ async def test_reflog(flow, scheduler, run, reflog, complete): async with run(schd): triggers = reflog(schd) # Note: add flow_nums=True to capture flows + breakpoint() await complete(schd) assert triggers == { From ec76e2e1a7069f52a5fcc05eef3bb3f4641224e0 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 23 Nov 2023 11:52:50 +0000 Subject: [PATCH 3/9] example test --- cylc/flow/scripts/trigger.py | 2 ++ tests/functional/triggering/09-fail/flow.cylc | 12 ------- .../triggering/09-fail/reference.log | 4 --- tests/integration/test_examples.py | 1 - .../09-fail.t => integration/triggering.py} | 36 ++++++++++++++----- 5 files changed, 30 insertions(+), 25 deletions(-) delete mode 100644 tests/functional/triggering/09-fail/flow.cylc delete mode 100644 tests/functional/triggering/09-fail/reference.log rename tests/{functional/triggering/09-fail.t => integration/triggering.py} (54%) diff --git a/cylc/flow/scripts/trigger.py b/cylc/flow/scripts/trigger.py index 9818bae329a..3e4a3da96f7 100755 --- a/cylc/flow/scripts/trigger.py +++ b/cylc/flow/scripts/trigger.py @@ -140,6 +140,7 @@ def _validate(options): async def run(options: 'Values', workflow_id: str, *tokens_list): pclient = get_client(workflow_id, timeout=options.comms_timeout) + mutation_kwargs = { 'request_string': MUTATION, 'variables': { @@ -164,6 +165,7 @@ def main(parser: COP, options: 'Values', *ids: str): if options.flow is None: options.flow = [FLOW_ALL] # default to all active flows _validate(options) + call_multi( partial(run, options), *ids, diff --git a/tests/functional/triggering/09-fail/flow.cylc b/tests/functional/triggering/09-fail/flow.cylc deleted file mode 100644 index b4048e27ae5..00000000000 --- a/tests/functional/triggering/09-fail/flow.cylc +++ /dev/null @@ -1,12 +0,0 @@ -[scheduler] - [[events]] - expected task failures = 1/foo - -[scheduling] - [[graph]] - R1 = "foo:fail => bar" -[runtime] - [[foo]] - script = "false" - [[bar]] - script = "true" diff --git a/tests/functional/triggering/09-fail/reference.log b/tests/functional/triggering/09-fail/reference.log deleted file mode 100644 index 1a9f846c98d..00000000000 --- a/tests/functional/triggering/09-fail/reference.log +++ /dev/null @@ -1,4 +0,0 @@ -Initial point: 1 -Final point: 1 -1/foo -triggered off [] -1/bar -triggered off ['1/foo'] diff --git a/tests/integration/test_examples.py b/tests/integration/test_examples.py index 005ab551982..da8b156503d 100644 --- a/tests/integration/test_examples.py +++ b/tests/integration/test_examples.py @@ -260,7 +260,6 @@ async def test_reflog(flow, scheduler, run, reflog, complete): async with run(schd): triggers = reflog(schd) # Note: add flow_nums=True to capture flows - breakpoint() await complete(schd) assert triggers == { diff --git a/tests/functional/triggering/09-fail.t b/tests/integration/triggering.py similarity index 54% rename from tests/functional/triggering/09-fail.t rename to tests/integration/triggering.py index 0f4698ec2ac..0486dadab1b 100644 --- a/tests/functional/triggering/09-fail.t +++ b/tests/integration/triggering.py @@ -1,7 +1,6 @@ -#!/usr/bin/env bash # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. # Copyright (C) NIWA & British Crown (Met Office) & Contributors. -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -14,9 +13,30 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test fail triggering -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit + +async def test_fail(flow, scheduler, run, reflog, complete, validate): + id_ = flow({ + 'scheduler': { + 'allow implicit tasks': 'true' + }, + 'scheduling': { + 'graph': { + 'R1': 'foo:failed => bar' + } + }, + 'runtime': { + 'foo': { + 'simulation': {'fail cycle points': 'all'} + } + } + }) + schd = scheduler(id_, paused_start=False) + + async with run(schd): + triggers = reflog(schd) + await complete(schd) + + assert triggers == { + ('1/foo', None), + ('1/bar', ('1/foo',)), + } From 458686f7eb8925fa2861b93a514e390f327ef984 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:38:32 +0000 Subject: [PATCH 4/9] fix --- tests/integration/conftest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 51e1b8c581c..874970a85a9 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -479,7 +479,7 @@ def _inner(source, **kwargs): @pytest.fixture -def reflog(monkeypatch): +def reflog(): """Integration test version of the --reflog CLI option. This returns a set which captures task triggers. @@ -512,7 +512,6 @@ def reflog(monkeypatch): """ def _reflog(schd, flow_nums=False): - nonlocal monkeypatch submit_task_jobs = schd.task_job_mgr.submit_task_jobs triggers = set() From f41d46738395e45f2a49cf727b754bdec1e60014 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:04:01 +0000 Subject: [PATCH 5/9] Update tests/integration/triggering.py Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> --- tests/integration/triggering.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/triggering.py b/tests/integration/triggering.py index 0486dadab1b..ca753b137c2 100644 --- a/tests/integration/triggering.py +++ b/tests/integration/triggering.py @@ -25,6 +25,9 @@ async def test_fail(flow, scheduler, run, reflog, complete, validate): } }, 'runtime': { + 'root': { + 'simulation': {'default run length': 'PT0S'} + }, 'foo': { 'simulation': {'fail cycle points': 'all'} } From ebb8c24a826be6867fc0ac4bd6ea4f0bca777d3f Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:09:01 +0000 Subject: [PATCH 6/9] Update tests/integration/triggering.py Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> --- tests/integration/triggering.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/triggering.py b/tests/integration/triggering.py index ca753b137c2..f086d46aa4c 100644 --- a/tests/integration/triggering.py +++ b/tests/integration/triggering.py @@ -15,6 +15,7 @@ # along with this program. If not, see . async def test_fail(flow, scheduler, run, reflog, complete, validate): + """Test triggering on :fail""" id_ = flow({ 'scheduler': { 'allow implicit tasks': 'true' From 15d254f25765b4434f272be65859098bd0182358 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:09:34 +0000 Subject: [PATCH 7/9] f --- tests/integration/{triggering.py => test_triggering.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/integration/{triggering.py => test_triggering.py} (100%) diff --git a/tests/integration/triggering.py b/tests/integration/test_triggering.py similarity index 100% rename from tests/integration/triggering.py rename to tests/integration/test_triggering.py From 52325c3c20891a1e9761ae4efbff989fb4bec549 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Fri, 15 Dec 2023 15:20:34 +0000 Subject: [PATCH 8/9] Update tests/integration/conftest.py Co-authored-by: Oliver Sanders --- tests/integration/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 874970a85a9..120d64d24ce 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -512,7 +512,6 @@ def reflog(): """ def _reflog(schd, flow_nums=False): - submit_task_jobs = schd.task_job_mgr.submit_task_jobs triggers = set() From 1ab89a9be525efa774b043af06bcacb82cecd943 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Fri, 15 Dec 2023 15:42:17 +0000 Subject: [PATCH 9/9] Integration tests: set default task runtime to 0 in a better way (#58) --- tests/integration/test_scan_api.py | 6 +++--- ...uler_logs.workflow-configuration-file.html | 10 ++++----- tests/integration/utils/flow_tools.py | 21 +++++++------------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/tests/integration/test_scan_api.py b/tests/integration/test_scan_api.py index ea25035e804..71d83124f77 100644 --- a/tests/integration/test_scan_api.py +++ b/tests/integration/test_scan_api.py @@ -80,14 +80,14 @@ async def flows(mod_flow, mod_scheduler, mod_run, mod_one_conf): } }, 'runtime': { - 'one': { - 'execution time limit': 'PT10S' + 'foo': { + 'simulation': {'default run length': 'PT10S'} } } }, name='-running-' ) - schd2 = mod_scheduler(reg2, run_mode='simulation', paused_start=False) + schd2 = mod_scheduler(reg2, paused_start=False) # run cylc run async with mod_run(schd1): diff --git a/tests/integration/tui/screenshots/test_scheduler_logs.workflow-configuration-file.html b/tests/integration/tui/screenshots/test_scheduler_logs.workflow-configuration-file.html index 8cc2f9af73b..04ebb27ff79 100644 --- a/tests/integration/tui/screenshots/test_scheduler_logs.workflow-configuration-file.html +++ b/tests/integration/tui/screenshots/test_scheduler_logs.workflow-configuration-file.html @@ -3,14 +3,14 @@ Path: mypath < Select File > - [runtime] - [[a]] [scheduling] [[graph]] R1 = a - - - + [runtime] + [[a]] + [[root]] + [[[simulation]]] + default run length = PT0S diff --git a/tests/integration/utils/flow_tools.py b/tests/integration/utils/flow_tools.py index 9270f12ee8d..c26f79c04ac 100644 --- a/tests/integration/utils/flow_tools.py +++ b/tests/integration/utils/flow_tools.py @@ -66,19 +66,14 @@ def _make_flow( flow_run_dir = (test_dir / name) flow_run_dir.mkdir(parents=True, exist_ok=True) id_ = str(flow_run_dir.relative_to(cylc_run_dir)) - conf = flow_config_str({ - # override the default simulation runtime logic to make - # tasks execute instantly - # NOTE: this is prepended so it can be overwritten - 'runtime': { - 'root': { - 'simulation': { - 'default run length': 'PT0S', - }, - }, - }, - **conf, - }) + # set the default simulation runtime to zero (can be overridden) + ( + conf.setdefault('runtime', {}) + .setdefault('root', {}) + .setdefault('simulation', {}) + .setdefault('default run length', 'PT0S') + ) + conf = flow_config_str(conf) with open((flow_run_dir / WorkflowFiles.FLOW_FILE), 'w+') as flow_file: flow_file.write(conf) return id_