14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
17
+ import asyncio
17
18
import pytest
18
19
import sqlite3
20
+ from typing import TYPE_CHECKING
19
21
20
- from cylc .flow .scheduler import Scheduler
22
+ from cylc .flow .cycling .iso8601 import ISO8601Point
23
+
24
+ if TYPE_CHECKING :
25
+ from cylc .flow .scheduler import Scheduler
21
26
22
27
23
28
async def test_restart_number (
@@ -29,7 +34,7 @@ async def test_restart_number(
29
34
async def test (expected_restart_num : int , do_reload : bool = False ):
30
35
"""(Re)start the workflow and check the restart number is as expected.
31
36
"""
32
- schd : Scheduler = scheduler (id_ , paused_start = True )
37
+ schd : ' Scheduler' = scheduler (id_ , paused_start = True )
33
38
async with start (schd ) as log :
34
39
if do_reload :
35
40
schd .command_reload_workflow ()
@@ -52,7 +57,7 @@ async def test(expected_restart_num: int, do_reload: bool = False):
52
57
await test (expected_restart_num = 3 )
53
58
54
59
55
- def db_remove_column (schd : Scheduler , table : str , column : str ) -> None :
60
+ def db_remove_column (schd : ' Scheduler' , table : str , column : str ) -> None :
56
61
"""Remove a column from a scheduler DB table.
57
62
58
63
ALTER TABLE DROP COLUMN is not supported by sqlite yet, so we have to copy
@@ -82,23 +87,23 @@ async def test_db_upgrade_pre_803(
82
87
id_ = flow (one_conf )
83
88
84
89
# Run a scheduler to create a DB.
85
- schd : Scheduler = scheduler (id_ , paused_start = True )
90
+ schd : ' Scheduler' = scheduler (id_ , paused_start = True )
86
91
async with start (schd ):
87
92
assert ('n_restart' , '0' ) in db_select (schd , False , 'workflow_params' )
88
93
89
94
# Remove task_states:is_manual_submit to fake a pre-8.0.3 DB.
90
95
db_remove_column (schd , "task_states" , "is_manual_submit" )
91
96
db_remove_column (schd , "task_jobs" , "flow_nums" )
92
97
93
- schd : Scheduler = scheduler (id_ , paused_start = True )
98
+ schd : ' Scheduler' = scheduler (id_ , paused_start = True )
94
99
95
100
# Restart should fail due to the missing column.
96
101
with pytest .raises (sqlite3 .OperationalError ):
97
102
async with start (schd ):
98
103
pass
99
104
assert ('n_restart' , '1' ) in db_select (schd , False , 'workflow_params' )
100
105
101
- schd : Scheduler = scheduler (id_ , paused_start = True )
106
+ schd : ' Scheduler' = scheduler (id_ , paused_start = True )
102
107
103
108
# Run the DB upgrader for version 8.0.2
104
109
# (8.0.2 requires upgrade)
@@ -117,7 +122,7 @@ async def test_workflow_param_rapid_toggle(
117
122
118
123
https://github.com/cylc/cylc-flow/issues/5593
119
124
"""
120
- schd : Scheduler = scheduler (flow (one_conf ), paused_start = False )
125
+ schd : ' Scheduler' = scheduler (flow (one_conf ), paused_start = False )
121
126
async with run (schd ):
122
127
assert schd .is_paused is False
123
128
schd .pause_workflow ()
@@ -127,3 +132,50 @@ async def test_workflow_param_rapid_toggle(
127
132
128
133
w_params = dict (schd .workflow_db_mgr .pri_dao .select_workflow_params ())
129
134
assert w_params ['is_paused' ] == '0'
135
+
136
+
137
+ async def test_record_only_non_clock_triggers (
138
+ flow , run , scheduler , complete , db_select
139
+ ):
140
+ """Database does not record wall_clock xtriggers.
141
+
142
+ https://github.com/cylc/cylc-flow/issues/5911
143
+
144
+ Includes:
145
+ - Not in DB: A normal wall clock xtrigger (wall_clock).
146
+ - In DB: An xrandom mis-labelled as wall_clock trigger DB).
147
+ - Not in DB: An execution retry xtrigger.
148
+
149
+ @TODO: Refactor to use simulation mode to speedup after Simulation
150
+ mode upgrade bugfixes: This should speed this test up considerably.
151
+ """
152
+ rawpoint = '1348'
153
+ id_ = flow ({
154
+ "scheduler" : {
155
+ 'cycle point format' : '%Y' ,
156
+ 'allow implicit tasks' : True
157
+ },
158
+ "scheduling" : {
159
+ "initial cycle point" : rawpoint ,
160
+ "xtriggers" : {
161
+ "another" : "xrandom(100)" ,
162
+ "wall_clock" : "xrandom(100, _=Not a real wall clock trigger)" ,
163
+ "real_wall_clock" : "wall_clock()"
164
+ },
165
+ "graph" : {
166
+ "R1" : """
167
+ @another & @wall_clock & @real_wall_clock => foo
168
+ @real_wall_clock => bar
169
+ """
170
+ }
171
+ },
172
+ })
173
+ schd = scheduler (id_ , paused_start = False , run_mode = 'simulation' )
174
+
175
+ async with run (schd ):
176
+ await complete (schd , timeout = 20 )
177
+
178
+ # Assert that (only) the real clock trigger is not in the db:
179
+ assert db_select (schd , False , 'xtriggers' , 'signature' ) == [
180
+ ('xrandom(100)' ,),
181
+ ('xrandom(100, _=Not a real wall clock trigger)' ,)]
0 commit comments