-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add snabb config test functionality #1339
base: master
Are you sure you want to change the base?
Conversation
3a83c4f
to
3b0e5f3
Compare
Reworks `snabb config` command line parsing somewhat to allow `snabb config test` to work. `snabb config test` loads a schema passed with `-s` either by name (if already known by snabb) or by file path, then validates a passed configuration FILE against the schema. Signed-off-by: Ben Agricola <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good :) Some comments. Also, do you think it ever makes sense to use a compiled file? I have the feeling that we should always be "testing" source. (Should this command be named "snabb config compile" instead, and make it compile a configuration instead?)
@@ -53,8 +53,10 @@ function load_configuration(filename, opts) | |||
end | |||
local function err(msg, ...) error(err_msg(msg, ...)) end | |||
local function log(msg, ...) | |||
io.stderr:write(err_msg(msg, ...)..'\n') | |||
io.stderr:flush() | |||
if opts.verbose then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to change the default above at line 34 to verbose={default=true}
, to keep the current behavior for existing callers.
if opts.require_schema then err("missing --schema arg") end | ||
ret.schema_name = descr.default_schema | ||
|
||
if opts.command == 'test' then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno, I think since there's these two ways to deal with the schema -- either as provided by the user or as received from the remote -- I think it makes sense to move all argument handling to test.lua
, to avoid making this common.lua
too specific on the commands being used. WDYT?
FWIW there is an ad-hoc implementation of this functionality in vita so this will be very useful to me! ❤️ |
@wingo re: should we ever config test a compiled file - no, that's a good point 😃- I'll rework this as |
(JFYI I didn't merge this on my sweep through open PRs just now because based on the discussion it seems like changes are pending.) |
Yep, pending a rewrite I'm hoping to get around to after more |
@wingo as mentioned on Slack earlier 🙂
Reworks
snabb config
command line parsing slightly to implementsnabb config test
.snabb config test
loads a schema passed with-s
either by name (if already known by snabb) or by file path, then validates a passed configuration FILE against the schema.If no
-s
is given butID
is passed, thenconfig test
attempts to connect to the instance and grab the current schema.Also modifies the
log()
function so that informational log messages like the ones below are only printed when verbose is passed toyang.load_configuration
:NOTE: WIP as I haven't tested this against running snabb instances yet, will complete this next week.