Search in sources :

Example 96 with Workflow

use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.

the class TestElasticSearchRestDAOV6 method shouldIndexWorkflow.

@Test
public void shouldIndexWorkflow() {
    Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
    WorkflowSummary summary = new WorkflowSummary(workflow);
    indexDAO.indexWorkflow(workflow);
    assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 97 with Workflow

use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.

the class TestElasticSearchRestDAOV6 method shouldIndexTaskAsync.

@Test
public void shouldIndexTaskAsync() throws Exception {
    Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
    Task task = workflow.getTasks().get(0);
    TaskSummary summary = new TaskSummary(task);
    indexDAO.asyncIndexTask(task).get();
    List<String> tasks = tryFindResults(() -> searchTasks(workflow));
    assertEquals(summary.getTaskId(), tasks.get(0));
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) TaskSummary(com.netflix.conductor.common.run.TaskSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 98 with Workflow

use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.

the class TestElasticSearchDAOV6 method shouldAsyncRemoveWorkflow.

@Test
public void shouldAsyncRemoveWorkflow() throws Exception {
    Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
    indexDAO.indexWorkflow(workflow);
    // wait for workflow to be indexed
    List<String> workflows = tryFindResults(() -> searchWorkflows(workflow.getWorkflowId()), 1);
    assertEquals(1, workflows.size());
    indexDAO.asyncRemoveWorkflow(workflow.getWorkflowId()).get();
    workflows = tryFindResults(() -> searchWorkflows(workflow.getWorkflowId()), 0);
    assertTrue("Workflow was not removed.", workflows.isEmpty());
}
Also used : Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 99 with Workflow

use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.

the class TestElasticSearchDAOV6 method shouldSearchRecentRunningWorkflows.

@Test
public void shouldSearchRecentRunningWorkflows() throws Exception {
    Workflow oldWorkflow = TestUtils.loadWorkflowSnapshot("workflow");
    oldWorkflow.setStatus(Workflow.WorkflowStatus.RUNNING);
    oldWorkflow.setUpdateTime(new DateTime().minusHours(2).toDate().getTime());
    Workflow recentWorkflow = TestUtils.loadWorkflowSnapshot("workflow");
    recentWorkflow.setStatus(Workflow.WorkflowStatus.RUNNING);
    recentWorkflow.setUpdateTime(new DateTime().minusHours(1).toDate().getTime());
    Workflow tooRecentWorkflow = TestUtils.loadWorkflowSnapshot("workflow");
    tooRecentWorkflow.setStatus(Workflow.WorkflowStatus.RUNNING);
    tooRecentWorkflow.setUpdateTime(new DateTime().toDate().getTime());
    indexDAO.indexWorkflow(oldWorkflow);
    indexDAO.indexWorkflow(recentWorkflow);
    indexDAO.indexWorkflow(tooRecentWorkflow);
    Thread.sleep(1000);
    List<String> ids = indexDAO.searchRecentRunningWorkflows(2, 1);
    assertEquals(1, ids.size());
    assertEquals(recentWorkflow.getWorkflowId(), ids.get(0));
}
Also used : Workflow(com.netflix.conductor.common.run.Workflow) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 100 with Workflow

use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.

the class TestElasticSearchDAOV6 method shouldRemoveWorkflow.

@Test
public void shouldRemoveWorkflow() {
    Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
    indexDAO.indexWorkflow(workflow);
    // wait for workflow to be indexed
    List<String> workflows = tryFindResults(() -> searchWorkflows(workflow.getWorkflowId()), 1);
    assertEquals(1, workflows.size());
    indexDAO.removeWorkflow(workflow.getWorkflowId());
    workflows = tryFindResults(() -> searchWorkflows(workflow.getWorkflowId()), 0);
    assertTrue("Workflow was not removed.", workflows.isEmpty());
}
Also used : Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Aggregations

Workflow (com.netflix.conductor.common.run.Workflow)360 Test (org.junit.Test)259 Task (com.netflix.conductor.common.metadata.tasks.Task)246 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)206 HashMap (java.util.HashMap)154 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)149 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)130 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)97 UserTask (com.netflix.conductor.tests.utils.UserTask)73 LinkedList (java.util.LinkedList)57 Map (java.util.Map)55 List (java.util.List)54 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)52 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)50 Collections (java.util.Collections)36 Collectors (java.util.stream.Collectors)35 Logger (org.slf4j.Logger)35 LoggerFactory (org.slf4j.LoggerFactory)35 TaskResult (com.netflix.conductor.common.metadata.tasks.TaskResult)34 WorkflowSystemTask (com.netflix.conductor.core.execution.tasks.WorkflowSystemTask)34