use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.
the class TestSystemTaskExecutor method testGetExecutionConfigForSystemTask.
@Test
public void testGetExecutionConfigForSystemTask() {
System.setProperty("workflow.system.task.worker.thread.count", "5");
Configuration configuration = new SystemPropertiesConfiguration();
systemTaskExecutor = new SystemTaskExecutor(queueDAO, workflowExecutor, configuration, executionService);
assertEquals(systemTaskExecutor.getExecutionConfig("").getSemaphoreUtil().availableSlots(), 5);
}
use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.
the class TestSystemTaskExecutor method testPollException.
@Test
public void testPollException() {
System.setProperty("workflow.system.task.worker.thread.count", "1");
Configuration configuration = new SystemPropertiesConfiguration();
when(queueDAO.pop(anyString(), anyInt(), anyInt())).thenThrow(RuntimeException.class).thenReturn(Collections.singletonList("taskId"));
systemTaskExecutor = new SystemTaskExecutor(queueDAO, workflowExecutor, configuration, executionService);
CountDownLatch latch = new CountDownLatch(1);
doAnswer(invocation -> {
latch.countDown();
return null;
}).when(workflowExecutor).executeSystemTask(any(), anyString(), anyInt());
scheduledExecutorService.scheduleAtFixedRate(() -> systemTaskExecutor.pollAndExecute(TEST_TASK), 0, 1, TimeUnit.SECONDS);
Uninterruptibles.awaitUninterruptibly(latch);
verify(workflowExecutor).executeSystemTask(any(), anyString(), anyInt());
}
use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.
the class TestSystemTaskExecutor method testBatchPollException.
@Test
public void testBatchPollException() {
try {
System.setProperty("workflow.system.task.queue.pollCount", "2");
System.setProperty("workflow.system.task.worker.thread.count", "2");
Configuration configuration = new SystemPropertiesConfiguration();
when(queueDAO.pop(anyString(), anyInt(), anyInt())).thenThrow(RuntimeException.class).thenReturn(Collections.nCopies(2, "taskId"));
systemTaskExecutor = new SystemTaskExecutor(queueDAO, workflowExecutor, configuration, executionService);
CountDownLatch latch = new CountDownLatch(2);
doAnswer(invocation -> {
latch.countDown();
return null;
}).when(workflowExecutor).executeSystemTask(any(), anyString(), anyInt());
scheduledExecutorService.scheduleAtFixedRate(() -> systemTaskExecutor.pollAndExecute(TEST_TASK), 0, 1, TimeUnit.SECONDS);
Uninterruptibles.awaitUninterruptibly(latch);
verify(workflowExecutor, Mockito.times(2)).executeSystemTask(any(), anyString(), anyInt());
} finally {
// Revert the batch poll settings
System.setProperty("workflow.system.task.queue.pollCount", "1");
}
}
use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.
the class TestSystemTaskExecutor method testPollAndExecuteIsolatedSystemTask.
@Test
public void testPollAndExecuteIsolatedSystemTask() {
System.setProperty("workflow.isolated.system.task.worker.thread.count", "1");
Configuration configuration = new SystemPropertiesConfiguration();
when(queueDAO.pop(anyString(), anyInt(), anyInt())).thenReturn(Collections.singletonList("isolated_taskId"));
systemTaskExecutor = new SystemTaskExecutor(queueDAO, workflowExecutor, configuration, executionService);
CountDownLatch latch = new CountDownLatch(1);
doAnswer(invocation -> {
latch.countDown();
return null;
}).when(workflowExecutor).executeSystemTask(any(), anyString(), anyInt());
scheduledExecutorService.scheduleAtFixedRate(() -> systemTaskExecutor.pollAndExecute(ISOLATED_TASK), 0, 1, TimeUnit.SECONDS);
Uninterruptibles.awaitUninterruptibly(latch);
verify(workflowExecutor).executeSystemTask(any(), anyString(), anyInt());
}
use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.
the class TestSystemTaskExecutor method testBatchPollAndExecuteSystemTask.
@Test
public void testBatchPollAndExecuteSystemTask() {
try {
System.setProperty("workflow.system.task.worker.thread.count", "2");
System.setProperty("workflow.system.task.queue.pollCount", "2");
Configuration configuration = new SystemPropertiesConfiguration();
when(queueDAO.pop(anyString(), anyInt(), anyInt())).thenReturn(Collections.nCopies(2, "taskId"));
systemTaskExecutor = new SystemTaskExecutor(queueDAO, workflowExecutor, configuration, executionService);
CountDownLatch latch = new CountDownLatch(10);
doAnswer(invocation -> {
latch.countDown();
return null;
}).when(workflowExecutor).executeSystemTask(any(), anyString(), anyInt());
scheduledExecutorService.scheduleAtFixedRate(() -> systemTaskExecutor.pollAndExecute(TEST_TASK), 0, 1, TimeUnit.SECONDS);
Uninterruptibles.awaitUninterruptibly(latch);
verify(workflowExecutor, Mockito.times(10)).executeSystemTask(any(), anyString(), anyInt());
} finally {
// Revert the batch poll settings
System.setProperty("workflow.system.task.queue.pollCount", "1");
}
}
Aggregations