@@ -723,10 +723,10 @@ public void testResumeBlocked() throws Exception {
723723 public void evaluate () throws Throwable {
724724 Jenkins jenkins = story .j .jenkins ;
725725 WorkflowRun run = createAndRunSleeperJob (story .j .jenkins , jobName , FlowDurabilityHint .MAX_SURVIVABILITY );
726+ run .getParent ().setResumeBlocked (true );
726727 FlowExecution exec = run .getExecution ();
727728 if (exec instanceof CpsFlowExecution ) {
728729 assert ((CpsFlowExecution ) exec ).getStorage ().isPersistedFully ();
729- ((CpsFlowExecution )exec ).setResumeBlocked (true );
730730 }
731731 logStart [0 ] = JenkinsRule .getLog (run );
732732 nodesOut .addAll (new DepthFirstScanner ().allNodes (run .getExecution ()));
@@ -744,6 +744,40 @@ public void evaluate() throws Throwable {
744744 });
745745 }
746746
747+ @ Test
748+ @ Issue ("JENKINS-49961" )
749+ public void testResumeBlockedAddedAfterRunStart () throws Exception {
750+ final String jobName = "survivesEverything" ;
751+ final String [] logStart = new String [1 ];
752+ final List <FlowNode > nodesOut = new ArrayList <FlowNode >();
753+
754+ story .addStepWithDirtyShutdown (new Statement () {
755+ @ Override
756+ public void evaluate () throws Throwable {
757+ Jenkins jenkins = story .j .jenkins ;
758+ WorkflowRun run = createAndRunSleeperJob (story .j .jenkins , jobName , FlowDurabilityHint .MAX_SURVIVABILITY );
759+ run .getParent ().setResumeBlocked (false );
760+ FlowExecution exec = run .getExecution ();
761+ if (exec instanceof CpsFlowExecution ) {
762+ assert ((CpsFlowExecution ) exec ).getStorage ().isPersistedFully ();
763+ }
764+ logStart [0 ] = JenkinsRule .getLog (run );
765+ nodesOut .addAll (new DepthFirstScanner ().allNodes (run .getExecution ()));
766+ nodesOut .sort (FlowScanningUtils .ID_ORDER_COMPARATOR );
767+ run .getParent ().setResumeBlocked (true );
768+ }
769+ });
770+
771+ story .addStep (new Statement () {
772+ @ Override
773+ public void evaluate () throws Throwable {
774+ WorkflowRun run = story .j .jenkins .getItemByFullName (jobName , WorkflowJob .class ).getLastBuild ();
775+ verifyFailedCleanly (story .j .jenkins , run );
776+ assertIncludesNodes (nodesOut , run );
777+ }
778+ });
779+ }
780+
747781 /** Test interrupting build by randomly dying at unpredictable times. */
748782 @ Test
749783 @ Ignore //Too long to run as part of main suite
0 commit comments