Source:
<code>public void testJobQueueAutoCleanUp() throws Exception { int capacity = 10; String queueName = TestHelper.getTestMethodName(); JobQueue.Builder builder = TaskTestUtil.buildJobQueue(queueName, capacity); WorkflowConfig.Builder cfgBuilder = new WorkflowConfig.Builder(builder.getWorkflowConfig()); cfgBuilder.setJobPurgeInterval(1000); builder.setWorkflowConfig(cfgBuilder.build()); JobConfig.Builder jobBuilder = new JobConfig.Builder().setTargetResource(WorkflowGenerator.DEFAULT_TGT_DB) .setCommand(MockTask.TASK_COMMAND).setMaxAttemptsPerTask(2).setJobCommandConfigMap( ImmutableMap.of(MockTask.SUCCESS_COUNT_BEFORE_FAIL, String.valueOf(capacity / 2))) .setExpiry(200L); Set<String> deletedJobs = new HashSet<String>(); Set<String> remainJobs = new HashSet<String>(); for (int i = 0; i < capacity; i++) { builder.enqueueJob("JOB" + i, jobBuilder); if (i < capacity/2) { deletedJobs.add("JOB" + i); } else { remainJobs.add(TaskUtil.getNamespacedJobName(queueName, "JOB" + i)); } } _driver.start(builder.build()); _driver.pollForJobState(queueName, TaskUtil.getNamespacedJobName(queueName, "JOB" + (capacity - 1)), TaskState.FAILED); Assert .assertTrue(TestHelper.verify(() -> { WorkflowConfig config = _driver.getWorkflowConfig(queueName); System.out.println("|Current time: " + System.currentTimeMillis() +" **TEST: " + config.getJobDag().getAllNodes()); return config.getJobDag().getAllNodes().equals(remainJobs); <START> }, 10000)); <END> Assert.assertTrue(TestHelper.verify(() -> { WorkflowContext context = _driver.getWorkflowContext(queueName); return context.getJobStates().keySet().equals(remainJobs) && remainJobs .containsAll(context.getJobStartTimes().keySet()); }, 10000)); for (String job : deletedJobs) { JobConfig cfg = _driver.getJobConfig(job); JobContext ctx = _driver.getJobContext(job); Assert.assertNull(cfg); Assert.assertNull(ctx); } }</code><technical_language>change this TestHeper.WAIT_DURATION</technical_language>

Target:
public void testJobQueueAutoCleanUp() throws Exception { int capacity = 10; String queueName = TestHelper.getTestMethodName(); JobQueue.Builder builder = TaskTestUtil.buildJobQueue(queueName, capacity); WorkflowConfig.Builder cfgBuilder = new WorkflowConfig.Builder(builder.getWorkflowConfig()); cfgBuilder.setJobPurgeInterval(1000); builder.setWorkflowConfig(cfgBuilder.build()); JobConfig.Builder jobBuilder = new JobConfig.Builder().setTargetResource(WorkflowGenerator.DEFAULT_TGT_DB) .setCommand(MockTask.TASK_COMMAND).setMaxAttemptsPerTask(2).setJobCommandConfigMap( ImmutableMap.of(MockTask.SUCCESS_COUNT_BEFORE_FAIL, String.valueOf(capacity / 2))) .setExpiry(200L); Set<String> deletedJobs = new HashSet<String>(); Set<String> remainJobs = new HashSet<String>(); for (int i = 0; i < capacity; i++) { builder.enqueueJob("JOB" + i, jobBuilder); if (i < capacity/2) { deletedJobs.add("JOB" + i); } else { remainJobs.add(TaskUtil.getNamespacedJobName(queueName, "JOB" + i)); } } _driver.start(builder.build()); _driver.pollForJobState(queueName, TaskUtil.getNamespacedJobName(queueName, "JOB" + (capacity - 1)), TaskState.FAILED); Assert .assertTrue(TestHelper.verify(() -> { WorkflowConfig config = _driver.getWorkflowConfig(queueName); System.out.println("|Current time: " + System.currentTimeMillis() +" **TEST: " + config.getJobDag().getAllNodes()); return config.getJobDag().getAllNodes().equals(remainJobs); }, TestHelper.WAIT_DURATION)); Assert.assertTrue(TestHelper.verify(() -> { WorkflowContext context = _driver.getWorkflowContext(queueName); return context.getJobStates().keySet().equals(remainJobs) && remainJobs .containsAll(context.getJobStartTimes().keySet()); }, TestHelper.WAIT_DURATION)); for (String job : deletedJobs) { JobConfig cfg = _driver.getJobConfig(job); JobContext ctx = _driver.getJobContext(job); Assert.assertNull(cfg); Assert.assertNull(ctx); } }