Add config options to resultsdb for requiring fields.
ClosedPublic

Authored by jskladan on Dec 6 2016, 4:11 PM.

Details

Summary

Fixes T868

Ralph wanted to be able to require ref_url in the Result. Doing this,
I discovered that even though we have some fields marked as required,
the engine does not really provide an option to set, that the field must
be both specified, and non-empty, thus leading to some situations, that
I thought are covered by marking stuff as 'required' like a Result's testcase
where the 'required' condition would be satisfied by an empty dict,
and that is not semantically right.

So this patch does two things, in the end

  1. it makes sure, that 'required' fields are also checked for 'non-emptiness'
  2. adds config options for specifying which (additional) fields are to be required

Ad the config part - the config now has a new option REQUIRED_DATA (dict).
This can be used to specify field, that are to be marked as required for the
request parser instace specified by the dict's key (e.g. create_result).
The value of that key is a list of strings, where the string is the name of
the field, which is to be set as required (e.g. create_group: ['description'])
These fields are _in addition_ to the fields that are already required,
so there is no way to say, that outcome is now not required for Result.

As Results are a specific beast, the fields-to-be-required can be also
specified in the data.{NAME} format, to enforce data in the 'additional
fields' - e.g. to require an arch value, you could set
create_result: ['data.arch']. This only works for create_result as
it is the only place where the fields can be 'generic'.

Test Plan

Unit tests added

Diff Detail

Repository
rRSDB resultsdb
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jskladan retitled this revision from to Add config options to resultsdb for requiring fields..Dec 6 2016, 4:11 PM
jskladan updated this object.
jskladan edited the test plan for this revision. (Show Details)
kparal accepted this revision.Jan 13 2017, 2:05 PM

I'm not familiar with the code and I did not check it thoroughly. But the idea behind this sounds OK and the code changes from a 100m view also look fine :-)

This revision is now accepted and ready to land.Jan 13 2017, 2:05 PM
ralph accepted this revision.Jan 13 2017, 2:06 PM
ralph added a reviewer: ralph.
ralph added a subscriber: ralph.

Looks good to me.

Closed by commit rRSDBae67091ddd85: Add config options to resultsdb for requiring fields. (authored by Josef Skladanka <jskladan@redhat.com>). · Explain WhyJan 17 2017, 9:50 AM
This revision was automatically updated to reflect the committed changes.