Search in sources :

Example 16 with SystemPropertiesConfiguration

use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.

the class TestSystemTaskExecutor method testMultipleQueuesExecution.

@Test
public void testMultipleQueuesExecution() {
    System.setProperty("workflow.system.task.worker.thread.count", "1");
    System.setProperty("workflow.isolated.system.task.worker.thread.count", "1");
    String sysTask = "taskId";
    String isolatedTask = "isolatedTaskId";
    Configuration configuration = new SystemPropertiesConfiguration();
    when(queueDAO.pop(TEST_TASK, 1, 200)).thenReturn(Collections.singletonList(sysTask));
    when(queueDAO.pop(ISOLATED_TASK, 1, 200)).thenReturn(Collections.singletonList(isolatedTask));
    systemTaskExecutor = new SystemTaskExecutor(queueDAO, workflowExecutor, configuration, executionService);
    CountDownLatch sysTaskLatch = new CountDownLatch(1);
    CountDownLatch isolatedTaskLatch = new CountDownLatch(1);
    doAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        String taskId = args[1].toString();
        if (taskId.equals(sysTask)) {
            sysTaskLatch.countDown();
        }
        if (taskId.equals(isolatedTask)) {
            isolatedTaskLatch.countDown();
        }
        return null;
    }).when(workflowExecutor).executeSystemTask(any(), anyString(), anyInt());
    scheduledExecutorService.scheduleAtFixedRate(() -> systemTaskExecutor.pollAndExecute(TEST_TASK), 0, 1, TimeUnit.SECONDS);
    ScheduledExecutorService isoTaskService = Executors.newSingleThreadScheduledExecutor();
    isoTaskService.scheduleAtFixedRate(() -> systemTaskExecutor.pollAndExecute(ISOLATED_TASK), 0, 1, TimeUnit.SECONDS);
    Uninterruptibles.awaitUninterruptibly(sysTaskLatch);
    Uninterruptibles.awaitUninterruptibly(isolatedTaskLatch);
    shutdownExecutorService(isoTaskService);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Configuration(com.netflix.conductor.core.config.Configuration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 17 with SystemPropertiesConfiguration

use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.

the class TestSystemTaskExecutor method testPollAndExecuteSystemTask.

@Test
public void testPollAndExecuteSystemTask() {
    System.setProperty("workflow.system.task.worker.thread.count", "1");
    Configuration configuration = new SystemPropertiesConfiguration();
    when(queueDAO.pop(anyString(), anyInt(), anyInt())).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 18 with SystemPropertiesConfiguration

use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.

the class TestSystemTaskWorkerCoordinator method testIsFromCoordinatorExecutionNameSpace.

@Test
public void testIsFromCoordinatorExecutionNameSpace() {
    System.setProperty("workflow.system.task.worker.executionNameSpace", "exeNS");
    Configuration configuration = new SystemPropertiesConfiguration();
    SystemTaskWorkerCoordinator systemTaskWorkerCoordinator = new SystemTaskWorkerCoordinator(queueDAO, workflowExecutor, configuration, executionService);
    assertTrue(systemTaskWorkerCoordinator.isFromCoordinatorExecutionNameSpace(TEST_QUEUE + EXECUTION_NAMESPACE_CONSTANT));
}
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 19 with SystemPropertiesConfiguration

use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.

the class TestKafkaProducerManager method testRequestTimeoutSetFromInput.

@Test
public void testRequestTimeoutSetFromInput() {
    KafkaProducerManager manager = new KafkaProducerManager(new SystemPropertiesConfiguration());
    KafkaPublishTask.Input input = getInput();
    input.setRequestTimeoutMs(200);
    Properties props = manager.getProducerProperties(input);
    Assert.assertEquals(props.getProperty(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG), "200");
}
Also used : SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) Properties(java.util.Properties) Test(org.junit.Test)

Example 20 with SystemPropertiesConfiguration

use of com.netflix.conductor.core.config.SystemPropertiesConfiguration in project conductor by Netflix.

the class TestKafkaPublishTask method longSerializer_longObject.

@Test
public void longSerializer_longObject() {
    KafkaPublishTask kPublishTask = new KafkaPublishTask(new SystemPropertiesConfiguration(), new KafkaProducerManager(new SystemPropertiesConfiguration()), objectMapper);
    KafkaPublishTask.Input input = new KafkaPublishTask.Input();
    input.setKeySerializer(LongSerializer.class.getCanonicalName());
    input.setKey(String.valueOf(Long.MAX_VALUE));
    Assert.assertEquals(kPublishTask.getKey(input), new Long(Long.MAX_VALUE));
}
Also used : LongSerializer(org.apache.kafka.common.serialization.LongSerializer) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) 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