PowerDNS / pdns

PowerDNS Authoritative, PowerDNS Recursor, dnsdist
https://www.powerdns.com/
GNU General Public License v2.0
3.59k stars 900 forks source link

Need way to run Lua script in Recursor context for testing #7355

Open ahupowerdns opened 5 years ago

ahupowerdns commented 5 years ago

As noted in #3211 we need more test for our Lua stuff. Right now, it is not straightforward to automate such tests. We can launch the Recursor with a Lua test script, but then the recursor stays up and running, and it is hard to communicate the result of tests to a test framework.

It would be great if we could do this:

pdns_recursor --run-lua-script-once=test.lua
if [ $? ...

The test.lua script could either return a code (like '1'), and we'd pass that on to the operating system, or it could call os.exit(1) directly, and we'd return that.

The test.lua script would run with all the facilities of a regular PowerDNS Lua script.

Usecase

Write better tests.

wojas commented 5 years ago

Ideally it would also allow passing command line arguments, but that might be hard to implement with the option parser.

I currently pass them through an env var and unpack them in the script:

local args = os.getenv('recursor_lua_args')
if args and #args > 0 then
    _G.arg = utils.split(args, ' ')
end