Search in sources :

Example 6 with SystemPropertiesConfiguration

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

the class TestKafkaProducerManager method testRequestTimeoutSetFromDefault.

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

Example 7 with SystemPropertiesConfiguration

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

the class TestKafkaPublishTask method kafkaPublishSuccess_Completed.

@Test
public void kafkaPublishSuccess_Completed() throws ExecutionException, InterruptedException {
    Task task = getTask();
    KafkaProducerManager producerManager = Mockito.mock(KafkaProducerManager.class);
    KafkaPublishTask kPublishTask = new KafkaPublishTask(new SystemPropertiesConfiguration(), producerManager, objectMapper);
    Producer producer = Mockito.mock(Producer.class);
    Mockito.when(producerManager.getProducer(Mockito.any())).thenReturn(producer);
    Mockito.when(producer.send(Mockito.any())).thenReturn(Mockito.mock(Future.class));
    kPublishTask.start(Mockito.mock(Workflow.class), task, Mockito.mock(WorkflowExecutor.class));
    Assert.assertEquals(Task.Status.COMPLETED, task.getStatus());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) Producer(org.apache.kafka.clients.producer.Producer) Future(java.util.concurrent.Future) Workflow(com.netflix.conductor.common.run.Workflow) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) WorkflowExecutor(com.netflix.conductor.core.execution.WorkflowExecutor) Test(org.junit.Test)

Example 8 with SystemPropertiesConfiguration

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

the class TestKafkaPublishTask method integerSerializer_integerObject.

@Test
public void integerSerializer_integerObject() {
    KafkaPublishTask kPublishTask = new KafkaPublishTask(new SystemPropertiesConfiguration(), new KafkaProducerManager(new SystemPropertiesConfiguration()), objectMapper);
    KafkaPublishTask.Input input = new KafkaPublishTask.Input();
    input.setKeySerializer(IntegerSerializer.class.getCanonicalName());
    input.setKey(String.valueOf(Integer.MAX_VALUE));
    Assert.assertEquals(kPublishTask.getKey(input), new Integer(Integer.MAX_VALUE));
}
Also used : SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) IntegerSerializer(org.apache.kafka.common.serialization.IntegerSerializer) Test(org.junit.Test)

Example 9 with SystemPropertiesConfiguration

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

the class TestKafkaPublishTask method kafkaPublishSuccess_AsyncComplete.

@Test
public void kafkaPublishSuccess_AsyncComplete() {
    Task task = getTask();
    task.getInputData().put("asyncComplete", true);
    KafkaProducerManager producerManager = Mockito.mock(KafkaProducerManager.class);
    KafkaPublishTask kPublishTask = new KafkaPublishTask(new SystemPropertiesConfiguration(), producerManager, objectMapper);
    Producer producer = Mockito.mock(Producer.class);
    Mockito.when(producerManager.getProducer(Mockito.any())).thenReturn(producer);
    Mockito.when(producer.send(Mockito.any())).thenReturn(Mockito.mock(Future.class));
    kPublishTask.start(Mockito.mock(Workflow.class), task, Mockito.mock(WorkflowExecutor.class));
    Assert.assertEquals(Task.Status.IN_PROGRESS, task.getStatus());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) Producer(org.apache.kafka.clients.producer.Producer) Future(java.util.concurrent.Future) Workflow(com.netflix.conductor.common.run.Workflow) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) WorkflowExecutor(com.netflix.conductor.core.execution.WorkflowExecutor) Test(org.junit.Test)

Example 10 with SystemPropertiesConfiguration

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

the class TestKafkaPublishTask method missingBootStrapServers_Fail.

@Test
public void missingBootStrapServers_Fail() {
    Task task = new Task();
    KafkaPublishTask.Input input = new KafkaPublishTask.Input();
    Map<String, Object> value = new HashMap<>();
    input.setValue(value);
    input.setTopic("testTopic");
    task.getInputData().put(KafkaPublishTask.REQUEST_PARAMETER_NAME, input);
    KafkaPublishTask kPublishTask = new KafkaPublishTask(new SystemPropertiesConfiguration(), new KafkaProducerManager(new SystemPropertiesConfiguration()), objectMapper);
    kPublishTask.start(Mockito.mock(Workflow.class), task, Mockito.mock(WorkflowExecutor.class));
    Assert.assertEquals(Task.Status.FAILED, task.getStatus());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) HashMap(java.util.HashMap) Workflow(com.netflix.conductor.common.run.Workflow) SystemPropertiesConfiguration(com.netflix.conductor.core.config.SystemPropertiesConfiguration) WorkflowExecutor(com.netflix.conductor.core.execution.WorkflowExecutor) 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