@@ -36,7 +36,6 @@ async def test_reload_waits_for_pending_tasks(
3636 scheduler ,
3737 start ,
3838 monkeypatch ,
39- capture_submission ,
4039 log_scan ,
4140):
4241 """Reload should flush out preparing tasks and pause the workflow.
@@ -47,9 +46,11 @@ async def test_reload_waits_for_pending_tasks(
4746
4847 See https://github.com/cylc/cylc-flow/issues/5107
4948 """
49+ # speed up the test:
50+ monkeypatch .setattr ('cylc.flow.scheduler.sleep' , lambda * _ : None )
5051 # a simple workflow with a single task
5152 id_ = flow ('foo' )
52- schd = scheduler (id_ , paused_start = False )
53+ schd : Scheduler = scheduler (id_ , paused_start = False )
5354
5455 # we will artificially push the task through these states
5556 state_seq = [
@@ -63,26 +64,24 @@ async def test_reload_waits_for_pending_tasks(
6364
6465 # start the scheduler
6566 async with start (schd ) as log :
66- # disable submission events to prevent anything from actually running
67- capture_submission (schd )
67+ foo = schd .pool .get_tasks ()[0 ]
6868
6969 # set the task to go through some state changes
70- def change_state ( _ = 0 ):
70+ def submit_task_jobs ( * a , ** k ):
7171 with suppress (IndexError ):
7272 foo .state_reset (state_seq .pop (0 ))
73+ return [foo ]
74+
7375 monkeypatch .setattr (
74- 'cylc.flow.scheduler.sleep' ,
75- change_state
76+ schd .task_job_mgr , 'submit_task_jobs' , submit_task_jobs
7677 )
7778
7879 # the task should start as waiting
79- tasks = schd .pool .get_tasks ()
80- assert len (tasks ) == 1
81- foo = tasks [0 ]
82- assert tasks [0 ].state (TASK_STATUS_WAITING )
80+ assert foo .state (TASK_STATUS_WAITING )
8381
8482 # put the task into the preparing state
85- change_state ()
83+ schd .release_tasks_to_run ()
84+ assert foo .state (TASK_STATUS_PREPARING )
8685
8786 # reload the workflow
8887 await commands .run_cmd (commands .reload_workflow (schd ))
@@ -96,12 +95,11 @@ def change_state(_=0):
9695 [
9796 # the task should have entered the preparing state before the
9897 # reload was requested
99- '[1/foo:waiting(queued) ] => preparing(queued) ' ,
98+ '[1/foo:waiting] => preparing' ,
10099 # the reload should have put the workflow into the paused state
101100 'Pausing the workflow: Reloading workflow' ,
102101 # reload should have waited for the task to submit
103- '[1/foo/00:preparing(queued)]'
104- ' => submitted(queued)' ,
102+ '[1/foo/00:preparing] => submitted' ,
105103 # before then reloading the workflow config
106104 'Reloading the workflow definition.' ,
107105 # post-reload the workflow should have been resumed
0 commit comments