Skip to content

Commit

Permalink
Translate cpu.stepping hardware requirement for mrack (#3295)
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily authored Oct 23, 2024
1 parent b9cf8fa commit 74630a0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ The ``tmt link`` command now supports providing multiple links by
using the ``--link`` option. See the :ref:`link-issues` section
for example usage.

The :ref:`/plugins/provision/beaker` provision plugin gains support
for :ref:`cpu.stepping</spec/hardware/cpu>` hardware requirement.


tmt-1.37.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
10 changes: 9 additions & 1 deletion spec/hardware/cpu.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ description: |
model, stepping and corresponding names. ``/proc/cpuinfo`` and ``lscpu``
are also useful resources.

.. versionchanged:: 1.38
``beaker`` plugins supports ``stepping``

.. versionchanged:: 1.35
``beaker`` plugins supports ``vendor-name``

Expand Down Expand Up @@ -108,8 +111,13 @@ example:
cpu:
hyper-threading: true

- |
# Request a CPU with specified stepping.
cpu:
stepping: 9

link:
- implemented-by: /tmt/steps/provision/artemis.py
note: "``cpu.vendor``, ``cpu.vendor-name`` 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`` and ``cpu.vendor-name`` only"
note: "``cpu.flag``, ``cpu.processors``, ``cpu.model``, ``cpu.cores``, ``cpu.model-name``, ``cpu.hyper-threading``, ``cpu.stepping`` and ``cpu.vendor-name`` only"
23 changes: 22 additions & 1 deletion tests/unit/provision/mrack/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ def test_maximal_constraint(root_logger: Logger) -> None:
},
{'or': []},
{'or': []},
{'or': []},
{
'cpu': {
'stepping': {
'_op': '!=',
'_value': '10',
},
},
},
{'or': []},
{
'not':
Expand Down Expand Up @@ -386,6 +393,20 @@ def test_cpu_cores(root_logger: Logger) -> None:
}


def test_cpu_stepping(root_logger: Logger) -> None:
result = _CONSTRAINT_TRANSFORMERS['cpu.stepping'](
_parse_cpu({'stepping': '10'}), root_logger)

assert result.to_mrack() == {
'cpu': {
'stepping': {
'_op': '==',
'_value': '10'
}
}
}


def test_cpu_vendor_name(root_logger: Logger) -> None:
result = _CONSTRAINT_TRANSFORMERS['cpu.vendor_name'](
_parse_cpu({'vendor-name': 'GenuineIntel'}), root_logger)
Expand Down
17 changes: 15 additions & 2 deletions tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@ def _transform_cpu_model_name(
children=[MrackHWBinOp('model_name', beaker_operator, actual_value)])


def _transform_cpu_stepping(
constraint: tmt.hardware.NumberConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
beaker_operator, actual_value, _ = operator_to_beaker_op(
constraint.operator,
str(constraint.value))

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


def _transform_cpu_vendor_name(
constraint: tmt.hardware.TextConstraint,
logger: tmt.log.Logger) -> MrackBaseHWElement:
Expand Down Expand Up @@ -572,12 +584,13 @@ def _transform_system_numa_nodes(

_CONSTRAINT_TRANSFORMERS: Mapping[str, ConstraintTransformer] = {
'beaker.pool': _transform_beaker_pool, # type: ignore[dict-item]
'cpu.cores': _transform_cpu_cores, # 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]
'cpu.processors': _transform_cpu_processors, # type: ignore[dict-item]
'cpu.cores': _transform_cpu_cores, # type: ignore[dict-item]
'cpu.model_name': _transform_cpu_model_name, # type: ignore[dict-item]
'cpu.processors': _transform_cpu_processors, # type: ignore[dict-item]
'cpu.stepping': _transform_cpu_stepping, # type: ignore[dict-item]
'cpu.vendor_name': _transform_cpu_vendor_name, # type: ignore[dict-item]
'disk.driver': _transform_disk_driver, # type: ignore[dict-item]
'disk.model_name': _transform_disk_model_name, # type: ignore[dict-item]
Expand Down

0 comments on commit 74630a0

Please sign in to comment.