Skip to content

Commit

Permalink
Support cpu.frequency hardware requirement for mrack (#3297)
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily authored Nov 15, 2024
1 parent 45d611c commit 938d8bc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ tmt-1.39.0

The :ref:`/plugins/provision/beaker` provision plugin gains
support for :ref:`system.model-name</spec/hardware/system>`,
:ref:`system.vendor-name</spec/hardware/system>` and
:ref:`cpu.family</spec/hardware/system>` hardware requirements.
:ref:`system.vendor-name</spec/hardware/system>`,
:ref:`cpu.family</spec/hardware/system>` and
:ref:`cpu.frequency</spec/hardware/cpu>` hardware requirements.

The ``tmt lint`` command now reports a failure if empty
environment files are found.
Expand Down
6 changes: 3 additions & 3 deletions spec/hardware/cpu.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ description: |
are also useful resources.

.. versionchanged:: 1.39
``beaker`` plugins supports ``family``
``beaker`` plugins supports ``family`` and ``frequency``

.. versionchanged:: 1.38
``beaker`` plugins supports ``stepping``
Expand Down Expand Up @@ -125,8 +125,8 @@ example:

link:
- implemented-by: /tmt/steps/provision/artemis.py
note: "``cpu.vendor``, ``cpu.vendor-name`` and ``cpu.hyper-threading`` not implemented yet"
note: "``cpu.vendor``, ``cpu.vendor-name``, ``cpu.frequency`` and ``cpu.hyper-threading`` not implemented yet"
- implemented-by: /tmt/steps/provision/mrack.py
note: "``cpu.flag``, ``cpu.processors``, ``cpu.model``, ``cpu.cores``, ``cpu.model-name``, ``cpu.hyper-threading``, ``cpu.stepping``, ``cpu.family`` and ``cpu.vendor-name`` only"
note: "``cpu.sockets``, ``cpu.threads``, ``cpu.cores-per-socket``, ``cpu.threads-per-core``, ``cpu.family-name``, ``cpu.vendor`` not implemented yet"
- implemented-by: /tmt/steps/provision/testcloud.py
note: "``cpu.processors`` only"
9 changes: 8 additions & 1 deletion tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ def test_maximal_constraint(root_logger: Logger) -> None:
},
},
},
{'or': []},
{
'cpu': {
'speed': {
'_op': '>=',
'_value': '2300.0',
},
},
},
{'or': []},
{
'not':
Expand Down
2 changes: 1 addition & 1 deletion tmt/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def _cast_int(raw_value: Any) -> int:
)


class NumberConstraint(Constraint[float]):
class NumberConstraint(Constraint['Quantity']):
""" A constraint representing a float number """

@classmethod
Expand Down
13 changes: 13 additions & 0 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,18 @@ def _transform_cpu_model_name(
children=[MrackHWBinOp('model_name', beaker_operator, actual_value)])


def _transform_cpu_frequency(
constraint: tmt.hardware.NumberConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
beaker_operator, actual_value, _ = operator_to_beaker_op(
constraint.operator,
str(float(constraint.value.to('MHz').magnitude)))

return MrackHWGroup(
'cpu',
children=[MrackHWBinOp('speed', beaker_operator, actual_value)])


def _transform_cpu_stepping(
constraint: tmt.hardware.IntegerConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
Expand Down Expand Up @@ -633,6 +645,7 @@ def _transform_system_vendor_name(
'cpu.cores': _transform_cpu_cores, # type: ignore[dict-item]
'cpu.family': _transform_cpu_family, # type: ignore[dict-item]
'cpu.flag': _transform_cpu_flag, # type: ignore[dict-item]
'cpu.frequency': _transform_cpu_frequency, # type: ignore[dict-item]
'cpu.hyper_threading': _transform_cpu_hyper_threading, # type: ignore[dict-item]
'cpu.model': _transform_cpu_model, # type: ignore[dict-item]
'cpu.model_name': _transform_cpu_model_name, # type: ignore[dict-item]
Expand Down

0 comments on commit 938d8bc

Please sign in to comment.