use of org.apache.nifi.util.MockFlowFile in project nifi by apache.
the class TestPutElasticsearch5 method testPutElasticSearchOnTriggerEL.
@Test
public void testPutElasticSearchOnTriggerEL() throws IOException {
// no failures
runner = TestRunners.newTestRunner(new PutElasticsearch5TestProcessor(false));
runner.setValidateExpressionUsage(true);
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.CLUSTER_NAME, "${cluster.name}");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.HOSTS, "${hosts}");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.PING_TIMEOUT, "${ping.timeout}");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.SAMPLER_INTERVAL, "${sampler.interval}");
runner.setProperty(PutElasticsearch5.INDEX, "doc");
runner.assertNotValid();
runner.setProperty(PutElasticsearch5.TYPE, "status");
runner.setProperty(PutElasticsearch5.BATCH_SIZE, "1");
runner.assertNotValid();
runner.setProperty(PutElasticsearch5.ID_ATTRIBUTE, "doc_id");
runner.assertValid();
runner.setVariable("cluster.name", "elasticsearch");
runner.setVariable("hosts", "127.0.0.1:9300");
runner.setVariable("ping.timeout", "5s");
runner.setVariable("sampler.interval", "5s");
runner.enqueue(docExample, new HashMap<String, String>() {
{
put("doc_id", "28039652140");
}
});
runner.run(1, true, true);
runner.assertAllFlowFilesTransferred(PutElasticsearch5.REL_SUCCESS, 1);
final MockFlowFile out = runner.getFlowFilesForRelationship(PutElasticsearch5.REL_SUCCESS).get(0);
assertNotNull(out);
out.assertAttributeEquals("doc_id", "28039652140");
}
use of org.apache.nifi.util.MockFlowFile in project nifi by apache.
the class TestPutElasticsearch5 method testPutElasticSearchOnTrigger.
@Test
public void testPutElasticSearchOnTrigger() throws IOException {
// no failures
runner = TestRunners.newTestRunner(new PutElasticsearch5TestProcessor(false));
runner.setValidateExpressionUsage(true);
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.CLUSTER_NAME, "elasticsearch");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.HOSTS, "127.0.0.1:9300");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.PING_TIMEOUT, "5s");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.SAMPLER_INTERVAL, "5s");
runner.setProperty(PutElasticsearch5.INDEX, "doc");
runner.assertNotValid();
runner.setProperty(PutElasticsearch5.TYPE, "status");
runner.setProperty(PutElasticsearch5.BATCH_SIZE, "1");
runner.assertNotValid();
runner.setProperty(PutElasticsearch5.ID_ATTRIBUTE, "doc_id");
runner.assertValid();
runner.enqueue(docExample, new HashMap<String, String>() {
{
put("doc_id", "28039652140");
}
});
runner.run(1, true, true);
runner.assertAllFlowFilesTransferred(PutElasticsearch5.REL_SUCCESS, 1);
final MockFlowFile out = runner.getFlowFilesForRelationship(PutElasticsearch5.REL_SUCCESS).get(0);
assertNotNull(out);
out.assertAttributeEquals("doc_id", "28039652140");
}
use of org.apache.nifi.util.MockFlowFile in project nifi by apache.
the class ITQueryElasticsearchHttp method testFetchElasticsearchOnTrigger.
@Test
public void testFetchElasticsearchOnTrigger() throws IOException {
// all docs are found
runner = TestRunners.newTestRunner(QueryElasticsearchHttp.class);
runner.setValidateExpressionUsage(true);
runner.setProperty(AbstractElasticsearchHttpProcessor.ES_URL, "http://localhost.internal:9200");
runner.setProperty(QueryElasticsearchHttp.INDEX, "prod-accounting");
runner.assertNotValid();
runner.setProperty(QueryElasticsearchHttp.TYPE, "provenance");
runner.assertNotValid();
runner.setProperty(QueryElasticsearchHttp.QUERY, "identifier:2f79eba8839f5976cd0b1e16a0e7fe8d7dd0ceca");
runner.setProperty(QueryElasticsearchHttp.SORT, "timestamp:asc");
runner.setProperty(QueryElasticsearchHttp.FIELDS, "transit_uri,version");
runner.setProperty(QueryElasticsearchHttp.PAGE_SIZE, "1");
runner.assertValid();
runner.setIncomingConnection(false);
runner.run(1, true, true);
runner.assertAllFlowFilesTransferred(QueryElasticsearchHttp.REL_SUCCESS, 3);
final MockFlowFile out = runner.getFlowFilesForRelationship(QueryElasticsearchHttp.REL_SUCCESS).get(0);
assertNotNull(out);
}
use of org.apache.nifi.util.MockFlowFile in project nifi by apache.
the class ITScrollElasticsearchHttp method testFetchElasticsearchOnTrigger.
@Test
public void testFetchElasticsearchOnTrigger() throws IOException {
// all docs are found
runner = TestRunners.newTestRunner(ScrollElasticsearchHttp.class);
runner.setValidateExpressionUsage(true);
runner.setProperty(AbstractElasticsearchHttpProcessor.ES_URL, "http://ip-172-31-49-152.ec2.internal:9200");
runner.setProperty(ScrollElasticsearchHttp.INDEX, "prod-accounting");
runner.assertNotValid();
runner.setProperty(ScrollElasticsearchHttp.TYPE, "provenance");
runner.assertNotValid();
runner.setProperty(ScrollElasticsearchHttp.QUERY, "identifier:2f79eba8839f5976cd0b1e16a0e7fe8d7dd0ceca");
runner.setProperty(ScrollElasticsearchHttp.SORT, "timestamp:asc");
runner.setProperty(ScrollElasticsearchHttp.FIELDS, "transit_uri,version");
runner.setProperty(ScrollElasticsearchHttp.PAGE_SIZE, "1");
runner.assertValid();
runner.setIncomingConnection(false);
runner.run(4, true, true);
runner.assertAllFlowFilesTransferred(ScrollElasticsearchHttp.REL_SUCCESS, 3);
final MockFlowFile out = runner.getFlowFilesForRelationship(ScrollElasticsearchHttp.REL_SUCCESS).get(0);
assertNotNull(out);
}
use of org.apache.nifi.util.MockFlowFile in project nifi by apache.
the class TestFetchElasticsearch method testFetchElasticsearchOnTriggerWithFailures.
@Test
public void testFetchElasticsearchOnTriggerWithFailures() throws IOException {
// simulate doc not found
runner = TestRunners.newTestRunner(new FetchElasticsearchTestProcessor(false));
runner.setProperty(AbstractElasticsearchTransportClientProcessor.CLUSTER_NAME, "elasticsearch");
runner.setProperty(AbstractElasticsearchTransportClientProcessor.HOSTS, "127.0.0.1:9300");
runner.setProperty(AbstractElasticsearchTransportClientProcessor.PING_TIMEOUT, "5s");
runner.setProperty(AbstractElasticsearchTransportClientProcessor.SAMPLER_INTERVAL, "5s");
runner.setProperty(FetchElasticsearch.INDEX, "doc");
runner.setProperty(FetchElasticsearch.TYPE, "status");
runner.setValidateExpressionUsage(true);
runner.setProperty(FetchElasticsearch.DOC_ID, "${doc_id}");
runner.enqueue(docExample, new HashMap<String, String>() {
{
put("doc_id", "28039652140");
}
});
runner.run(1, true, true);
// This test generates a "document not found"
runner.assertAllFlowFilesTransferred(FetchElasticsearch.REL_NOT_FOUND, 1);
final MockFlowFile out = runner.getFlowFilesForRelationship(FetchElasticsearch.REL_NOT_FOUND).get(0);
assertNotNull(out);
out.assertAttributeEquals("doc_id", "28039652140");
}
Aggregations