You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Matt Burgess <ma...@apache.org> on 2016/04/28 20:42:56 UTC

NiFi Script Tester utility

I've been getting lots of questions about how to develop/debug scripts
that go into ExecuteScript. One way to do this is to add a unit test
to the nifi-scripting-processors submodule, and set the Script File
property to your test script. However for this you basically need the
full NiFi source.

To make things easier, I basically took a pared-down copy of the
ExecuteScript processor (and its helper classes), added nifi-mock as a
dependency, and slapped a command-line interface on it. This way with
a single JAR you can run your script inside a dummy flow containing
ExecuteScript.

 Announcing v1.0 of the NiFi Script Tester utility:
https://github.com/mattyb149/nifi-script-tester

also on Bintray:
https://bintray.com/mattyb149/maven/download_file?file_path=mattyb149%2Fnifi-script-tester%2F1.0%2Fnifi-script-tester-1.0-all.jar

Basically it runs your script as a little unit test, and you can pipe
stdin to become a flowfile, or point it at a directory and it will
send every file as a flowfile, stuff like that. If your script doesn't
need a flowfile, you can run it without specifying an input dir or
piping in stdin, it will run once even without input.

It only supports Javascript and Groovy at the moment; including Jython
for example would 5X the size :/ Right now its only 8.4 MB, so a
little big but not too bad.

Anyway hope this helps, please let me know how/if it works for you!

Cheers,
Matt

Re: NiFi Script Tester utility

Posted by Joe Skora <js...@gmail.com>.
Matt,

That's very cool.  When I get some time I might try the script processor
just to check the tester out.

Joe

On Thu, Apr 28, 2016 at 2:42 PM, Matt Burgess <ma...@apache.org> wrote:

> I've been getting lots of questions about how to develop/debug scripts
> that go into ExecuteScript. One way to do this is to add a unit test
> to the nifi-scripting-processors submodule, and set the Script File
> property to your test script. However for this you basically need the
> full NiFi source.
>
> To make things easier, I basically took a pared-down copy of the
> ExecuteScript processor (and its helper classes), added nifi-mock as a
> dependency, and slapped a command-line interface on it. This way with
> a single JAR you can run your script inside a dummy flow containing
> ExecuteScript.
>
>  Announcing v1.0 of the NiFi Script Tester utility:
> https://github.com/mattyb149/nifi-script-tester
>
> also on Bintray:
>
> https://bintray.com/mattyb149/maven/download_file?file_path=mattyb149%2Fnifi-script-tester%2F1.0%2Fnifi-script-tester-1.0-all.jar
>
> Basically it runs your script as a little unit test, and you can pipe
> stdin to become a flowfile, or point it at a directory and it will
> send every file as a flowfile, stuff like that. If your script doesn't
> need a flowfile, you can run it without specifying an input dir or
> piping in stdin, it will run once even without input.
>
> It only supports Javascript and Groovy at the moment; including Jython
> for example would 5X the size :/ Right now its only 8.4 MB, so a
> little big but not too bad.
>
> Anyway hope this helps, please let me know how/if it works for you!
>
> Cheers,
> Matt
>