From 5a17c67cb315352c1569d1a2d63268c639b806c8 Mon Sep 17 00:00:00 2001 From: Nakul Pathak Date: Thu, 12 Feb 2026 17:33:32 +0530 Subject: [PATCH] cherrypick : Modifications in CLI and UI Libvirt CR to resolve key error #20176 --- pytest_fixtures/component/provision_pxe.py | 4 ++++ tests/foreman/cli/test_computeresource_libvirt.py | 15 ++++++++++++--- tests/foreman/ui/test_computeresource_libvirt.py | 6 +++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pytest_fixtures/component/provision_pxe.py b/pytest_fixtures/component/provision_pxe.py index e8810d17eae..e8ebc6fea19 100644 --- a/pytest_fixtures/component/provision_pxe.py +++ b/pytest_fixtures/component/provision_pxe.py @@ -147,6 +147,7 @@ def module_provisioning_sat( It calls a workflow using broker to set up the network and to run satellite-installer. It uses the artifacts from the workflow to create all the necessary Satellite entities that are later used by the tests. + For IPv4, it clears DHCP leases and restarts dhcpd to ensure provisioning can obtain addresses. """ provisioning_type = getattr(request, 'param', '') sat = module_target_sat @@ -208,6 +209,9 @@ def module_provisioning_sat( remote_execution_proxy=[module_provisioning_capsule.id], domain=[domain.id], ).create() + if sat.network_type == NetworkType.IPV4: + assert sat.execute('cat /dev/null > /var/lib/dhcpd/dhcpd.leases').status == 0 + assert sat.execute('systemctl restart dhcpd').status == 0 return Box(sat=sat, domain=domain, subnet=subnet, provisioning_type=provisioning_type) diff --git a/tests/foreman/cli/test_computeresource_libvirt.py b/tests/foreman/cli/test_computeresource_libvirt.py index c582c810bf4..d0eb5d7d78f 100644 --- a/tests/foreman/cli/test_computeresource_libvirt.py +++ b/tests/foreman/cli/test_computeresource_libvirt.py @@ -40,6 +40,7 @@ from robottelo.exceptions import CLIReturnCodeError from robottelo.hosts import ContentHost from robottelo.utils.datafactory import parametrized +from robottelo.utils.issue_handlers import is_open LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname @@ -408,6 +409,10 @@ def test_positive_provision_end_to_end( :customerscenario: true """ + # Skip test for UEFI and SecureBoot loaders + if is_open('SAT-41340') and pxe_loader.vm_firmware in ['uefi', 'uefi_secure_boot']: + pytest.skip(f"Test not supported for {pxe_loader.vm_firmware} firmware") + sat = module_libvirt_provisioning_sat.sat cr_name = gen_string('alpha') hostname = gen_string('alpha').lower() @@ -450,12 +455,16 @@ def test_positive_provision_end_to_end( f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"' ) assert hostname in result.stdout - wait_for( - lambda: sat.cli.Host.info({'name': hostname})['status']['build-status'] - != 'Pending installation', + lambda: ( + sat.cli.Host.info({'name': hostname}) + .get('status', {}) + .get('build-status', 'Pending installation') + != 'Pending installation' + ), timeout=1800, delay=30, + handle_exception=True, ) host_info = sat.cli.Host.info({'id': host['id']}) assert host_info['status']['build-status'] == 'Installed' diff --git a/tests/foreman/ui/test_computeresource_libvirt.py b/tests/foreman/ui/test_computeresource_libvirt.py index 2d77786370b..01507388f15 100644 --- a/tests/foreman/ui/test_computeresource_libvirt.py +++ b/tests/foreman/ui/test_computeresource_libvirt.py @@ -181,8 +181,8 @@ def test_positive_provision_end_to_end( ) name = f'{hostname}.{module_libvirt_provisioning_sat.domain.name}' request.addfinalizer(lambda: sat.provisioning_cleanup(name)) - assert session.host.search(name)[0]['Name'] == name - + result = session.host_new.search(name)[0] + assert result['Name'] == name # Check on Libvirt, if VM exists result = sat.execute( 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( # Verify SecureBoot is enabled on host after provisioning is completed successfully if pxe_loader.vm_firmware == 'uefi_secure_boot': - host = sat.api.Host().search(query={'host': hostname})[0].read() + host = sat.api.Host().search(query={"search": f'name={name}'})[0].read() provisioning_host = ContentHost(host.ip) # Wait for the host to be rebooted and SSH daemon to be started. provisioning_host.wait_for_connection()