lisa¶
A plugin for organizing, analyzing, and selecting tests.
This plugin provides the mark pytest.mark.lisa
, aliased as
LISA()
, for marking up tests metadata beyond that which
Pytest provides by default. See the lisa_schema
for the
expected metadata input.
Tests can be selected through a playbook.yaml
file using the
criteria schema (using the pytest-playbook plugin). For example:
criteria:
# Select all Priority 0 tests.
- priority: 0
# Run tests with 'smoke' in the name twice.
- name: smoke
times: 2
# Exclude all tests in Area "xdp"
- area: xdp
exclude: true
Todo
Review the
criteria
schema.Provide test metadata statistics via a command-line flag.
Assert every test has a LISA marker.
Functions
|
Wrapper function so we can have a |
|
Pytest collection modifyitems hook for modifying the selected items (tests). |
|
Pytest configure hook to perform initial configuration. |
|
|
|
pytest-xdist make scheduler hook for implementing a custom scheduler. |
|
Validate each test’s |
Classes
|
Implement load scheduling across nodes, but grouping by target parameter. |
-
lisa.
LISA
= MarkDecorator(mark=Mark(name='lisa', args=(), kwargs={}))[source]¶ Alias for the Pytest mark
lisa
.
-
lisa.
pytest_configure
(config: Config) → None[source][source]¶ Pytest configure hook to perform initial configuration.
We’re registering our custom marker so that it passes
--strict-markers
.
-
lisa.
pytest_playbook_schema
(schema: Dict[Any, Any]) → None[source][source]¶ pytest_playbook_schema()
hook to update the playbook schema.
-
lisa.
lisa_schema
= Schema({Literal("platform", description="The test's intended platform."): <class 'str'>, Literal("category", description="The kind of test this is."): Or('Functional', 'Performance', 'Stress', 'Community', 'Longhaul'), Literal("area", description="The test's area (or 'feature')."): <class 'str'>, Literal("priority", description="The test's priority with 0 being the highest."): Or(0, 1, 2, 3), Optional('tags'): [<class 'str'>], Optional('features'): [<class 'str'>], Optional('reuse'): <class 'bool'>, Optional('count'): And(<class 'int'>, <function <lambda>>)})[source]¶ Schema used to validate a test’s metadata.
-
lisa.
pytest_collection_modifyitems
(session: Session, config: Config, items: List[Item]) → None[source][source]¶ Pytest collection modifyitems hook for modifying the selected items (tests).
First we validate all the
LISA()
marks on the collected tests. Then we parse the givencriteria
in the playbook to include or exclude tests. We do not care if theplatform
mismatches because we intend a multiplicative effect where all selected tests in a playbook are run on all the targets.
-
class
lisa.
LISAScheduling
(config: Config, log=None)[source][source]¶ Bases:
xdist.scheduler.loadscope.LoadScopeScheduling
Implement load scheduling across nodes, but grouping by target parameter.
This algorithm ensures that all tests which share the same set of parameters (namely the target) will run on the same executor as a single work-unit.
Todo
This essentially confines the targets and one target won’t be spun up multiple times when run in parallel, so we should make this scheduler optional, as an alternative scenario is to spin up multiple near-identical instances of a target in order to run tests in parallel.
This is modeled after the built-in
LoadFileScheduling
, which also simply subclassesLoadScopeScheduling
. See_split_scope
for the important part. Note that we can extend this to implement any kind of scheduling algorithm we want.
-
lisa.
pytest_xdist_make_scheduler
(config: Config) → LISAScheduling[source][source]¶ pytest-xdist make scheduler hook for implementing a custom scheduler.