Search in sources :

Example 6 with SearchResult

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

the class WorkflowServiceTest method testSearchWorkflowsByTasksV2.

@Test
public void testSearchWorkflowsByTasksV2() {
    Workflow workflow = new Workflow();
    workflow.setCorrelationId("c123");
    List<Workflow> listOfWorkflow = Collections.singletonList(workflow);
    SearchResult<Workflow> searchResult = new SearchResult<>(1, listOfWorkflow);
    when(mockExecutionService.searchWorkflowByTasksV2("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflowsByTasksV2(0, 100, "asc", "*", "*"));
    when(mockExecutionService.searchWorkflowByTasksV2("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflowsByTasksV2(0, 100, Collections.singletonList("asc"), "*", "*"));
}
Also used : Workflow(com.netflix.conductor.common.run.Workflow) SearchResult(com.netflix.conductor.common.run.SearchResult) Test(org.junit.Test)

Example 7 with SearchResult

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

the class WorkflowServiceTest method testSearchWorkflows.

@Test
public void testSearchWorkflows() {
    Workflow workflow = new Workflow();
    workflow.setCorrelationId("c123");
    WorkflowSummary workflowSummary = new WorkflowSummary(workflow);
    List<WorkflowSummary> listOfWorkflowSummary = new ArrayList<WorkflowSummary>() {

        {
            add(workflowSummary);
        }
    };
    SearchResult<WorkflowSummary> searchResult = new SearchResult<WorkflowSummary>(100, listOfWorkflowSummary);
    when(mockExecutionService.search("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflows(0, 100, "asc", "*", "*"));
    when(mockExecutionService.search("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflows(0, 100, Collections.singletonList("asc"), "*", "*"));
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) Workflow(com.netflix.conductor.common.run.Workflow) SearchResult(com.netflix.conductor.common.run.SearchResult) Test(org.junit.Test)

Example 8 with SearchResult

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

the class WorkflowServiceTest method testSearchWorkflowsV2.

@Test
public void testSearchWorkflowsV2() {
    Workflow workflow = new Workflow();
    workflow.setCorrelationId("c123");
    List<Workflow> listOfWorkflow = Collections.singletonList(workflow);
    SearchResult<Workflow> searchResult = new SearchResult<>(1, listOfWorkflow);
    when(mockExecutionService.searchV2("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflowsV2(0, 100, "asc", "*", "*"));
    when(mockExecutionService.searchV2("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflowsV2(0, 100, Collections.singletonList("asc"), "*", "*"));
}
Also used : Workflow(com.netflix.conductor.common.run.Workflow) SearchResult(com.netflix.conductor.common.run.SearchResult) Test(org.junit.Test)

Example 9 with SearchResult

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

the class ExecutionService method searchWorkflowByTasks.

public SearchResult<WorkflowSummary> searchWorkflowByTasks(String query, String freeText, int start, int size, List<String> sortOptions) {
    SearchResult<TaskSummary> taskSummarySearchResult = searchTasks(query, freeText, start, size, sortOptions);
    List<WorkflowSummary> workflowSummaries = taskSummarySearchResult.getResults().stream().parallel().map(taskSummary -> {
        try {
            String workflowId = taskSummary.getWorkflowId();
            return new WorkflowSummary(executionDAOFacade.getWorkflowById(workflowId, false));
        } catch (Exception e) {
            logger.error("Error fetching workflow by id: {}", taskSummary.getWorkflowId(), e);
            return null;
        }
    }).filter(Objects::nonNull).distinct().collect(Collectors.toList());
    int missing = taskSummarySearchResult.getResults().size() - workflowSummaries.size();
    long totalHits = taskSummarySearchResult.getTotalHits() - missing;
    return new SearchResult<>(totalHits, workflowSummaries);
}
Also used : QueueUtils(com.netflix.conductor.core.utils.QueueUtils) Status(com.netflix.conductor.common.metadata.tasks.Task.Status) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) MetadataDAO(com.netflix.conductor.dao.MetadataDAO) Task(com.netflix.conductor.common.metadata.tasks.Task) Singleton(javax.inject.Singleton) ExecutionDAOFacade(com.netflix.conductor.core.orchestration.ExecutionDAOFacade) TaskResult(com.netflix.conductor.common.metadata.tasks.TaskResult) ServiceUtils(com.netflix.conductor.service.utils.ServiceUtils) ArrayList(java.util.ArrayList) WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) Inject(javax.inject.Inject) Workflow(com.netflix.conductor.common.run.Workflow) Map(java.util.Map) PollData(com.netflix.conductor.common.metadata.tasks.PollData) ExternalPayloadStorage(com.netflix.conductor.common.utils.ExternalPayloadStorage) Max(javax.validation.constraints.Max) Operation(com.netflix.conductor.common.utils.ExternalPayloadStorage.Operation) WorkflowExecutor(com.netflix.conductor.core.execution.WorkflowExecutor) EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) LinkedList(java.util.LinkedList) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) Message(com.netflix.conductor.core.events.queue.Message) SearchResult(com.netflix.conductor.common.run.SearchResult) Logger(org.slf4j.Logger) Trace(com.netflix.conductor.annotations.Trace) TaskExecLog(com.netflix.conductor.common.metadata.tasks.TaskExecLog) TaskSummary(com.netflix.conductor.common.run.TaskSummary) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) Collectors(java.util.stream.Collectors) Monitors(com.netflix.conductor.metrics.Monitors) ExternalStorageLocation(com.netflix.conductor.common.run.ExternalStorageLocation) Objects(java.util.Objects) QueueDAO(com.netflix.conductor.dao.QueueDAO) List(java.util.List) SystemTaskType(com.netflix.conductor.core.execution.SystemTaskType) Optional(java.util.Optional) Configuration(com.netflix.conductor.core.config.Configuration) Comparator(java.util.Comparator) PayloadType(com.netflix.conductor.common.utils.ExternalPayloadStorage.PayloadType) Collections(java.util.Collections) WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) TaskSummary(com.netflix.conductor.common.run.TaskSummary) Objects(java.util.Objects) SearchResult(com.netflix.conductor.common.run.SearchResult) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Example 10 with SearchResult

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

the class WorkflowServiceTest method testSearchWorkflowsByTasks.

@Test
public void testSearchWorkflowsByTasks() {
    Workflow workflow = new Workflow();
    workflow.setCorrelationId("c123");
    WorkflowSummary workflowSummary = new WorkflowSummary(workflow);
    List<WorkflowSummary> listOfWorkflowSummary = new ArrayList<WorkflowSummary>() {

        {
            add(workflowSummary);
        }
    };
    SearchResult<WorkflowSummary> searchResult = new SearchResult<>(100, listOfWorkflowSummary);
    when(mockExecutionService.searchWorkflowByTasks("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflowsByTasks(0, 100, "asc", "*", "*"));
    when(mockExecutionService.searchWorkflowByTasks("*", "*", 0, 100, Collections.singletonList("asc"))).thenReturn(searchResult);
    assertEquals(searchResult, workflowService.searchWorkflowsByTasks(0, 100, Collections.singletonList("asc"), "*", "*"));
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) Workflow(com.netflix.conductor.common.run.Workflow) SearchResult(com.netflix.conductor.common.run.SearchResult) Test(org.junit.Test)

Aggregations

SearchResult (com.netflix.conductor.common.run.SearchResult)19 Test (org.junit.Test)14 Workflow (com.netflix.conductor.common.run.Workflow)12 WorkflowSummary (com.netflix.conductor.common.run.WorkflowSummary)9 Collections (java.util.Collections)5 SearchPb (com.netflix.conductor.grpc.SearchPb)4 WorkflowServicePb (com.netflix.conductor.grpc.WorkflowServicePb)4 ClientHandler (com.sun.jersey.api.client.ClientHandler)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 GenericType (com.sun.jersey.api.client.GenericType)4 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)4 StreamObserver (io.grpc.stub.StreamObserver)4 URI (java.net.URI)4 LinkedList (java.util.LinkedList)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 TestCase.assertEquals (junit.framework.TestCase.assertEquals)4 SearchResponse (org.elasticsearch.action.search.SearchResponse)4 Before (org.junit.Before)4 RunWith (org.junit.runner.RunWith)4