-
Committer:
Zygmunt Krynicki
-
Date:
2014-01-08 15:25:08 UTC
-
mto:
This revision was merged to the branch mainline in
revision
2587.
-
Revision ID:
zygmunt.krynicki@canonical.com-20140108152508-6fnim1uhw4qjuhnl
plainbox: extend IJobQualifier interface
The IJobQualifier interface is used as a common way to interact with
various types of job qualifiers, things that either designate a job or
not. This interface is insufficient for portable deep inspection into
the data held by the WhiteList qualifier class, required to implement
the so-called whitelist ordering feature, where the order of jobs does
not deviate, at runtime, from what is written down inside a .whitelist
file.
This patch extends the interface to have two more methods and one more
property. The new get_vote() method replaces and generalizes the
existing designates() method, allowing qualifiers to both include and
exclude jobs for execution. The second new method,
get_primitive_qualifiers() offers a common low-level iterator-like API
for flattening potentially complex qualifiers, such as the whitelist
class. The new property, is_primitive, distinguishes primitive (without
any further structure) qualifiers from any non-primitive qualifiers,
that can be flattened by calling get_primitive_qualifiers() method.
This allows us to write generic job selection code that preserves
ordering of current whitelists as well as any hypothetical (upcoming)
new test plan formats.
Unit tests were adapted to test all of the new code. Several existing
qualifiers were patched, some of that was trivial (RegExpJobQualifier
and NameJobQualifier now share a common SimpleQualifier base class),
some more involved (CompositeQualifier was rewritten to use a single
list and rely on INCLUDE and EXCLUDE votes). The rather obscure
ResumeDiscardQualifier used during session resume was rewritten with
SimpleQualifier as base class and given dedicated tests.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>