Source:
<code>public void testDeleteStoppingStuckWorkflowForcefully() throws Exception { String workflowName = TestHelper.getTestMethodName(); <START> Workflow.Builder builder = createCustomWorkflow(workflowName, "10000", "1000000"); <END> _driver.start(builder.build()); boolean isWorkflowCreated = TestHelper.verify(() -> { WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName); return (wCtx1 != null); }, 60 * 1000); Assert.assertTrue(isWorkflowCreated); _driver.stop(workflowName); boolean isWorkflowStopped = TestHelper.verify(() -> { WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName); return ((wCtx1.getWorkflowState() == TaskState.STOPPED || wCtx1.getWorkflowState() == TaskState.STOPPING)); }, 60 * 1000); Assert.assertTrue(isWorkflowStopped); boolean isJobStopped = TestHelper.verify(() -> { WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName); return wCtx1.getJobState(TaskUtil.getNamespacedJobName(workflowName + "_JOB0"))==TaskState.STOPPED; }, 60 * 1000); Assert.assertFalse(isJobStopped); Assert.assertNotNull(_driver.getWorkflowConfig(workflowName)); Assert.assertNotNull(_driver.getWorkflowContext(workflowName)); Assert.assertNotNull(_admin.getResourceIdealState(CLUSTER_NAME, workflowName)); _controller.syncStop(); _driver.delete(workflowName, true); boolean isWorkflowDeleted = TestHelper.verify(() -> { WorkflowConfig wfcfg = _driver.getWorkflowConfig(workflowName); WorkflowContext wfctx = _driver.getWorkflowContext(workflowName); IdealState is = _admin.getResourceIdealState(CLUSTER_NAME, workflowName); return (wfcfg == null && wfctx == null && is == null); }, 60 * 1000); Assert.assertTrue(isWorkflowDeleted); String controllerName = CONTROLLER_PREFIX + "_2"; _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName); _controller.syncStart(); }</code><technical_language>Magic number</technical_language>

Target:
public void testDeleteStoppingStuckWorkflowForcefully() throws Exception { CANCEL_COUNT.set(0); STOP_COUNT.set(0); String controllerName = CONTROLLER_PREFIX + "_0"; _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName); _controller.syncStart(); String workflowName = TestHelper.getTestMethodName(); Workflow.Builder builder = createCustomWorkflow(workflowName, LONG_EXECUTION_TIME, STOP_DELAY); _driver.start(builder.build()); _driver.pollForWorkflowState(workflowName, TaskState.IN_PROGRESS); _driver.stop(workflowName); _driver.pollForWorkflowState(workflowName, TaskState.STOPPING); _driver.pollForJobState(workflowName, TaskUtil.getNamespacedJobName(workflowName, "JOB0"), TaskState.STOPPING); boolean haveAllCancelsCalled = TestHelper.verify(() -> { return CANCEL_COUNT.get() == _numNodes; }, 60 * 1000); Assert.assertTrue(haveAllCancelsCalled); Assert.assertEquals(STOP_COUNT.get(), 0); Assert.assertNotNull(_driver.getWorkflowConfig(workflowName)); Assert.assertNotNull(_driver.getWorkflowContext(workflowName)); Assert.assertNotNull(_admin.getResourceIdealState(CLUSTER_NAME, workflowName)); _controller.syncStop(); _driver.delete(workflowName, true); boolean isWorkflowDeleted = TestHelper.verify(() -> { WorkflowConfig wfcfg = _driver.getWorkflowConfig(workflowName); WorkflowContext wfctx = _driver.getWorkflowContext(workflowName); IdealState is = _admin.getResourceIdealState(CLUSTER_NAME, workflowName); return (wfcfg == null && wfctx == null && is == null); }, 60 * 1000); Assert.assertTrue(isWorkflowDeleted); }