use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class WorkflowClientTest method testSearch.
@Test
public void testSearch() {
ClientResponse clientResponse = mock(ClientResponse.class);
SearchResult<WorkflowSummary> workflowSearchResult = new SearchResult<>();
workflowSearchResult.setTotalHits(1);
WorkflowSummary workflowSummary = new WorkflowSummary(new Workflow());
workflowSearchResult.setResults(Collections.singletonList(workflowSummary));
when(clientResponse.getEntity(argThat((GenericType<SearchResult<WorkflowSummary>> type) -> ((ParameterizedTypeImpl) type.getType()).getRawType().equals(SearchResult.class) && ((ParameterizedTypeImpl) type.getType()).getActualTypeArguments()[0].equals(WorkflowSummary.class)))).thenReturn(workflowSearchResult);
when(clientHandler.handle(argThat(argument -> argument.getURI().equals(URI.create("http://myuri:8080/workflow/search?query=my_complex_query"))))).thenReturn(clientResponse);
SearchResult<WorkflowSummary> searchResult = workflowClient.search("my_complex_query");
assertEquals(1, searchResult.getTotalHits());
assertEquals(Collections.singletonList(workflowSummary), searchResult.getResults());
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class WorkflowServiceImplTest method searchTest.
@Test
public void searchTest() throws InterruptedException {
CountDownLatch streamAlive = new CountDownLatch(1);
AtomicReference<WorkflowServicePb.WorkflowSummarySearchResult> result = new AtomicReference<>();
SearchPb.Request req = SearchPb.Request.newBuilder().setStart(1).setSize(1).setSort("strings").setQuery("").setFreeText("").build();
StreamObserver<WorkflowServicePb.WorkflowSummarySearchResult> streamObserver = new StreamObserver<WorkflowServicePb.WorkflowSummarySearchResult>() {
@Override
public void onNext(WorkflowServicePb.WorkflowSummarySearchResult value) {
result.set(value);
}
@Override
public void onError(Throwable t) {
streamAlive.countDown();
}
@Override
public void onCompleted() {
streamAlive.countDown();
}
};
WorkflowSummary workflow = new WorkflowSummary();
SearchResult<WorkflowSummary> searchResult = new SearchResult<>();
searchResult.setTotalHits(1);
searchResult.setResults(Collections.singletonList(workflow));
when(workflowService.searchWorkflows(anyInt(), anyInt(), anyList(), anyString(), anyString())).thenReturn(searchResult);
workflowServiceImpl.search(req, streamObserver);
streamAlive.await(10, TimeUnit.MILLISECONDS);
WorkflowServicePb.WorkflowSummarySearchResult workflowSearchResult = result.get();
assertEquals(1, workflowSearchResult.getTotalHits());
assertEquals(WorkflowSummaryPb.WorkflowSummary.newBuilder().build(), workflowSearchResult.getResultsList().get(0));
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class TestElasticSearchRestDAOV7 method shouldAsyncUpdateWorkflow.
@Test
public void shouldAsyncUpdateWorkflow() throws Exception {
Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
WorkflowSummary summary = new WorkflowSummary(workflow);
indexDAO.indexWorkflow(workflow);
indexDAO.asyncUpdateWorkflow(workflow.getWorkflowId(), new String[] { "status" }, new Object[] { Workflow.WorkflowStatus.FAILED }).get();
summary.setStatus(Workflow.WorkflowStatus.FAILED);
assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class TestElasticSearchRestDAOV7 method shouldIndexWorkflow.
@Test
public void shouldIndexWorkflow() {
Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
WorkflowSummary summary = new WorkflowSummary(workflow);
indexDAO.indexWorkflow(workflow);
assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class ElasticSearchRestDAOV5 method indexWorkflow.
@Override
public void indexWorkflow(Workflow workflow) {
try {
long startTime = Instant.now().toEpochMilli();
String workflowId = workflow.getWorkflowId();
WorkflowSummary summary = new WorkflowSummary(workflow);
byte[] docBytes = objectMapper.writeValueAsBytes(summary);
IndexRequest request = new IndexRequest(indexName, WORKFLOW_DOC_TYPE, workflowId);
request.source(docBytes, XContentType.JSON);
new RetryUtil<IndexResponse>().retryOnException(() -> {
try {
return elasticSearchClient.index(request);
} catch (IOException e) {
throw new RuntimeException(e);
}
}, null, null, RETRY_COUNT, "Indexing workflow document: " + workflow.getWorkflowId(), "indexWorkflow");
long endTime = Instant.now().toEpochMilli();
logger.debug("Time taken {} for indexing workflow: {}", endTime - startTime, workflowId);
Monitors.recordESIndexTime("index_workflow", WORKFLOW_DOC_TYPE, endTime - startTime);
Monitors.recordWorkerQueueSize("indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size());
} catch (Exception e) {
Monitors.error(className, "indexWorkflow");
logger.error("Failed to index workflow: {}", workflow.getWorkflowId(), e);
}
}
Aggregations