Fixed predict module, config tests, cleanup
modules/predict: cleaned up unused function, variables, trailing whitespace
The stats
module is now also included if not exists.
$ luacheck modules/predict
Checking modules/predict/predict.lua OK
Total: 0 warnings / 0 errors in 1 file
converted constant tables, support kres.type.TYPE1234
The difficulty with using structs as constant tables is that access to non-existent fields throws an error. This is difficult to handle without wrapping every access in a pcall, for example in predict module:
error: /usr/local/lib/kdns_modules/predict.lua:34: 'struct rr_type' has no member named 'TYPE65535'
So I converted the constant tables into regular Lua tables, and added a metatable for RR types to allow looking up unnamed types, in the TYPE%d format. Looking up non-existent fields will now return nil instead of throwing an error.
tests: fixed config tests locking up on error, added test for predict
The config tests locked up on error as if error was raised from the
event callback, it would never reach the quit()
statement, so
server would never close on error. Added a script to make running these types of tests a little bit nicer and to allow concurrent execution of config tests.
Added a test for the predict module, that fails on prediction of unknown types:
error: /usr/local/lib/kdns_modules/predict.lua:34: 'struct rr_type' has no member named 'TYPE65535'