Improving Config Validation Testing

Maxim Dounin mdounin at mdounin.ru
Tue Jun 29 19:15:00 MSD 2010


Hello!

On Tue, Jun 29, 2010 at 03:47:24PM +0100, Hassan Syed wrote:

> I am wondering if there is anything in the pipeline that may ease config
> validation testing. The use-case I am currently working on is testing the
> validity of config for a certain module. If for a particular location a
> module is active, than a certain other directives should be present, and if
> they are present it should be possible to test for some other predicates at
> runtime (for example files on the file-system, where filenames are specified
> as directives for the module).

Normally cross-directive dependencies are hand-checked during 
configuration merge, see e.g. proxy module for an example.

In some trivial cases dependencies may be checked in command set 
or post handlers (but this doesn't work if some dependant 
directives may be inherited from upper levels).

> Nginx's out-of-the-box configuration is quite elegant, and it is hard to
> write incorrect config files. And most common settings have default values.
> However in my case I require more validation.
> 
> I have hacked together some code to test weather all requisite directives
> have been set (in contrast to checking them one by one, and returning a
> single error at a time). If one or more aren't, the code builds and returns
> a formatted list of missing directives.
> 
> I'm just wondering if there is room for modelling such dependencies directly
> in the "ngx_comman_t array" provided when creating a module, and perhaps for
> a general purpose delegate mechanism that would allow other predicates to be
> evaluated at runtime.

I believe introducing some generic mechanism for checking 
dependencies would be non-trivial as there are lots of possible 
dependencies and lots of possible directive effects.  So 
eventually you'll end up writing custom checks... and you may 
easily do this right now, without even talking about mechanisms.  
;)

Maxim Dounin



More information about the nginx-devel mailing list