Skip to content

Commit

Permalink
Support beaker.pool hardware requirement for mrack (#3074)
Browse files Browse the repository at this point in the history
Co-authored-by: Miloš Prchlík <[email protected]>
  • Loading branch information
skycastlelily and happz authored Aug 1, 2024
1 parent 1e3c6fa commit 5fbbd89
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Change of Polarion field to store tmt id. Now using 'tmt ID' field,
specifically created for this purpose instead of 'Test Case ID' field.

The :ref:`/plugins/provision/beaker` provision plugin gains
support for :ref:`cpu.vendor-name</spec/hardware/cpu>` hardware
requirement.
support for :ref:`cpu.vendor-name</spec/hardware/cpu>` and
:ref:`beaker.pool</spec/hardware/beaker>` hardware requirements.


tmt-1.34
Expand Down
3 changes: 3 additions & 0 deletions spec/hardware/beaker.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ example:
# Select any system, as long as it is not from the given Beaker pool
beaker:
pool: "!= very-rare-machines"

link:
- implemented-by: /tmt/steps/provision/mrack.py
6 changes: 5 additions & 1 deletion tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def test_maximal_constraint(root_logger: Logger) -> None:

assert result.to_mrack() == {
'and': [
{'or': []},
{'pool': {
'_op': '!=',
'_value': 'foo.*',
},
},
{'or': []},
{
'and': [
Expand Down
14 changes: 14 additions & 0 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ def _transform_unsupported(
return MrackHWOrGroup()


def _transform_beaker_pool(
constraint: tmt.hardware.TextConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
beaker_operator, actual_value, negate = operator_to_beaker_op(
constraint.operator,
constraint.value)

return MrackHWBinOp(
'pool',
beaker_operator,
actual_value)


def _transform_cpu_flag(
constraint: tmt.hardware.TextConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
Expand Down Expand Up @@ -536,6 +549,7 @@ def _transform_system_numa_nodes(
tmt.hardware.Constraint[Any], tmt.log.Logger], MrackBaseHWElement]

_CONSTRAINT_TRANSFORMERS: Mapping[str, ConstraintTransformer] = {
'beaker.pool': _transform_beaker_pool, # type: ignore[dict-item]
'cpu.flag': _transform_cpu_flag, # type: ignore[dict-item]
'cpu.hyper_threading': _transform_cpu_hyper_threading, # type: ignore[dict-item]
'cpu.model': _transform_cpu_model, # type: ignore[dict-item]
Expand Down

0 comments on commit 5fbbd89

Please sign in to comment.