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.
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).
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:
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With