Skip to content

Commit

Permalink
Fix normalization of hardware key/option
Browse files Browse the repository at this point in the history
A bug was introduced in the patching adding multiple disks to testcloud
plugin, and the test was missing.
  • Loading branch information
happz committed Jun 13, 2024
1 parent 3f19bef commit e4991dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 14 additions & 0 deletions tests/unit/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ def test_constraint_components_pattern(value: str, expected: tuple[Any, Any]) ->
assert match.groups() == expected


def test_normalize_hardware(root_logger) -> None:
# All major classes of requirements:
spec = (
# Simple name.child_name=value
'cpu.processors=1',
# The same but with cpu.flags which have special handling
'cpu.flag!=avc',
# name[peer_index].child_name=value
'disk[1].size=1'
)

tmt.steps.provision.normalize_hardware('', spec, root_logger)


@pytest.mark.parametrize(
('spec', 'expected_exc', 'expected_message'),
[
Expand Down
7 changes: 2 additions & 5 deletions tmt/steps/provision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def normalize_hardware(

elif components.name == 'cpu' and components.child_name == 'flag':
if components.name not in merged:
merged[components.name] = []
merged[components.name] = {}

if 'flag' not in merged['cpu']:
merged['cpu']['flag'] = []
Expand All @@ -540,15 +540,12 @@ def normalize_hardware(

elif components.child_name:
if components.name not in merged:
merged[components.name] = []
merged[components.name] = {}

merged[components.name][components.child_name] = \
f'{components.operator} {components.value}'

else:
if components.name not in merged:
merged[components.name] = []

merged[components.name] = f'{components.operator} {components.value}'

# Very crude, we will need something better to handle `and` and
Expand Down

0 comments on commit e4991dd

Please sign in to comment.