use of org.apache.nifi.util.TestRunner in project nifi by apache.
the class TestSplitAvro method testRecordSplitDatafileOutputWithSplitSizeLarger.
@Test
public void testRecordSplitDatafileOutputWithSplitSizeLarger() throws IOException {
final TestRunner runner = TestRunners.newTestRunner(new SplitAvro());
runner.setProperty(SplitAvro.OUTPUT_SIZE, "200");
runner.enqueue(users.toByteArray());
runner.run();
runner.assertTransferCount(SplitAvro.REL_SPLIT, 1);
runner.assertTransferCount(SplitAvro.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitAvro.REL_FAILURE, 0);
runner.getFlowFilesForRelationship(SplitAvro.REL_ORIGINAL).get(0).assertAttributeEquals(FRAGMENT_COUNT.key(), "1");
final List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(SplitAvro.REL_SPLIT);
checkDataFileSplitSize(flowFiles, 100, true);
}
use of org.apache.nifi.util.TestRunner in project nifi by apache.
the class TestSplitAvro method testRecordSplitWithNoIncomingRecords.
@Test
public void testRecordSplitWithNoIncomingRecords() throws IOException {
final TestRunner runner = TestRunners.newTestRunner(new SplitAvro());
final ByteArrayOutputStream out = new ByteArrayOutputStream();
createUsers(0, out);
runner.enqueue(out.toByteArray());
runner.run();
runner.assertTransferCount(SplitAvro.REL_SPLIT, 0);
runner.assertTransferCount(SplitAvro.REL_ORIGINAL, 1);
runner.assertTransferCount(SplitAvro.REL_FAILURE, 0);
}
use of org.apache.nifi.util.TestRunner in project nifi by apache.
the class ITDeleteElasticsearch5Test method testDeleteIntegrationTestDocumentNotFound.
@Test
public void testDeleteIntegrationTestDocumentNotFound() {
final TestRunner runnerDelete = TestRunners.newTestRunner(new DeleteElasticsearch5());
runnerDelete.setValidateExpressionUsage(false);
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.CLUSTER_NAME, clusterName);
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.HOSTS, "127.0.0.1:9300");
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.PING_TIMEOUT, "5s");
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.SAMPLER_INTERVAL, "5s");
runnerDelete.setProperty(DeleteElasticsearch5.INDEX, INDEX1);
runnerDelete.setProperty(DeleteElasticsearch5.TYPE, TYPE1);
runnerDelete.setProperty(DeleteElasticsearch5.DOCUMENT_ID, "${documentId}");
runnerDelete.assertValid();
runnerDelete.enqueue(new byte[] {}, new HashMap<String, String>() {
{
put("documentId", documentId);
}
});
runnerDelete.enqueue(new byte[] {});
runnerDelete.run(1, true, true);
runnerDelete.assertAllFlowFilesTransferred(DeleteElasticsearch5.REL_NOT_FOUND, 1);
final MockFlowFile out = runnerDelete.getFlowFilesForRelationship(DeleteElasticsearch5.REL_NOT_FOUND).get(0);
out.assertAttributeEquals(DeleteElasticsearch5.ES_FILENAME, documentId);
out.assertAttributeEquals(DeleteElasticsearch5.ES_INDEX, INDEX1);
out.assertAttributeEquals(DeleteElasticsearch5.ES_TYPE, TYPE1);
}
use of org.apache.nifi.util.TestRunner in project nifi by apache.
the class ITDeleteElasticsearch5Test method testDeleteIntegrationTestBadType.
@Test
public void testDeleteIntegrationTestBadType() {
final TestRunner runnerDelete = TestRunners.newTestRunner(new DeleteElasticsearch5());
runnerDelete.setValidateExpressionUsage(false);
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.CLUSTER_NAME, clusterName);
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.HOSTS, "127.0.0.1:9300");
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.PING_TIMEOUT, "5s");
runnerDelete.setProperty(AbstractElasticsearch5TransportClientProcessor.SAMPLER_INTERVAL, "5s");
runnerDelete.setProperty(DeleteElasticsearch5.INDEX, INDEX1);
String type = String.valueOf(System.currentTimeMillis());
runnerDelete.setProperty(DeleteElasticsearch5.TYPE, type);
runnerDelete.setProperty(DeleteElasticsearch5.DOCUMENT_ID, "${documentId}");
runnerDelete.assertValid();
runnerDelete.enqueue(new byte[] {}, new HashMap<String, String>() {
{
put("documentId", documentId);
}
});
runnerDelete.enqueue(new byte[] {});
runnerDelete.run(1, true, true);
runnerDelete.assertAllFlowFilesTransferred(DeleteElasticsearch5.REL_NOT_FOUND, 1);
final MockFlowFile out = runnerDelete.getFlowFilesForRelationship(DeleteElasticsearch5.REL_NOT_FOUND).get(0);
out.assertAttributeEquals(DeleteElasticsearch5.ES_FILENAME, documentId);
out.assertAttributeEquals(DeleteElasticsearch5.ES_INDEX, INDEX1);
out.assertAttributeEquals(DeleteElasticsearch5.ES_TYPE, type);
}
use of org.apache.nifi.util.TestRunner in project nifi by apache.
the class TestFetchElasticsearch5 method testFetchElasticsearch5Batch.
@Test
@Ignore("Comment this out if you want to run against local or test ES")
public void testFetchElasticsearch5Batch() throws IOException {
System.out.println("Starting test " + new Object() {
}.getClass().getEnclosingMethod().getName());
final TestRunner runner = TestRunners.newTestRunner(new FetchElasticsearch5());
runner.setValidateExpressionUsage(true);
// Local Cluster - Mac pulled from brew
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.CLUSTER_NAME, "elasticsearch_brew");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.HOSTS, "127.0.0.1:9300");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.PING_TIMEOUT, "5s");
runner.setProperty(AbstractElasticsearch5TransportClientProcessor.SAMPLER_INTERVAL, "5s");
runner.setProperty(FetchElasticsearch5.INDEX, "doc");
runner.setProperty(FetchElasticsearch5.TYPE, "status");
runner.setProperty(FetchElasticsearch5.DOC_ID, "${doc_id}");
runner.assertValid();
String message = convertStreamToString(docExample);
for (int i = 0; i < 100; i++) {
long newId = 28039652140L + i;
final String newStrId = Long.toString(newId);
runner.enqueue(message.getBytes(), new HashMap<String, String>() {
{
put("doc_id", newStrId);
}
});
}
runner.run();
runner.assertAllFlowFilesTransferred(FetchElasticsearch5.REL_SUCCESS, 100);
}
Aggregations