Skip to content

Commit 4ce3685

Browse files
authored
[6.17.z] Modifications in CLI and UI Libvirt CR to resolve key error SatelliteQE#20176 (SatelliteQE#20791)
cherrypick : Modifications in CLI and UI Libvirt CR to resolve key error SatelliteQE#20176
1 parent 7a11d87 commit 4ce3685

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

pytest_fixtures/component/provision_pxe.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def module_provisioning_sat(
147147
It calls a workflow using broker to set up the network and to run satellite-installer.
148148
It uses the artifacts from the workflow to create all the necessary Satellite entities
149149
that are later used by the tests.
150+
For IPv4, it clears DHCP leases and restarts dhcpd to ensure provisioning can obtain addresses.
150151
"""
151152
provisioning_type = getattr(request, 'param', '')
152153
sat = module_target_sat
@@ -208,6 +209,9 @@ def module_provisioning_sat(
208209
remote_execution_proxy=[module_provisioning_capsule.id],
209210
domain=[domain.id],
210211
).create()
212+
if sat.network_type == NetworkType.IPV4:
213+
assert sat.execute('cat /dev/null > /var/lib/dhcpd/dhcpd.leases').status == 0
214+
assert sat.execute('systemctl restart dhcpd').status == 0
211215
return Box(sat=sat, domain=domain, subnet=subnet, provisioning_type=provisioning_type)
212216

213217

tests/foreman/cli/test_computeresource_libvirt.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from robottelo.exceptions import CLIReturnCodeError
4141
from robottelo.hosts import ContentHost
4242
from robottelo.utils.datafactory import parametrized
43+
from robottelo.utils.issue_handlers import is_open
4344

4445
LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname
4546

@@ -408,6 +409,10 @@ def test_positive_provision_end_to_end(
408409
409410
:customerscenario: true
410411
"""
412+
# Skip test for UEFI and SecureBoot loaders
413+
if is_open('SAT-41340') and pxe_loader.vm_firmware in ['uefi', 'uefi_secure_boot']:
414+
pytest.skip(f"Test not supported for {pxe_loader.vm_firmware} firmware")
415+
411416
sat = module_libvirt_provisioning_sat.sat
412417
cr_name = gen_string('alpha')
413418
hostname = gen_string('alpha').lower()
@@ -450,12 +455,16 @@ def test_positive_provision_end_to_end(
450455
f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"'
451456
)
452457
assert hostname in result.stdout
453-
454458
wait_for(
455-
lambda: sat.cli.Host.info({'name': hostname})['status']['build-status']
456-
!= 'Pending installation',
459+
lambda: (
460+
sat.cli.Host.info({'name': hostname})
461+
.get('status', {})
462+
.get('build-status', 'Pending installation')
463+
!= 'Pending installation'
464+
),
457465
timeout=1800,
458466
delay=30,
467+
handle_exception=True,
459468
)
460469
host_info = sat.cli.Host.info({'id': host['id']})
461470
assert host_info['status']['build-status'] == 'Installed'

tests/foreman/ui/test_computeresource_libvirt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ def test_positive_provision_end_to_end(
181181
)
182182
name = f'{hostname}.{module_libvirt_provisioning_sat.domain.name}'
183183
request.addfinalizer(lambda: sat.provisioning_cleanup(name))
184-
assert session.host.search(name)[0]['Name'] == name
185-
184+
result = session.host_new.search(name)[0]
185+
assert result['Name'] == name
186186
# Check on Libvirt, if VM exists
187187
result = sat.execute(
188188
f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"'
@@ -203,7 +203,7 @@ def test_positive_provision_end_to_end(
203203

204204
# Verify SecureBoot is enabled on host after provisioning is completed successfully
205205
if pxe_loader.vm_firmware == 'uefi_secure_boot':
206-
host = sat.api.Host().search(query={'host': hostname})[0].read()
206+
host = sat.api.Host().search(query={"search": f'name={name}'})[0].read()
207207
provisioning_host = ContentHost(host.ip)
208208
# Wait for the host to be rebooted and SSH daemon to be started.
209209
provisioning_host.wait_for_connection()

0 commit comments

Comments
 (0)