@@ -987,11 +987,32 @@ func TestSynchronizationForPendingShuttingdownWfs(t *testing.T) {
987987 wfTwo , err = controller .wfclientset .ArgoprojV1alpha1 ().Workflows (wf .Namespace ).Patch (ctx , wfTwo .Name , types .MergePatchType , patch , metav1.PatchOptions {})
988988 require .NoError (t , err )
989989
990- // The pending workflow that's being shutdown should have succeeded and released the lock.
990+ // The pending workflow that's being shutdown should have failed and released the lock.
991991 wocTwo = newWorkflowOperationCtx (ctx , wfTwo , controller )
992992 wocTwo .operate (ctx )
993- assert .Equal (t , wfv1 .WorkflowSucceeded , wocTwo .execWf .Status .Phase )
993+ assert .Equal (t , wfv1 .WorkflowFailed , wocTwo .wf .Status .Phase )
994+ assert .Equal (t , "Stopped with strategy 'Terminate'" , wocTwo .wf .Status .Message )
994995 assert .Nil (t , wocTwo .wf .Status .Synchronization )
996+ // The workflow never ran, so no nodes should have been created for it.
997+ assert .Empty (t , wocTwo .wf .Status .Nodes )
998+
999+ // Release the lock from the first workflow.
1000+ woc .wf .Status .Phase = wfv1 .WorkflowSucceeded
1001+ woc .operate (ctx )
1002+ assert .Nil (t , woc .wf .Status .Synchronization )
1003+
1004+ // The terminated workflow must also have been removed from the lock's
1005+ // waiting queue, so a new workflow acquires the lock immediately.
1006+ wfThree := wf .DeepCopy ()
1007+ wfThree .Name = "three-terminating"
1008+ wfThree , err = controller .wfclientset .ArgoprojV1alpha1 ().Workflows (wf .Namespace ).Create (ctx , wfThree , metav1.CreateOptions {})
1009+ require .NoError (t , err )
1010+ wocThree := newWorkflowOperationCtx (ctx , wfThree , controller )
1011+ wocThree .operate (ctx )
1012+ assert .Equal (t , wfv1 .WorkflowRunning , wocThree .wf .Status .Phase )
1013+ require .NotNil (t , wocThree .wf .Status .Synchronization )
1014+ require .NotNil (t , wocThree .wf .Status .Synchronization .Mutex )
1015+ assert .Len (t , wocThree .wf .Status .Synchronization .Mutex .Holding , 1 )
9951016 })
9961017
9971018 t .Run ("PendingShuttingdownStoppingWf" , func (t * testing.T ) {
0 commit comments