Search in sources :

Example 1 with SystemPropertiesConfiguration

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);
}
Also used : Configuration(com.netflix.conductor.core.config.Configuration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) Test(org.junit.Test)

Example 2 with SystemPropertiesConfiguration

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());
}
Also used : Configuration(com.netflix.conductor.core.config.Configuration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 3 with SystemPropertiesConfiguration

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");
    }
}
Also used : Configuration(com.netflix.conductor.core.config.Configuration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 4 with SystemPropertiesConfiguration

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());
}
Also used : Configuration(com.netflix.conductor.core.config.Configuration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 5 with SystemPropertiesConfiguration

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");
    }
}
Also used : Configuration(com.netflix.conductor.core.config.Configuration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

SystemPropertiesConfiguration (com.netflix.conductor.core.config.SystemPropertiesConfiguration)22 Test (org.junit.Test)21 Configuration (com.netflix.conductor.core.config.Configuration)9 Task (com.netflix.conductor.common.metadata.tasks.Task)7 Workflow (com.netflix.conductor.common.run.Workflow)7 WorkflowExecutor (com.netflix.conductor.core.execution.WorkflowExecutor)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 Producer (org.apache.kafka.clients.producer.Producer)4 Future (java.util.concurrent.Future)3 Properties (java.util.Properties)2 ModulesProvider (com.netflix.conductor.bootstrap.ModulesProvider)1 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 IntegerSerializer (org.apache.kafka.common.serialization.IntegerSerializer)1 LongSerializer (org.apache.kafka.common.serialization.LongSerializer)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1