use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class TestSimpleEventProcessor method testExecuteNonRetriableApplicationException.
@Test
public void testExecuteNonRetriableApplicationException() {
AtomicInteger executeInvoked = new AtomicInteger(0);
doAnswer((Answer<Map<String, Object>>) invocation -> {
executeInvoked.incrementAndGet();
throw new ApplicationException(ApplicationException.Code.INVALID_INPUT, "some non-retriable error");
}).when(actionProcessor).execute(any(), any(), any(), any());
SimpleEventProcessor eventProcessor = new SimpleEventProcessor(executionService, metadataService, actionProcessor, eventQueues, jsonUtils, new TestConfiguration(), objectMapper);
EventExecution eventExecution = new EventExecution("id", "messageId");
eventExecution.setStatus(EventExecution.Status.IN_PROGRESS);
eventExecution.setEvent("event");
eventExecution.setName("handler");
Action action = new Action();
action.setAction(Type.start_workflow);
eventExecution.setAction(Type.start_workflow);
eventProcessor.execute(eventExecution, action, "payload");
assertEquals(1, executeInvoked.get());
assertEquals(EventExecution.Status.FAILED, eventExecution.getStatus());
assertNotNull(eventExecution.getOutput().get("exception"));
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class TestElasticSearchDAOV5 method addEventExecution.
@Test
public void addEventExecution() {
String messageId = "some-message-id";
EventExecution eventExecution = new EventExecution();
eventExecution.setId("some-id");
eventExecution.setMessageId(messageId);
eventExecution.setAction(Type.complete_task);
eventExecution.setEvent("some-event");
eventExecution.setStatus(EventExecution.Status.COMPLETED);
indexDAO.addEventExecution(eventExecution);
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
SearchResponse searchResponse = search(LOG_INDEX_PREFIX + "*", "messageId='" + messageId + "'", 0, 10000, "*", EVENT_DOC_TYPE);
assertEquals("search results should be length 1", searchResponse.getHits().getTotalHits(), 1);
SearchHit searchHit = searchResponse.getHits().getAt(0);
GetResponse response = elasticSearchClient.prepareGet(searchHit.getIndex(), EVENT_DOC_TYPE, searchHit.getId()).get();
assertEquals("indexed message id should match", messageId, response.getSource().get("messageId"));
assertEquals("indexed id should match", "some-id", response.getSource().get("id"));
assertEquals("indexed status should match", EventExecution.Status.COMPLETED.name(), response.getSource().get("status"));
});
List<EventExecution> events = indexDAO.getEventExecutions("some-event");
assertEquals(1, events.size());
assertEquals(eventExecution, events.get(0));
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class ElasticSearchRestDAOV6 method mapEventExecutionsResponse.
private List<EventExecution> mapEventExecutionsResponse(SearchResponse response) throws IOException {
SearchHit[] hits = response.getHits().getHits();
List<EventExecution> executions = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
EventExecution tel = objectMapper.readValue(source, EventExecution.class);
executions.add(tel);
}
return executions;
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class TestElasticSearchRestDAOV6 method shouldAddEventExecution.
@Test
public void shouldAddEventExecution() {
String event = "event";
EventExecution execution1 = createEventExecution(event);
EventExecution execution2 = createEventExecution(event);
indexDAO.addEventExecution(execution1);
indexDAO.addEventExecution(execution2);
List<EventExecution> indexedExecutions = tryFindResults(() -> indexDAO.getEventExecutions(event), 2);
assertEquals(2, indexedExecutions.size());
assertTrue("Not all event executions was indexed", indexedExecutions.containsAll(Arrays.asList(execution1, execution2)));
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class TestElasticSearchDAOV6 method createEventExecution.
private EventExecution createEventExecution(String event) {
EventExecution execution = new EventExecution(uuid(), uuid());
execution.setName("name");
execution.setEvent(event);
execution.setCreated(System.currentTimeMillis());
execution.setStatus(EventExecution.Status.COMPLETED);
execution.setAction(EventHandler.Action.Type.start_workflow);
execution.setOutput(ImmutableMap.of("a", 1, "b", 2, "c", 3));
return execution;
}
Aggregations