Debian Codegraph @

tests/i/scripts/test_back_compat_flow_all.py

raw
1 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
2 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 """Test set, trigger, and remove command back-compat with --flow=all.
18
19 This option is now just the default (flows = ['all'] -> []).
20
21 BACK COMPAT: handle --flow=all from pre-8.5 clients
22 """
23
24 import pytest
25
26 from cylc.flow.commands import (
27 force_trigger_tasks,
28 remove_tasks,
29 run_cmd,
30 set_prereqs_and_outputs,
31 )
32 from cylc.flow.exceptions import InputError
33 from cylc.flow.scheduler import Scheduler
34 from cylc.flow.task_outputs import TASK_OUTPUT_SUCCEEDED
35
36
37 async def test_back_compat_flow_all(flow, scheduler, start):
38 """Handle --flow=all from old clients.
39
40 The trigger, set, and remove commmands no longer take --flow=all, but
41 for a while we need to handle that option coming in from older clients.
42
43 (Prior to 8.5 it was the schema default for remove, and was documented
44 as an option for set and trigger).
45
46 """
47 conf = {
48 'scheduling': {
49 'graph': {
50 'R1': 'a & b'
51 },
52 },
53 }
54 schd: Scheduler = scheduler(flow(conf))
55 async with start(schd):
56 foo, bar = schd.pool.get_tasks()
57
58 # For comparison, set should fail with an illegal flow value (allx)
59 with pytest.raises(
60 InputError,
61 match="Flow values must be integers, or 'new', or 'none'"
62 ):
63 await run_cmd(
64 set_prereqs_and_outputs(schd, [foo.identity], ['allx'])
65 )
66 # but the old --flow=all is OK - it converts to the default.
67 await run_cmd(
68 set_prereqs_and_outputs(schd, [foo.identity], ['all'])
69 )
70 assert (
71 TASK_OUTPUT_SUCCEEDED in foo.state.outputs.get_completed_outputs()
72 )
73
74 # For comparison, trigger should fail with an illegal flow value (allx)
75 with pytest.raises(
76 InputError,
77 match="Flow values must be integers, or 'new', or 'none'"
78 ):
79 await run_cmd(
80 force_trigger_tasks(schd, [bar.identity], ['allx'])
81 )
82 # but the old --flow=all is OK - it converts to the default.
83 await run_cmd(
84 force_trigger_tasks(schd, [bar.identity], ['all'])
85 )
86 assert bar in schd.pool.tasks_to_trigger_now
87
88 # For comparison, remove should fail with an illegal flow value (allx)
89 with pytest.raises(
90 InputError,
91 match="Flow values must be integers"
92 ):
93 await run_cmd(
94 remove_tasks(schd, [bar.identity], ['allx'])
95 )
96 # but the old --flow=all is OK - it converts to the default.
97 await run_cmd(
98 remove_tasks(schd, [bar.identity], ['all'])
99 )
100 assert bar not in schd.pool.get_tasks()
101 assert bar not in schd.pool.tasks_to_trigger_now