Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integration and Unit testing Nifi process groups

I have a few Nifi process groups which I want to run integration tests on before promoting to production. The issue is that I can't seem to find any documentation on how to do so.

Data Provenance seems like a promising tool to accomplish what I want, however, over the course of the flowfile's lifecycle, data is published to/from kafka or the file system. As a result, the flowfile UUID changes so I cannot query for it using the nifi-api.

Additionally, I know that Nifi offers a TestRunner library to run tests, however, this seems to only be for processors/processor groups generated via code and not the UI.

Does anyone know of a tool, framework, or pattern for integration and unit testing nifi process groups. Ideally this would be a solution where you can programatically compare input/output of the processor/processor group without modifying the existing workflow.

like image 479
bryce Avatar asked Aug 13 '18 22:08

bryce


People also ask

What is unit testing in NiFi?

Unit testing The NiFi framework comes with extensive testing utilities for the framework itself as well as individual processors. You can examine the test code of any bundled processor to see common test patterns (testing a specific logic method vs. testing the execution of arbitrary flowfiles through the TestRunner mock execution).

How to process integration testing for program units?

In order to process the integration testing for each program unit, test conditions should be prepared. Once the conditions are listed, these have to be documented, so that they can be used while performing integration tests. 5. Choose an automation tool and execute the tests:

How do I test the NiFi framework?

The NiFi framework comes with extensive testing utilities for the framework itself as well as individual processors. You can examine the test code of any bundled processor to see common test patterns (testing a specific logic method vs. testing the execution of arbitrary flowfiles through the TestRunner mock execution).

What is integration testing?

It is a software testing technique where individual units of a program are combined and tested as a group. Test stubs and test drivers are used to assist in Integration Testing.


1 Answers

With the introduction of the Apache NiFi Registry, we have seen users promote flows from a development/sandbox environment to a test/QE environment where there are existing "test harness" flows surrounding the "flow under test" so that they can send repeatable and deterministic (or an anonymized sample of real production data) through the flow and compare the results to an expected value.

As you point out, there is a TestRunner class and a whole testing framework provided for unit tests. While it can be difficult to manually translate a UI-constructed flow to the programmatic construction, you could also create something like a translator to accept a flow template or flow.xml.gz file and convert it into something processable by the test framework.

like image 108
Andy Avatar answered Oct 13 '22 20:10

Andy