Skip to content

Commit

Permalink
Support system.model-name hardware requirement for mrack (#3280)
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily authored Oct 29, 2024
1 parent b707724 commit 7def3eb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
8 changes: 8 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
======================


tmt-1.39.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The :ref:`/plugins/provision/beaker` provision plugin gains
support for :ref:`system.model-name</spec/hardware/system>`
hardware requirement.


tmt-1.38.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
10 changes: 9 additions & 1 deletion spec/hardware/system.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ description: |
# Integer or string, required number of NUMA nodes.
numa-nodes: 2|">= 2"

.. versionchanged:: 1.38
``beaker`` plugins supports ``model-name``

example:
- |
# Select any system by a given vendor
system:
vendor-name: "~ HPE"

- |
# Select any system by a given model name
system:
model-name: "~ PowerEdge R750"

- |
# Select any HPE system with enough NUMA nodes.
system:
Expand All @@ -34,4 +42,4 @@ example:

link:
- implemented-by: /tmt/steps/provision/mrack.py
note: "``system.numa-nodes`` only"
note: "``system.numa-nodes`` and ``system.model-name`` only"
25 changes: 24 additions & 1 deletion tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,14 @@ def test_maximal_constraint(root_logger: Logger) -> None:
},
},
},
{'or': []},
{
'system': {
'model': {
'_op': 'like',
'_value': 'PowerEdge R750',
},
},
},
]
},
{
Expand Down Expand Up @@ -886,3 +893,19 @@ def test_system_numa_nodes(root_logger: Logger) -> None:
}
}
}


def test_system_model_name(root_logger: Logger) -> None:
result = _CONSTRAINT_TRANSFORMERS['system.model_name'](
_parse_system({'model-name': '!~ PowerEdge R750.*'}), root_logger)

assert result.to_mrack() == {
'not': {
'system': {
'model': {
'_op': 'like',
'_value': 'PowerEdge R750%'
}
}
}
}
18 changes: 18 additions & 0 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,23 @@ def _transform_system_numa_nodes(
children=[MrackHWBinOp('numanodes', beaker_operator, actual_value)])


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

if negate:
return MrackHWNotGroup(children=[
MrackHWGroup('system',
children=[MrackHWBinOp('model', beaker_operator, actual_value)])
])

return MrackHWGroup('system',
children=[MrackHWBinOp('model', beaker_operator, actual_value)])


ConstraintTransformer = Callable[[
tmt.hardware.Constraint[Any], tmt.log.Logger], MrackBaseHWElement]

Expand Down Expand Up @@ -608,6 +625,7 @@ def _transform_system_numa_nodes(
'zcrypt.adapter': _transform_zcrypt_adapter, # type: ignore[dict-item]
'zcrypt.mode': _transform_zcrypt_mode, # type: ignore[dict-item]
'system.numa_nodes': _transform_system_numa_nodes, # type: ignore[dict-item]
'system.model_name': _transform_system_model_name, # type: ignore[dict-item]
'iommu.is_supported': _transform_iommu_is_supported, # type: ignore[dict-item]
}

Expand Down

0 comments on commit 7def3eb

Please sign in to comment.