From 7a6f25660184926f79bb293026f46ef4ab6d967e Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Fri, 15 Dec 2023 16:58:34 +0000 Subject: [PATCH 1/6] Integration tests: add a simpler reftest fixture --- tests/integration/conftest.py | 25 ++++++++++++++++--- tests/integration/test_examples.py | 25 ++++++++++++++++--- ...uler_logs.workflow-configuration-file.html | 4 +-- tests/integration/utils/flow_tools.py | 5 ++-- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 120d64d24ce..ca7ee981bd9 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -25,7 +25,6 @@ from cylc.flow.config import WorkflowConfig from cylc.flow.option_parsers import Options -from cylc.flow.network.client import WorkflowRuntimeClient from cylc.flow.pathutil import get_cylc_run_dir from cylc.flow.rundb import CylcWorkflowDAO from cylc.flow.scripts.validate import ValidateOptions @@ -48,6 +47,7 @@ ) if TYPE_CHECKING: + from cylc.flow.network.client import WorkflowRuntimeClient from cylc.flow.scheduler import Scheduler from cylc.flow.task_proxy import TaskProxy @@ -326,7 +326,7 @@ def _inner( def gql_query(): """Execute a GraphQL query given a workflow runtime client.""" async def _gql_query( - client: WorkflowRuntimeClient, query_str: str + client: 'WorkflowRuntimeClient', query_str: str ) -> object: ret = await client.async_request( 'graphql', { @@ -511,7 +511,7 @@ def reflog(): """ - def _reflog(schd, flow_nums=False): + def _reflog(schd: 'Scheduler', flow_nums: bool = False) -> Set[tuple]: submit_task_jobs = schd.task_job_mgr.submit_task_jobs triggers = set() @@ -613,3 +613,22 @@ def _set_stop(mode=None): schd._set_stop = set_stop return _complete + + +@pytest.fixture +def reftest(run, reflog, complete): + """Fixture that runs a simple reftest. + + Combines the `reflog` and `complete` fixtures. + """ + async def _reftest( + schd: 'Scheduler', + flow_nums: bool = False, + ) -> Set[tuple]: + async with run(schd): + triggers = reflog(schd, flow_nums) + await complete(schd) + + return triggers + + return _reftest diff --git a/tests/integration/test_examples.py b/tests/integration/test_examples.py index da8b156503d..882d4c10163 100644 --- a/tests/integration/test_examples.py +++ b/tests/integration/test_examples.py @@ -240,9 +240,6 @@ async def test_reflog(flow, scheduler, run, reflog, complete): they can be compared with the expected outcome. """ id_ = flow({ - 'scheduler': { - 'allow implicit tasks': 'True', - }, 'scheduling': { 'initial cycle point': '1', 'final cycle point': '1', @@ -271,3 +268,25 @@ async def test_reflog(flow, scheduler, run, reflog, complete): ('1/x', None), ('1/z', ('1/b',)), } + + +async def test_reftest(flow, scheduler, reftest): + """Test the triggering of tasks. + + This uses the reftest fixture which combines the reflog and + complete fixtures. Suitable for use when you just want to do a simple + reftest. + """ + id_ = flow({ + 'scheduling': { + 'graph': { + 'R1': 'a => b' + } + } + }) + schd = scheduler(id_, paused_start=False) + + assert await reftest(schd) == { + ('1/a', None), + ('1/b', ('1/a',)), + } 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 04ebb27ff79..011734bc410 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 @@ -11,8 +11,8 @@ [[root]] [[[simulation]]] default run length = PT0S - - + [scheduler] + allow implicit tasks = True diff --git a/tests/integration/utils/flow_tools.py b/tests/integration/utils/flow_tools.py index c26f79c04ac..3b196c0113d 100644 --- a/tests/integration/utils/flow_tools.py +++ b/tests/integration/utils/flow_tools.py @@ -73,9 +73,10 @@ def _make_flow( .setdefault('simulation', {}) .setdefault('default run length', 'PT0S') ) - conf = flow_config_str(conf) + # allow implicit tasks by default: + conf.setdefault('scheduler', {}).setdefault('allow implicit tasks', 'True') with open((flow_run_dir / WorkflowFiles.FLOW_FILE), 'w+') as flow_file: - flow_file.write(conf) + flow_file.write(flow_config_str(conf)) return id_ From aff3dd18cf86673c0a763e8896cb0594e5a971f7 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Fri, 15 Dec 2023 16:59:29 +0000 Subject: [PATCH 2/6] Replace pre-initial functional reftests with integration reftests --- tests/functional/pre-initial/01-basic.t | 22 ---- .../functional/pre-initial/01-basic/flow.cylc | 10 -- .../pre-initial/01-basic/reference.log | 6 - tests/functional/pre-initial/02-advanced.t | 22 ---- .../pre-initial/02-advanced/flow.cylc | 10 -- .../pre-initial/02-advanced/reference.log | 17 --- tests/functional/pre-initial/03-drop.t | 22 ---- .../functional/pre-initial/03-drop/flow.cylc | 10 -- .../pre-initial/03-drop/reference.log | 12 -- .../pre-initial/06-over-bracketed.t | 22 ---- .../pre-initial/06-over-bracketed/flow.cylc | 14 -- .../06-over-bracketed/reference.log | 6 - .../integration/reftests/test_pre_initial.py | 122 ++++++++++++++++++ 13 files changed, 122 insertions(+), 173 deletions(-) delete mode 100644 tests/functional/pre-initial/01-basic.t delete mode 100644 tests/functional/pre-initial/01-basic/flow.cylc delete mode 100644 tests/functional/pre-initial/01-basic/reference.log delete mode 100644 tests/functional/pre-initial/02-advanced.t delete mode 100644 tests/functional/pre-initial/02-advanced/flow.cylc delete mode 100644 tests/functional/pre-initial/02-advanced/reference.log delete mode 100644 tests/functional/pre-initial/03-drop.t delete mode 100644 tests/functional/pre-initial/03-drop/flow.cylc delete mode 100644 tests/functional/pre-initial/03-drop/reference.log delete mode 100644 tests/functional/pre-initial/06-over-bracketed.t delete mode 100644 tests/functional/pre-initial/06-over-bracketed/flow.cylc delete mode 100644 tests/functional/pre-initial/06-over-bracketed/reference.log create mode 100644 tests/integration/reftests/test_pre_initial.py diff --git a/tests/functional/pre-initial/01-basic.t b/tests/functional/pre-initial/01-basic.t deleted file mode 100644 index b1f413ddace..00000000000 --- a/tests/functional/pre-initial/01-basic.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test simplification of basic conditionals in pre-initial cycling -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/pre-initial/01-basic/flow.cylc b/tests/functional/pre-initial/01-basic/flow.cylc deleted file mode 100644 index bca29e50d8e..00000000000 --- a/tests/functional/pre-initial/01-basic/flow.cylc +++ /dev/null @@ -1,10 +0,0 @@ -[scheduler] - UTC mode = True -[scheduling] - initial cycle point = 20100101T00 - final cycle point = 20100102T00 - [[graph]] - T00 = "a[-P1D] & b => a" -[runtime] - [[a, b]] - script = true diff --git a/tests/functional/pre-initial/01-basic/reference.log b/tests/functional/pre-initial/01-basic/reference.log deleted file mode 100644 index f8e9ebfb9b9..00000000000 --- a/tests/functional/pre-initial/01-basic/reference.log +++ /dev/null @@ -1,6 +0,0 @@ -Initial point: 20100101T0000Z -Final point: 20100102T0000Z -20100101T0000Z/b -triggered off [] -20100102T0000Z/b -triggered off [] -20100101T0000Z/a -triggered off ['20091231T0000Z/a', '20100101T0000Z/b'] -20100102T0000Z/a -triggered off ['20100101T0000Z/a', '20100102T0000Z/b'] diff --git a/tests/functional/pre-initial/02-advanced.t b/tests/functional/pre-initial/02-advanced.t deleted file mode 100644 index e47da93e022..00000000000 --- a/tests/functional/pre-initial/02-advanced.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test nested conditional simplification for pre-initial cycling. -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/pre-initial/02-advanced/flow.cylc b/tests/functional/pre-initial/02-advanced/flow.cylc deleted file mode 100644 index 3fac2378990..00000000000 --- a/tests/functional/pre-initial/02-advanced/flow.cylc +++ /dev/null @@ -1,10 +0,0 @@ -[scheduler] - UTC mode = True -[scheduling] - initial cycle point = 20100101T00 - final cycle point = 20100102T00 - [[graph]] - PT6H = "(a[-PT6H] & b) & c[-PT6H] => a & c" -[runtime] - [[a, b, c]] - script = true diff --git a/tests/functional/pre-initial/02-advanced/reference.log b/tests/functional/pre-initial/02-advanced/reference.log deleted file mode 100644 index 9592b07f619..00000000000 --- a/tests/functional/pre-initial/02-advanced/reference.log +++ /dev/null @@ -1,17 +0,0 @@ -Initial point: 20100101T0000Z -Final point: 20100102T0000Z -20100101T0000Z/b -triggered off [] -20100101T0600Z/b -triggered off [] -20100101T0000Z/a -triggered off ['20091231T1800Z/a', '20091231T1800Z/c', '20100101T0000Z/b'] -20100101T0000Z/c -triggered off ['20091231T1800Z/a', '20091231T1800Z/c', '20100101T0000Z/b'] -20100101T1200Z/b -triggered off [] -20100101T0600Z/a -triggered off ['20100101T0000Z/a', '20100101T0000Z/c', '20100101T0600Z/b'] -20100101T0600Z/c -triggered off ['20100101T0000Z/a', '20100101T0000Z/c', '20100101T0600Z/b'] -20100101T1800Z/b -triggered off [] -20100101T1200Z/a -triggered off ['20100101T0600Z/a', '20100101T0600Z/c', '20100101T1200Z/b'] -20100101T1200Z/c -triggered off ['20100101T0600Z/a', '20100101T0600Z/c', '20100101T1200Z/b'] -20100102T0000Z/b -triggered off [] -20100101T1800Z/c -triggered off ['20100101T1200Z/a', '20100101T1200Z/c', '20100101T1800Z/b'] -20100101T1800Z/a -triggered off ['20100101T1200Z/a', '20100101T1200Z/c', '20100101T1800Z/b'] -20100102T0000Z/a -triggered off ['20100101T1800Z/a', '20100101T1800Z/c', '20100102T0000Z/b'] -20100102T0000Z/c -triggered off ['20100101T1800Z/a', '20100101T1800Z/c', '20100102T0000Z/b'] diff --git a/tests/functional/pre-initial/03-drop.t b/tests/functional/pre-initial/03-drop.t deleted file mode 100644 index 6afb98480a9..00000000000 --- a/tests/functional/pre-initial/03-drop.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test the case of dropping a conditional based on pre-initial cycling -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/pre-initial/03-drop/flow.cylc b/tests/functional/pre-initial/03-drop/flow.cylc deleted file mode 100644 index f54faf43fdf..00000000000 --- a/tests/functional/pre-initial/03-drop/flow.cylc +++ /dev/null @@ -1,10 +0,0 @@ -[scheduler] - UTC mode = True -[scheduling] - initial cycle point = 20100101T00 - final cycle point = 20100102T00 - [[graph]] - PT6H = "a[-PT6H] & b[-PT6H] => a => b" -[runtime] - [[a, b]] - script = true diff --git a/tests/functional/pre-initial/03-drop/reference.log b/tests/functional/pre-initial/03-drop/reference.log deleted file mode 100644 index cecb29f06a0..00000000000 --- a/tests/functional/pre-initial/03-drop/reference.log +++ /dev/null @@ -1,12 +0,0 @@ -Initial point: 20100101T0000Z -Final point: 20100102T0000Z -20100101T0000Z/a -triggered off ['20091231T1800Z/a', '20091231T1800Z/b'] -20100101T0000Z/b -triggered off ['20100101T0000Z/a'] -20100101T0600Z/a -triggered off ['20100101T0000Z/a', '20100101T0000Z/b'] -20100101T0600Z/b -triggered off ['20100101T0600Z/a'] -20100101T1200Z/a -triggered off ['20100101T0600Z/a', '20100101T0600Z/b'] -20100101T1200Z/b -triggered off ['20100101T1200Z/a'] -20100101T1800Z/a -triggered off ['20100101T1200Z/a', '20100101T1200Z/b'] -20100101T1800Z/b -triggered off ['20100101T1800Z/a'] -20100102T0000Z/a -triggered off ['20100101T1800Z/a', '20100101T1800Z/b'] -20100102T0000Z/b -triggered off ['20100102T0000Z/a'] diff --git a/tests/functional/pre-initial/06-over-bracketed.t b/tests/functional/pre-initial/06-over-bracketed.t deleted file mode 100644 index e47da93e022..00000000000 --- a/tests/functional/pre-initial/06-over-bracketed.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test nested conditional simplification for pre-initial cycling. -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/pre-initial/06-over-bracketed/flow.cylc b/tests/functional/pre-initial/06-over-bracketed/flow.cylc deleted file mode 100644 index 64203d91e96..00000000000 --- a/tests/functional/pre-initial/06-over-bracketed/flow.cylc +++ /dev/null @@ -1,14 +0,0 @@ -[scheduler] - UTC mode = True - allow implicit tasks = True -[scheduling] - initial cycle point = 20131225T1200Z - final cycle point = 20131225T1200Z - [[graph]] - T12 = """ - (a[-P1D]:fail | b[-P1D]:fail | c[-P1D]:fail) => d - a & b & c # Implied by implicit cycling now... - """ -[runtime] - [[root]] - script = true diff --git a/tests/functional/pre-initial/06-over-bracketed/reference.log b/tests/functional/pre-initial/06-over-bracketed/reference.log deleted file mode 100644 index 5246592f6c6..00000000000 --- a/tests/functional/pre-initial/06-over-bracketed/reference.log +++ /dev/null @@ -1,6 +0,0 @@ -Initial point: 20131225T1200Z -Final point: 20131225T1200Z -20131225T1200Z/c -triggered off [] -20131225T1200Z/d -triggered off ['20131224T1200Z/a', '20131224T1200Z/b', '20131224T1200Z/c'] -20131225T1200Z/a -triggered off [] -20131225T1200Z/b -triggered off [] diff --git a/tests/integration/reftests/test_pre_initial.py b/tests/integration/reftests/test_pre_initial.py new file mode 100644 index 00000000000..1cf48cc4d7f --- /dev/null +++ b/tests/integration/reftests/test_pre_initial.py @@ -0,0 +1,122 @@ +# 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 +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +async def test_basic(flow, scheduler, reftest): + """Test simplification of basic conditionals in pre-initial cycling""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2010-01-01', + 'final cycle point': '2010-01-02', + 'graph': { + 'T00': 'a[-P1D] & b => a', + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + # 20100101T0000Z/b -triggered off [] + # 20100102T0000Z/b -triggered off [] + # 20100101T0000Z/a -triggered off ['20091231T0000Z/a', '20100101T0000Z/b'] + # 20100102T0000Z/a -triggered off ['20100101T0000Z/a', '20100102T0000Z/b'] + assert await reftest(schd) == { + ('20100101T0000Z/b', None), + ('20100102T0000Z/b', None), + ('20100101T0000Z/a', ('20091231T0000Z/a', '20100101T0000Z/b')), + ('20100102T0000Z/a', ('20100101T0000Z/a', '20100102T0000Z/b')), + } + + +async def test_advanced(flow, scheduler, reftest): + """Test nested conditional simplification for pre-initial cycling.""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2010-01-01', + 'final cycle point': '2010-01-02', + 'graph': { + 'PT6H': '(a[-PT6H] & b) & c[-PT6H] => a & c', + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('20100101T0000Z/b', None), + ('20100101T0600Z/b', None), + ('20100101T0000Z/a', ('20091231T1800Z/a', '20091231T1800Z/c', '20100101T0000Z/b')), + ('20100101T0000Z/c', ('20091231T1800Z/a', '20091231T1800Z/c', '20100101T0000Z/b')), + ('20100101T1200Z/b', None), + ('20100101T0600Z/a', ('20100101T0000Z/a', '20100101T0000Z/c', '20100101T0600Z/b')), + ('20100101T0600Z/c', ('20100101T0000Z/a', '20100101T0000Z/c', '20100101T0600Z/b')), + ('20100101T1800Z/b', None), + ('20100101T1200Z/a', ('20100101T0600Z/a', '20100101T0600Z/c', '20100101T1200Z/b')), + ('20100101T1200Z/c', ('20100101T0600Z/a', '20100101T0600Z/c', '20100101T1200Z/b')), + ('20100102T0000Z/b', None), + ('20100101T1800Z/c', ('20100101T1200Z/a', '20100101T1200Z/c', '20100101T1800Z/b')), + ('20100101T1800Z/a', ('20100101T1200Z/a', '20100101T1200Z/c', '20100101T1800Z/b')), + ('20100102T0000Z/a', ('20100101T1800Z/a', '20100101T1800Z/c', '20100102T0000Z/b')), + ('20100102T0000Z/c', ('20100101T1800Z/a', '20100101T1800Z/c', '20100102T0000Z/b')), + } + + +async def test_drop(flow, scheduler, reftest): + """Test the case of dropping a conditional based on pre-initial cycling""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2010-01-01', + 'final cycle point': '2010-01-02', + 'graph': { + 'PT6H': 'a[-PT6H] & b[-PT6H] => a => b', + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('20100101T0000Z/a', ('20091231T1800Z/a', '20091231T1800Z/b')), + ('20100101T0000Z/b', ('20100101T0000Z/a',)), + ('20100101T0600Z/a', ('20100101T0000Z/a', '20100101T0000Z/b')), + ('20100101T0600Z/b', ('20100101T0600Z/a',)), + ('20100101T1200Z/a', ('20100101T0600Z/a', '20100101T0600Z/b')), + ('20100101T1200Z/b', ('20100101T1200Z/a',)), + ('20100101T1800Z/a', ('20100101T1200Z/a', '20100101T1200Z/b')), + ('20100101T1800Z/b', ('20100101T1800Z/a',)), + ('20100102T0000Z/a', ('20100101T1800Z/a', '20100101T1800Z/b')), + ('20100102T0000Z/b', ('20100102T0000Z/a',)), + } + + +async def test_over_bracketed(flow, scheduler, reftest): + """Test nested conditional simplification for pre-initial cycling.""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2013-12-25T12:00Z', + 'final cycle point': '2013-12-25T12:00Z', + 'graph': { + 'T12': ''' + (a[-P1D]:fail | b[-P1D]:fail | c[-P1D]:fail) => d + a & b & c # Implied by implicit cycling now... + ''', + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('20131225T1200Z/c', None), + ('20131225T1200Z/d', ('20131224T1200Z/a', '20131224T1200Z/b', '20131224T1200Z/c')), + ('20131225T1200Z/a', None), + ('20131225T1200Z/b', None), + } From c397262c323abda4e43f686b425de20283086891 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Mon, 18 Dec 2023 12:25:38 +0000 Subject: [PATCH 3/6] Simplify integration reftest --- .../integration/{ => reftests}/test_triggering.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) rename tests/integration/{ => reftests}/test_triggering.py (76%) diff --git a/tests/integration/test_triggering.py b/tests/integration/reftests/test_triggering.py similarity index 76% rename from tests/integration/test_triggering.py rename to tests/integration/reftests/test_triggering.py index f086d46aa4c..bc1c0df402e 100644 --- a/tests/integration/test_triggering.py +++ b/tests/integration/reftests/test_triggering.py @@ -14,21 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -async def test_fail(flow, scheduler, run, reflog, complete, validate): +async def test_fail(flow, scheduler, reftest): """Test triggering on :fail""" id_ = flow({ - 'scheduler': { - 'allow implicit tasks': 'true' - }, 'scheduling': { 'graph': { 'R1': 'foo:failed => bar' } }, 'runtime': { - 'root': { - 'simulation': {'default run length': 'PT0S'} - }, 'foo': { 'simulation': {'fail cycle points': 'all'} } @@ -36,11 +30,7 @@ async def test_fail(flow, scheduler, run, reflog, complete, validate): }) schd = scheduler(id_, paused_start=False) - async with run(schd): - triggers = reflog(schd) - await complete(schd) - - assert triggers == { + assert await reftest(schd) == { ('1/foo', None), ('1/bar', ('1/foo',)), } From 3404f6ca910a74b6af9387c1db46b087d03f890d Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Wed, 20 Dec 2023 16:25:51 +0000 Subject: [PATCH 4/6] Replace cyclers functional reftests with integration reftests --- tests/functional/cyclers/21-360_calendar.t | 22 --- .../cyclers/21-360_calendar/flow.cylc | 11 -- .../cyclers/21-360_calendar/graph.plain.ref | 9 -- .../cyclers/21-360_calendar/reference.log | 6 - .../functional/cyclers/36-icp_fcp_notation.t | 22 --- .../cyclers/36-icp_fcp_notation/flow.cylc | 15 --- .../cyclers/36-icp_fcp_notation/reference.log | 7 - .../functional/cyclers/47-icp_fcp_notation.t | 36 ----- .../cyclers/47-icp_fcp_notation/flow.cylc | 15 --- tests/functional/cyclers/49-365_calendar.t | 22 --- .../cyclers/49-365_calendar/flow.cylc | 11 -- .../cyclers/49-365_calendar/graph.plain.ref | 5 - .../cyclers/49-365_calendar/reference.log | 4 - tests/functional/cyclers/50-366_calendar.t | 22 --- .../cyclers/50-366_calendar/flow.cylc | 11 -- .../cyclers/50-366_calendar/graph.plain.ref | 7 - .../cyclers/50-366_calendar/reference.log | 5 - .../functional/cyclers/51-recurrence_fmt_1.t | 22 --- .../cyclers/51-recurrence_fmt_1/flow.cylc | 11 -- .../cyclers/51-recurrence_fmt_1/reference.log | 6 - tests/integration/reftests/test_cyclers.py | 127 ++++++++++++++++++ 21 files changed, 127 insertions(+), 269 deletions(-) delete mode 100755 tests/functional/cyclers/21-360_calendar.t delete mode 100644 tests/functional/cyclers/21-360_calendar/flow.cylc delete mode 100644 tests/functional/cyclers/21-360_calendar/graph.plain.ref delete mode 100644 tests/functional/cyclers/21-360_calendar/reference.log delete mode 100755 tests/functional/cyclers/36-icp_fcp_notation.t delete mode 100644 tests/functional/cyclers/36-icp_fcp_notation/flow.cylc delete mode 100644 tests/functional/cyclers/36-icp_fcp_notation/reference.log delete mode 100755 tests/functional/cyclers/47-icp_fcp_notation.t delete mode 100644 tests/functional/cyclers/47-icp_fcp_notation/flow.cylc delete mode 100644 tests/functional/cyclers/49-365_calendar.t delete mode 100644 tests/functional/cyclers/49-365_calendar/flow.cylc delete mode 100644 tests/functional/cyclers/49-365_calendar/graph.plain.ref delete mode 100644 tests/functional/cyclers/49-365_calendar/reference.log delete mode 100644 tests/functional/cyclers/50-366_calendar.t delete mode 100644 tests/functional/cyclers/50-366_calendar/flow.cylc delete mode 100644 tests/functional/cyclers/50-366_calendar/graph.plain.ref delete mode 100644 tests/functional/cyclers/50-366_calendar/reference.log delete mode 100644 tests/functional/cyclers/51-recurrence_fmt_1.t delete mode 100644 tests/functional/cyclers/51-recurrence_fmt_1/flow.cylc delete mode 100644 tests/functional/cyclers/51-recurrence_fmt_1/reference.log create mode 100644 tests/integration/reftests/test_cyclers.py diff --git a/tests/functional/cyclers/21-360_calendar.t b/tests/functional/cyclers/21-360_calendar.t deleted file mode 100755 index 5f58beef713..00000000000 --- a/tests/functional/cyclers/21-360_calendar.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test intercycle dependencies. -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/cyclers/21-360_calendar/flow.cylc b/tests/functional/cyclers/21-360_calendar/flow.cylc deleted file mode 100644 index dd68f0ec60a..00000000000 --- a/tests/functional/cyclers/21-360_calendar/flow.cylc +++ /dev/null @@ -1,11 +0,0 @@ -[scheduler] - UTC mode = True -[scheduling] - initial cycle point = 20130228T00 - final cycle point = 20130301T00 - cycling mode = 360day - [[graph]] - P1D = foo[-P1D] => foo -[runtime] - [[foo]] - script = true diff --git a/tests/functional/cyclers/21-360_calendar/graph.plain.ref b/tests/functional/cyclers/21-360_calendar/graph.plain.ref deleted file mode 100644 index 56dba855ee2..00000000000 --- a/tests/functional/cyclers/21-360_calendar/graph.plain.ref +++ /dev/null @@ -1,9 +0,0 @@ -edge "20130228T00/foo" "20130229T00/foo" -edge "20130229T00/foo" "20130230T00/foo" -edge "20130230T00/foo" "20130301T00/foo" -graph -node "20130228T00/foo" "foo\n20130228T00" -node "20130229T00/foo" "foo\n20130229T00" -node "20130230T00/foo" "foo\n20130230T00" -node "20130301T00/foo" "foo\n20130301T00" -stop diff --git a/tests/functional/cyclers/21-360_calendar/reference.log b/tests/functional/cyclers/21-360_calendar/reference.log deleted file mode 100644 index 04bc0b86031..00000000000 --- a/tests/functional/cyclers/21-360_calendar/reference.log +++ /dev/null @@ -1,6 +0,0 @@ -Initial point: 20130228T00 -Final point: 20130301T00 -20130228T0000Z/foo -triggered off ['20130227T0000Z/foo'] -20130229T0000Z/foo -triggered off ['20130228T0000Z/foo'] -20130230T0000Z/foo -triggered off ['20130229T0000Z/foo'] -20130301T0000Z/foo -triggered off ['20130230T0000Z/foo'] diff --git a/tests/functional/cyclers/36-icp_fcp_notation.t b/tests/functional/cyclers/36-icp_fcp_notation.t deleted file mode 100755 index 96d5a35e895..00000000000 --- a/tests/functional/cyclers/36-icp_fcp_notation.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test initial and final cycle point special notation (^, $) -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/cyclers/36-icp_fcp_notation/flow.cylc b/tests/functional/cyclers/36-icp_fcp_notation/flow.cylc deleted file mode 100644 index d4a18a640a6..00000000000 --- a/tests/functional/cyclers/36-icp_fcp_notation/flow.cylc +++ /dev/null @@ -1,15 +0,0 @@ -[scheduler] - UTC mode = true - allow implicit tasks = True -[scheduling] - initial cycle point = 20160101T00Z - final cycle point = 20160102T00Z - [[graph]] - R1 = foo - R1/^ = bar - R1/^+PT1H = baz - R1/$-PT1H = boo - R1/$ = foo[^] & bar[^] & baz[^+PT1H] & boo[^+PT23H] => bot -[runtime] - [[ root ]] - script = echo "success" diff --git a/tests/functional/cyclers/36-icp_fcp_notation/reference.log b/tests/functional/cyclers/36-icp_fcp_notation/reference.log deleted file mode 100644 index 2d1494da8c1..00000000000 --- a/tests/functional/cyclers/36-icp_fcp_notation/reference.log +++ /dev/null @@ -1,7 +0,0 @@ -Initial point: 20160101T0000Z -Final point: 20160102T0000Z -20160101T0000Z/foo -triggered off [] -20160101T0000Z/bar -triggered off [] -20160101T0100Z/baz -triggered off [] -20160101T2300Z/boo -triggered off [] -20160102T0000Z/bot -triggered off ['20160101T0000Z/bar', '20160101T0000Z/foo', '20160101T0100Z/baz', '20160101T2300Z/boo'] diff --git a/tests/functional/cyclers/47-icp_fcp_notation.t b/tests/functional/cyclers/47-icp_fcp_notation.t deleted file mode 100755 index 7f455983e9b..00000000000 --- a/tests/functional/cyclers/47-icp_fcp_notation.t +++ /dev/null @@ -1,36 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test intercycle dependencies. -. "$(dirname "$0")/test_header" -#------------------------------------------------------------------------------- -set_test_number 6 -#------------------------------------------------------------------------------- -# test initial and final cycle point special notation (^, $) -TEST_NAME=${TEST_NAME_BASE} -install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" -TEST_NAME="${TEST_NAME_BASE}-run" -run_ok "${TEST_NAME}" cylc play "${WORKFLOW_NAME}" --debug --no-detach - -TEST_NAME=${TEST_NAME_BASE}-out -grep_ok "20160101T0000Z/foo" "$HOME/cylc-run/${WORKFLOW_NAME}/log/scheduler/log" -grep_ok "20160101T0000Z/bar" "$HOME/cylc-run/${WORKFLOW_NAME}/log/scheduler/log" -grep_ok "20160101T0100Z/baz" "$HOME/cylc-run/${WORKFLOW_NAME}/log/scheduler/log" -grep_ok "20160101T2300Z/boo" "$HOME/cylc-run/${WORKFLOW_NAME}/log/scheduler/log" -grep_ok "20160102T0000Z/bot" "$HOME/cylc-run/${WORKFLOW_NAME}/log/scheduler/log" -#------------------------------------------------------------------------------- -purge diff --git a/tests/functional/cyclers/47-icp_fcp_notation/flow.cylc b/tests/functional/cyclers/47-icp_fcp_notation/flow.cylc deleted file mode 100644 index d4a18a640a6..00000000000 --- a/tests/functional/cyclers/47-icp_fcp_notation/flow.cylc +++ /dev/null @@ -1,15 +0,0 @@ -[scheduler] - UTC mode = true - allow implicit tasks = True -[scheduling] - initial cycle point = 20160101T00Z - final cycle point = 20160102T00Z - [[graph]] - R1 = foo - R1/^ = bar - R1/^+PT1H = baz - R1/$-PT1H = boo - R1/$ = foo[^] & bar[^] & baz[^+PT1H] & boo[^+PT23H] => bot -[runtime] - [[ root ]] - script = echo "success" diff --git a/tests/functional/cyclers/49-365_calendar.t b/tests/functional/cyclers/49-365_calendar.t deleted file mode 100644 index 5f58beef713..00000000000 --- a/tests/functional/cyclers/49-365_calendar.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test intercycle dependencies. -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/cyclers/49-365_calendar/flow.cylc b/tests/functional/cyclers/49-365_calendar/flow.cylc deleted file mode 100644 index 86073fe8c56..00000000000 --- a/tests/functional/cyclers/49-365_calendar/flow.cylc +++ /dev/null @@ -1,11 +0,0 @@ -[scheduler] - UTC mode = True -[scheduling] - initial cycle point = 20120228T00 - final cycle point = 20120301T00 - cycling mode = 365day - [[graph]] - P1D = foo[-P1D] => foo -[runtime] - [[foo]] - script = true diff --git a/tests/functional/cyclers/49-365_calendar/graph.plain.ref b/tests/functional/cyclers/49-365_calendar/graph.plain.ref deleted file mode 100644 index 7f0a0d0706e..00000000000 --- a/tests/functional/cyclers/49-365_calendar/graph.plain.ref +++ /dev/null @@ -1,5 +0,0 @@ -edge "20120228T00/foo" "20120330T00/foo" -graph -node "20120228T00/foo" "foo\n20120228T00" -node "20120301T00/foo" "foo\n20120301T00" -stop diff --git a/tests/functional/cyclers/49-365_calendar/reference.log b/tests/functional/cyclers/49-365_calendar/reference.log deleted file mode 100644 index 920807e835e..00000000000 --- a/tests/functional/cyclers/49-365_calendar/reference.log +++ /dev/null @@ -1,4 +0,0 @@ -Initial point: 20120228T00 -Final point: 20120301T00 -20120228T0000Z/foo -triggered off ['20120227T0000Z/foo'] -20120301T0000Z/foo -triggered off ['20120228T0000Z/foo'] diff --git a/tests/functional/cyclers/50-366_calendar.t b/tests/functional/cyclers/50-366_calendar.t deleted file mode 100644 index 5f58beef713..00000000000 --- a/tests/functional/cyclers/50-366_calendar.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test intercycle dependencies. -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/cyclers/50-366_calendar/flow.cylc b/tests/functional/cyclers/50-366_calendar/flow.cylc deleted file mode 100644 index 1c38cb46777..00000000000 --- a/tests/functional/cyclers/50-366_calendar/flow.cylc +++ /dev/null @@ -1,11 +0,0 @@ -[scheduler] - UTC mode = True -[scheduling] - initial cycle point = 20130228T00 - final cycle point = 20130301T00 - cycling mode = 366day - [[graph]] - P1D = foo[-P1D] => foo -[runtime] - [[foo]] - script = true diff --git a/tests/functional/cyclers/50-366_calendar/graph.plain.ref b/tests/functional/cyclers/50-366_calendar/graph.plain.ref deleted file mode 100644 index e49811ab8bf..00000000000 --- a/tests/functional/cyclers/50-366_calendar/graph.plain.ref +++ /dev/null @@ -1,7 +0,0 @@ -edge "20130228T00/foo" "20130229T00/foo" -edge "20130229T00/foo" "20130301T00/foo" -graph -node "20130228T00/foo" "foo\n20130228T00" -node "20130229T00/foo" "foo\n20130229T00" -node "20130301T00/foo" "foo\n20130301T00" -stop diff --git a/tests/functional/cyclers/50-366_calendar/reference.log b/tests/functional/cyclers/50-366_calendar/reference.log deleted file mode 100644 index a74c1954ed5..00000000000 --- a/tests/functional/cyclers/50-366_calendar/reference.log +++ /dev/null @@ -1,5 +0,0 @@ -Initial point: 20130228T00 -Final point: 20130301T00 -20130228T0000Z/foo -triggered off ['20130227T0000Z/foo'] -20130229T0000Z/foo -triggered off ['20130228T0000Z/foo'] -20130301T0000Z/foo -triggered off ['20130229T0000Z/foo'] diff --git a/tests/functional/cyclers/51-recurrence_fmt_1.t b/tests/functional/cyclers/51-recurrence_fmt_1.t deleted file mode 100644 index 6f90a79e4b5..00000000000 --- a/tests/functional/cyclers/51-recurrence_fmt_1.t +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -#------------------------------------------------------------------------------- -# Test ISO 8601 recurrence format no. 1 with unbounded repetitions -. "$(dirname "$0")/test_header" -set_test_number 2 -reftest -exit diff --git a/tests/functional/cyclers/51-recurrence_fmt_1/flow.cylc b/tests/functional/cyclers/51-recurrence_fmt_1/flow.cylc deleted file mode 100644 index 8d83a47f1fa..00000000000 --- a/tests/functional/cyclers/51-recurrence_fmt_1/flow.cylc +++ /dev/null @@ -1,11 +0,0 @@ -[meta] - description = Test ISO 8601 recurrence format 1 -[scheduler] - UTC mode = True - allow implicit tasks = True - cycle point format = CCYY-MM-DD -[scheduling] - initial cycle point = 2010-01-01 - final cycle point = 2010-01-10 - [[graph]] - R/2010-01-01/2010-01-04 = worf # 3-day interval diff --git a/tests/functional/cyclers/51-recurrence_fmt_1/reference.log b/tests/functional/cyclers/51-recurrence_fmt_1/reference.log deleted file mode 100644 index dda1e323ebd..00000000000 --- a/tests/functional/cyclers/51-recurrence_fmt_1/reference.log +++ /dev/null @@ -1,6 +0,0 @@ -Initial point: 2010-01-01 -Final point: 2010-01-12 -2010-01-01/worf -triggered off [] -2010-01-04/worf -triggered off [] -2010-01-07/worf -triggered off [] -2010-01-10/worf -triggered off [] diff --git a/tests/integration/reftests/test_cyclers.py b/tests/integration/reftests/test_cyclers.py new file mode 100644 index 00000000000..ccc6f718904 --- /dev/null +++ b/tests/integration/reftests/test_cyclers.py @@ -0,0 +1,127 @@ +# 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 +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +async def test_360_calendar(flow, scheduler, reftest): + """Test 360 day calendar.""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2013-02-28', + 'final cycle point': '2013-03-01', + 'cycling mode': '360day', + 'graph': { + 'P1D': 'foo[-P1D] => foo' + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('20130228T0000Z/foo', ('20130227T0000Z/foo',)), + ('20130229T0000Z/foo', ('20130228T0000Z/foo',)), + ('20130230T0000Z/foo', ('20130229T0000Z/foo',)), + ('20130301T0000Z/foo', ('20130230T0000Z/foo',)), + } + + +async def test_365_calendar(flow, scheduler, reftest): + """Test 365 day calendar.""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2012-02-28', + 'final cycle point': '2012-03-01', + 'cycling mode': '365day', + 'graph': { + 'P1D': 'foo[-P1D] => foo' + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('20120228T0000Z/foo', ('20120227T0000Z/foo',)), + ('20120301T0000Z/foo', ('20120228T0000Z/foo',)), + } + + +async def test_366_calendar(flow, scheduler, reftest): + """Test 366 day calendar.""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2013-02-28', + 'final cycle point': '2013-03-01', + 'cycling mode': '366day', + 'graph': { + 'P1D': 'foo[-P1D] => foo' + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('20130228T0000Z/foo', ('20130227T0000Z/foo',)), + ('20130229T0000Z/foo', ('20130228T0000Z/foo',)), + ('20130301T0000Z/foo', ('20130229T0000Z/foo',)), + } + + +async def test_icp_fcp_notation(flow, scheduler, reftest): + """Test initial and final cycle point special notation (^, $)""" + wid = flow({ + 'scheduling': { + 'initial cycle point': '2016-01-01', + 'final cycle point': '2016-01-02', + 'graph': { + 'R1': 'foo', + 'R1/^': 'bar', + 'R1/^+PT1H': 'baz', + 'R1/$-PT1H': 'boo', + 'R1/$': 'foo[^] & bar[^] & baz[^+PT1H] & boo[^+PT23H] => bot' + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('20160101T0000Z/foo', None), + ('20160101T0000Z/bar', None), + ('20160101T0100Z/baz', None), + ('20160101T2300Z/boo', None), + ('20160102T0000Z/bot', ('20160101T0000Z/bar', '20160101T0000Z/foo', '20160101T0100Z/baz', '20160101T2300Z/boo')), + } + + +async def test_recurrence_format_1(flow, scheduler, reftest): + """Test ISO 8601 recurrence format no. 1 with unbounded repetitions.""" + wid = flow({ + 'scheduler': { + 'cycle point format': 'CCYY-MM-DD', + }, + 'scheduling': { + 'initial cycle point': '2010-01-01', + 'final cycle point': '2010-01-10', + 'graph': { + 'R/2010-01-01/2010-01-04': 'worf', # 3-day interval + }, + }, + }) + schd = scheduler(wid, paused_start=False) + + assert await reftest(schd) == { + ('2010-01-01/worf', None), + ('2010-01-04/worf', None), + ('2010-01-07/worf', None), + ('2010-01-10/worf', None), + } From 9df0272225cd792c80b53a694831bd16633c95c6 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Wed, 20 Dec 2023 16:31:15 +0000 Subject: [PATCH 5/6] Tests: fix cached datetime arithmetic contamination between tests using different calendar modes --- cylc/flow/cycling/iso8601.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cylc/flow/cycling/iso8601.py b/cylc/flow/cycling/iso8601.py index 3c8bd3955fa..553b63e4b2f 100644 --- a/cylc/flow/cycling/iso8601.py +++ b/cylc/flow/cycling/iso8601.py @@ -88,7 +88,9 @@ def from_nonstandard_string(cls, point_string): def add(self, other): """Add an Interval to self.""" - return ISO8601Point(self._iso_point_add(self.value, other.value)) + return ISO8601Point(self._iso_point_add( + self.value, other.value, CALENDAR.mode + )) def standardise(self): """Reformat self.value into a standard representation.""" @@ -106,25 +108,27 @@ def standardise(self): def sub(self, other): """Subtract a Point or Interval from self.""" if isinstance(other, ISO8601Point): - return ISO8601Interval( - self._iso_point_sub_point(self.value, other.value)) - return ISO8601Point( - self._iso_point_sub_interval(self.value, other.value)) + return ISO8601Interval(self._iso_point_sub_point( + self.value, other.value, CALENDAR.mode + )) + return ISO8601Point(self._iso_point_sub_interval( + self.value, other.value, CALENDAR.mode + )) @staticmethod @lru_cache(10000) - def _iso_point_add(point_string, interval_string): + def _iso_point_add(point_string, interval_string, _calendar_mode): """Add the parsed point_string to the parsed interval_string.""" point = point_parse(point_string) interval = interval_parse(interval_string) return str(point + interval) def _cmp(self, other: 'ISO8601Point') -> int: - return self._iso_point_cmp(self.value, other.value) + return self._iso_point_cmp(self.value, other.value, CALENDAR.mode) @staticmethod @lru_cache(10000) - def _iso_point_cmp(point_string, other_point_string): + def _iso_point_cmp(point_string, other_point_string, _calendar_mode): """Compare the parsed point_string to the other one.""" point = point_parse(point_string) other_point = point_parse(other_point_string) @@ -132,7 +136,7 @@ def _iso_point_cmp(point_string, other_point_string): @staticmethod @lru_cache(10000) - def _iso_point_sub_interval(point_string, interval_string): + def _iso_point_sub_interval(point_string, interval_string, _calendar_mode): """Return the parsed point_string minus the parsed interval_string.""" point = point_parse(point_string) interval = interval_parse(interval_string) @@ -140,7 +144,7 @@ def _iso_point_sub_interval(point_string, interval_string): @staticmethod @lru_cache(10000) - def _iso_point_sub_point(point_string, other_point_string): + def _iso_point_sub_point(point_string, other_point_string, _calendar_mode): """Return the difference between the two parsed point strings.""" point = point_parse(point_string) other_point = point_parse(other_point_string) From d4a9d0ad5e6c3bdf807af623342254e00869e8aa Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Mon, 8 Jan 2024 14:38:51 +1300 Subject: [PATCH 6/6] Apply suggestions from code review [skip ci] Co-authored-by: Oliver Sanders --- tests/integration/reftests/test_pre_initial.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integration/reftests/test_pre_initial.py b/tests/integration/reftests/test_pre_initial.py index 1cf48cc4d7f..d1ed6a6e566 100644 --- a/tests/integration/reftests/test_pre_initial.py +++ b/tests/integration/reftests/test_pre_initial.py @@ -27,10 +27,6 @@ async def test_basic(flow, scheduler, reftest): }) schd = scheduler(wid, paused_start=False) - # 20100101T0000Z/b -triggered off [] - # 20100102T0000Z/b -triggered off [] - # 20100101T0000Z/a -triggered off ['20091231T0000Z/a', '20100101T0000Z/b'] - # 20100102T0000Z/a -triggered off ['20100101T0000Z/a', '20100102T0000Z/b'] assert await reftest(schd) == { ('20100101T0000Z/b', None), ('20100102T0000Z/b', None),