Search in sources :

Example 11 with PollData

use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.

the class TestWorkflowExecutor method testTaskToDomain.

@Test
public void testTaskToDomain() {
    Workflow workflow = generateSampleWorkflow();
    List<Task> tasks = generateSampleTasks(3);
    Map<String, String> taskToDomain = new HashMap<>();
    taskToDomain.put("*", "mydomain");
    workflow.setTaskToDomain(taskToDomain);
    PollData pollData1 = new PollData("queue1", "mydomain", "worker1", System.currentTimeMillis() - 99 * 100);
    when(executionDAOFacade.getTaskPollDataByDomain(anyString(), anyString())).thenReturn(pollData1);
    workflowExecutor.setTaskDomains(tasks, workflow);
    assertNotNull(tasks);
    tasks.forEach(task -> assertEquals("mydomain", task.getDomain()));
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowSystemTask(com.netflix.conductor.core.execution.tasks.WorkflowSystemTask) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) HashMap(java.util.HashMap) PollData(com.netflix.conductor.common.metadata.tasks.PollData) SubWorkflow(com.netflix.conductor.core.execution.tasks.SubWorkflow) Workflow(com.netflix.conductor.common.run.Workflow) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 12 with PollData

use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.

the class TestWorkflowExecutor method testInactiveDomains.

@Test
public void testInactiveDomains() {
    String taskType = "test-task";
    String[] domains = new String[] { "domain1", "domain2" };
    PollData pollData1 = new PollData("queue1", domains[0], "worker1", System.currentTimeMillis() - 99 * 10000);
    when(executionDAOFacade.getTaskPollDataByDomain(taskType, domains[0])).thenReturn(pollData1);
    when(executionDAOFacade.getTaskPollDataByDomain(taskType, domains[1])).thenReturn(null);
    String activeDomain = workflowExecutor.getActiveDomain(taskType, domains);
    assertEquals("domain2", activeDomain);
}
Also used : PollData(com.netflix.conductor.common.metadata.tasks.PollData) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 13 with PollData

use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.

the class TestWorkflowExecutor method testTaskToDomainsPerTask.

@Test
public void testTaskToDomainsPerTask() {
    Workflow workflow = generateSampleWorkflow();
    List<Task> tasks = generateSampleTasks(2);
    Map<String, String> taskToDomain = new HashMap<>();
    taskToDomain.put("*", "mydomain, NO_DOMAIN");
    workflow.setTaskToDomain(taskToDomain);
    PollData pollData1 = new PollData("queue1", "mydomain", "worker1", System.currentTimeMillis() - 99 * 100);
    when(executionDAOFacade.getTaskPollDataByDomain(eq("task1"), anyString())).thenReturn(pollData1);
    when(executionDAOFacade.getTaskPollDataByDomain(eq("task2"), anyString())).thenReturn(null);
    workflowExecutor.setTaskDomains(tasks, workflow);
    assertEquals("mydomain", tasks.get(0).getDomain());
    assertNull(tasks.get(1).getDomain());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowSystemTask(com.netflix.conductor.core.execution.tasks.WorkflowSystemTask) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) HashMap(java.util.HashMap) PollData(com.netflix.conductor.common.metadata.tasks.PollData) SubWorkflow(com.netflix.conductor.core.execution.tasks.SubWorkflow) Workflow(com.netflix.conductor.common.run.Workflow) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 14 with PollData

use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.

the class MySQLExecutionDAO method updateLastPollData.

@Override
public void updateLastPollData(String taskDefName, String domain, String workerId) {
    Preconditions.checkNotNull(taskDefName, "taskDefName name cannot be null");
    PollData pollData = new PollData(taskDefName, domain, workerId, System.currentTimeMillis());
    String effectiveDomain = (domain == null) ? "DEFAULT" : domain;
    withTransaction(tx -> insertOrUpdatePollData(tx, pollData, effectiveDomain));
}
Also used : PollData(com.netflix.conductor.common.metadata.tasks.PollData)

Example 15 with PollData

use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.

the class TaskResourceTest method testGetAllPollData.

@Test
public void testGetAllPollData() {
    PollData pollData = new PollData("queue", "test", "w123", 100);
    List<PollData> listOfPollData = new ArrayList<>();
    listOfPollData.add(pollData);
    when(mockTaskService.getAllPollData()).thenReturn(listOfPollData);
    assertEquals(listOfPollData, taskResource.getAllPollData());
}
Also used : PollData(com.netflix.conductor.common.metadata.tasks.PollData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

PollData (com.netflix.conductor.common.metadata.tasks.PollData)17 Test (org.junit.Test)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 Task (com.netflix.conductor.common.metadata.tasks.Task)4 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)4 Workflow (com.netflix.conductor.common.run.Workflow)4 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)4 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)3 WorkflowSystemTask (com.netflix.conductor.core.execution.tasks.WorkflowSystemTask)3 HashMap (java.util.HashMap)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 Status (com.netflix.conductor.common.metadata.tasks.Task.Status)1 COMPLETED (com.netflix.conductor.common.metadata.tasks.Task.Status.COMPLETED)1 COMPLETED_WITH_ERRORS (com.netflix.conductor.common.metadata.tasks.Task.Status.COMPLETED_WITH_ERRORS)1 FAILED (com.netflix.conductor.common.metadata.tasks.Task.Status.FAILED)1 IN_PROGRESS (com.netflix.conductor.common.metadata.tasks.Task.Status.IN_PROGRESS)1 SCHEDULED (com.netflix.conductor.common.metadata.tasks.Task.Status.SCHEDULED)1