@@ -65,8 +65,10 @@ def test_pause_and_resume(self):
6565 # but task1 will still be running to allow for graceful exit.
6666 self .st2client .executions .pause (ex .id )
6767
68- # Expecting the ex to be canceling, waiting for task1 to be completed.
69- ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_PAUSING )
68+ # Expecting the ex to be pausing or paused, waiting for task1 to be completed.
69+ ex = self ._wait_for_state (
70+ ex , [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ]
71+ )
7072
7173 # Delete the temporary file.
7274 os .remove (path )
@@ -96,9 +98,14 @@ def test_pause_and_resume_cascade_to_subworkflow(self):
9698 # but task1 will still be running to allow for graceful exit.
9799 ex = self .st2client .executions .pause (ex .id )
98100
99- # Expecting the ex to be pausing, waiting for task1 to be completed.
100- ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_PAUSING )
101- tk_ac_ex = self ._wait_for_state (tk_exs [0 ], ac_const .LIVEACTION_STATUS_PAUSING )
101+ # Expecting the ex to be pausing or paused, waiting for task1 to be completed.
102+ ex = self ._wait_for_state (
103+ ex , [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ]
104+ )
105+ tk_ac_ex = self ._wait_for_state (
106+ tk_exs [0 ],
107+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
108+ )
102109
103110 # Delete the temporary file.
104111 os .remove (path )
@@ -133,19 +140,32 @@ def test_pause_and_resume_cascade_to_subworkflows(self):
133140 # but task1 will still be running to allow for graceful exit.
134141 ex = self .st2client .executions .pause (ex .id )
135142
136- # Expecting the ex to be pausing, waiting for task1 to be completed.
137- ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_PAUSING )
138- tk1_ac_ex = self ._wait_for_state (tk1_exs [0 ], ac_const .LIVEACTION_STATUS_PAUSING )
139- tk2_ac_ex = self ._wait_for_state (tk2_exs [0 ], ac_const .LIVEACTION_STATUS_PAUSING )
143+ # Expecting the ex to be pausing or paused, waiting for task1 to be completed.
144+ ex = self ._wait_for_state (
145+ ex , [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ]
146+ )
147+ tk1_ac_ex = self ._wait_for_state (
148+ tk1_exs [0 ],
149+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
150+ )
151+ tk2_ac_ex = self ._wait_for_state (
152+ tk2_exs [0 ],
153+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
154+ )
140155
141156 # Delete the temporary file for one of the subworkflow.
142157 os .remove (path1 )
143158 self .assertFalse (os .path .exists (path1 ))
144159
145160 # Check the workflow and subworkflow status.
146161 tk1_ac_ex = self ._wait_for_state (tk1_ac_ex , ac_const .LIVEACTION_STATUS_PAUSED )
147- tk1_ac_ex = self ._wait_for_state (tk2_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
148- ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_PAUSING )
162+ tk1_ac_ex = self ._wait_for_state (
163+ tk2_ac_ex ,
164+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
165+ )
166+ ex = self ._wait_for_state (
167+ ex , [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ]
168+ )
149169
150170 # Delete the temporary file for the other subworkflow.
151171 os .remove (path2 )
@@ -183,9 +203,12 @@ def test_pause_and_resume_cascade_from_subworkflow(self):
183203 # paused but workflow will still be running.
184204 tk_ac_ex = self .st2client .executions .pause (tk_exs [0 ].id )
185205
186- # Expecting the workflow is still running and task1 is pausing.
206+ # Expecting the workflow is still running and task1 is pausing or paused .
187207 ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_RUNNING )
188- tk_ac_ex = self ._wait_for_state (tk_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
208+ tk_ac_ex = self ._wait_for_state (
209+ tk_ac_ex ,
210+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
211+ )
189212
190213 # Delete the temporary file.
191214 os .remove (path )
@@ -222,9 +245,12 @@ def test_pause_from_1_of_2_subworkflows_and_resume_subworkflow_when_workflow_pau
222245 # paused but workflow and the other subworkflow will still be running.
223246 tk1_ac_ex = self .st2client .executions .pause (tk1_exs [0 ].id )
224247
225- # Expecting the workflow is still running and task1 is pausing.
248+ # Expecting the workflow is still running and task1 is pausing or paused .
226249 ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_RUNNING )
227- tk1_ac_ex = self ._wait_for_state (tk1_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
250+ tk1_ac_ex = self ._wait_for_state (
251+ tk1_ac_ex ,
252+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
253+ )
228254 tk2_ac_ex = self ._wait_for_state (tk2_exs [0 ], ac_const .LIVEACTION_STATUS_RUNNING )
229255
230256 # Delete the temporary file for the subworkflow.
@@ -282,7 +308,10 @@ def test_pause_from_1_of_2_subworkflows_and_resume_subworkflow_while_workflow_ru
282308
283309 # Expecting the workflow is still running and task1 is pausing.
284310 ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_RUNNING )
285- tk1_ac_ex = self ._wait_for_state (tk1_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
311+ tk1_ac_ex = self ._wait_for_state (
312+ tk1_ac_ex ,
313+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSING ],
314+ )
286315 tk2_ac_ex = self ._wait_for_state (tk2_exs [0 ], ac_const .LIVEACTION_STATUS_RUNNING )
287316
288317 # Delete the temporary file for the subworkflow.
@@ -336,19 +365,28 @@ def test_pause_from_all_subworkflows_and_resume_from_subworkflows(self):
336365 # paused but workflow and the other subworkflow will still be running.
337366 tk1_ac_ex = self .st2client .executions .pause (tk1_exs [0 ].id )
338367
339- # Expecting the workflow is still running and task1 is pausing.
368+ # Expecting the workflow is still running and task1 is pausing or paused .
340369 ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_RUNNING )
341- tk1_ac_ex = self ._wait_for_state (tk1_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
370+ tk1_ac_ex = self ._wait_for_state (
371+ tk1_ac_ex ,
372+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
373+ )
342374 tk2_ac_ex = self ._wait_for_state (tk2_exs [0 ], ac_const .LIVEACTION_STATUS_RUNNING )
343375
344376 # Pause the other subworkflow before the temp file is deleted. The main
345377 # workflow will still running because pause is initiated downstream.
346378 tk2_ac_ex = self .st2client .executions .pause (tk2_exs [0 ].id )
347379
348- # Expecting workflow and subworkflows are pausing.
380+ # Expecting workflow and subworkflows are pausing or paused .
349381 ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_RUNNING )
350- tk1_ac_ex = self ._wait_for_state (tk1_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
351- tk2_ac_ex = self ._wait_for_state (tk2_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
382+ tk1_ac_ex = self ._wait_for_state (
383+ tk1_ac_ex ,
384+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
385+ )
386+ tk2_ac_ex = self ._wait_for_state (
387+ tk2_ac_ex ,
388+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
389+ )
352390
353391 # Delete the temporary files for the subworkflows.
354392 os .remove (path1 )
@@ -402,19 +440,28 @@ def test_pause_from_all_subworkflows_and_resume_from_parent_workflow(self):
402440 # paused but workflow and the other subworkflow will still be running.
403441 tk1_ac_ex = self .st2client .executions .pause (tk1_exs [0 ].id )
404442
405- # Expecting the workflow is still running and task1 is pausing.
443+ # Expecting the workflow is still running and task1 is pausing or paused .
406444 ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_RUNNING )
407- tk1_ac_ex = self ._wait_for_state (tk1_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
445+ tk1_ac_ex = self ._wait_for_state (
446+ tk1_ac_ex ,
447+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
448+ )
408449 tk2_ac_ex = self ._wait_for_state (tk2_exs [0 ], ac_const .LIVEACTION_STATUS_RUNNING )
409450
410451 # Pause the other subworkflow before the temp file is deleted. The main
411452 # workflow will still running because pause is initiated downstream.
412453 tk2_ac_ex = self .st2client .executions .pause (tk2_exs [0 ].id )
413454
414- # Expecting workflow and subworkflows are pausing.
455+ # Expecting workflow and subworkflows are pausing or paused .
415456 ex = self ._wait_for_state (ex , ac_const .LIVEACTION_STATUS_RUNNING )
416- tk1_ac_ex = self ._wait_for_state (tk1_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
417- tk2_ac_ex = self ._wait_for_state (tk2_ac_ex , ac_const .LIVEACTION_STATUS_PAUSING )
457+ tk1_ac_ex = self ._wait_for_state (
458+ tk1_ac_ex ,
459+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
460+ )
461+ tk2_ac_ex = self ._wait_for_state (
462+ tk2_ac_ex ,
463+ [ac_const .LIVEACTION_STATUS_PAUSING , ac_const .LIVEACTION_STATUS_PAUSED ],
464+ )
418465
419466 # Delete the temporary files for the subworkflows.
420467 os .remove (path1 )
0 commit comments