use of org.opensearch.ingest.IngestService in project OpenSearch by opensearch-project.
the class TransportBulkActionIngestTests method testIngestSkipped.
public void testIngestSkipped() throws Exception {
BulkRequest bulkRequest = new BulkRequest();
IndexRequest indexRequest = new IndexRequest("index").id("id");
indexRequest.source(emptyMap());
bulkRequest.add(indexRequest);
action.execute(null, bulkRequest, ActionListener.wrap(response -> {
}, exception -> {
throw new AssertionError(exception);
}));
assertTrue(action.isExecuted);
verifyNoInteractions(ingestService);
}
use of org.opensearch.ingest.IngestService in project OpenSearch by opensearch-project.
the class TransportBulkActionIngestTests method testNotFindDefaultPipelineFromTemplateMatches.
public void testNotFindDefaultPipelineFromTemplateMatches() {
Exception exception = new Exception("fake exception");
IndexRequest indexRequest = new IndexRequest("missing_index").id("id");
indexRequest.source(emptyMap());
AtomicBoolean responseCalled = new AtomicBoolean(false);
AtomicBoolean failureCalled = new AtomicBoolean(false);
singleItemBulkWriteAction.execute(null, indexRequest, ActionListener.wrap(response -> responseCalled.set(true), e -> {
assertThat(e, sameInstance(exception));
failureCalled.set(true);
}));
assertEquals(IngestService.NOOP_PIPELINE_NAME, indexRequest.getPipeline());
verifyNoInteractions(ingestService);
}
use of org.opensearch.ingest.IngestService in project OpenSearch by opensearch-project.
the class TransportBulkActionIngestTests method validateDefaultPipeline.
private void validateDefaultPipeline(IndexRequest indexRequest) {
Exception exception = new Exception("fake exception");
indexRequest.source(emptyMap());
AtomicBoolean responseCalled = new AtomicBoolean(false);
AtomicBoolean failureCalled = new AtomicBoolean(false);
assertNull(indexRequest.getPipeline());
singleItemBulkWriteAction.execute(null, indexRequest, ActionListener.wrap(response -> {
responseCalled.set(true);
}, e -> {
assertThat(e, sameInstance(exception));
failureCalled.set(true);
}));
// check failure works, and passes through to the listener
// haven't executed yet
assertFalse(action.isExecuted);
assertFalse(responseCalled.get());
assertFalse(failureCalled.get());
verify(ingestService).executeBulkRequest(eq(1), bulkDocsItr.capture(), failureHandler.capture(), completionHandler.capture(), any(), eq(Names.WRITE));
assertEquals(indexRequest.getPipeline(), "default_pipeline");
completionHandler.getValue().accept(null, exception);
assertTrue(failureCalled.get());
// now check success
// this is done by the real pipeline execution service when processing
indexRequest.setPipeline(IngestService.NOOP_PIPELINE_NAME);
completionHandler.getValue().accept(DUMMY_WRITE_THREAD, null);
assertTrue(action.isExecuted);
// listener would only be called by real index action, not our mocked one
assertFalse(responseCalled.get());
verifyNoInteractions(transportService);
}
use of org.opensearch.ingest.IngestService in project OpenSearch by opensearch-project.
the class SimulatePipelineRequestParsingTests method init.
@Before
public void init() throws IOException {
TestProcessor processor = new TestProcessor(ingestDocument -> {
});
CompoundProcessor pipelineCompoundProcessor = new CompoundProcessor(processor);
Pipeline pipeline = new Pipeline(SIMULATED_PIPELINE_ID, null, null, pipelineCompoundProcessor);
Map<String, Processor.Factory> registry = Collections.singletonMap("mock_processor", (factories, tag, description, config) -> processor);
ingestService = mock(IngestService.class);
when(ingestService.getPipeline(SIMULATED_PIPELINE_ID)).thenReturn(pipeline);
when(ingestService.getProcessorFactories()).thenReturn(registry);
}
Aggregations