Source:
<code>public void testDeleteRunningWorkflowForcefully() throws Exception { String workflowName = TestHelper.getTestMethodName(); Workflow.Builder builder = new Workflow.Builder(workflowName); JobConfig.Builder jobBuilder0 = JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG) .setMaxAttemptsPerTask(1).setWorkflow(workflowName) .setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "100000")); JobConfig.Builder jobBuilder1 = JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG) .setMaxAttemptsPerTask(1).setWorkflow(workflowName) .setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "100000")); JobConfig.Builder jobBuilder2 = JobConfig.Builder.fromMap(WorkflowGenerator.DEFAULT_JOB_CONFIG) .setMaxAttemptsPerTask(1).setWorkflow(workflowName) .setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "100000")); builder.addParentChildDependency("JOB0", "JOB1"); builder.addParentChildDependency("JOB0", "JOB2"); builder.addJob("JOB0", jobBuilder0); builder.addJob("JOB1", jobBuilder1); builder.addJob("JOB2", jobBuilder2); _driver.start(builder.build()); boolean isWorkflowRunning = TestHelper.verify(() -> { WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName); return (wCtx1 != null && wCtx1.getWorkflowState() == TaskState.IN_PROGRESS); }, 60 * 1000); Assert.assertTrue(isWorkflowRunning); Assert.assertNotNull(_driver.getWorkflowConfig(workflowName)); Assert.assertNotNull(_driver.getWorkflowContext(workflowName)); Assert.assertNotNull(admin.getResourceIdealState(CLUSTER_NAME, workflowName)); admin.enableCluster(CLUSTER_NAME, false); Thread.sleep(Disable_Delay); <START> _driver.delete(workflowName, true); <END> Thread.sleep(DELETE_DELAY); admin.enableCluster(CLUSTER_NAME, true); Assert.assertNull(_driver.getWorkflowConfig(workflowName)); Assert.assertNull(_driver.getWorkflowContext(workflowName)); Assert.assertNull(admin.getResourceIdealState(CLUSTER_NAME, workflowName)); }</code><technical_language>do ensure workflow is in progress time of deletion</technical_language>

Target:
public void testDeleteRunningWorkflowForcefully() throws Exception { 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, "0"); _driver.start(builder.build()); _driver.pollForWorkflowState(workflowName, TaskState.IN_PROGRESS); _driver.pollForJobState(workflowName, TaskUtil.getNamespacedJobName(workflowName, "JOB0"), TaskState.IN_PROGRESS); 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); }