Skip to content

Commit 2e5e393

Browse files
committed
drop assert_vm_xml_efi
Signed-off-by: akri3i <guptaakriti70@gmail.com>
1 parent 44e7b79 commit 2e5e393

File tree

6 files changed

+19
-42
lines changed

6 files changed

+19
-42
lines changed

tests/infrastructure/instance_types/supported_os/test_fedora_os.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from utilities.constants import PREFERENCE_STR, U1_MEDIUM_STR
1010
from utilities.virt import (
1111
assert_linux_efi,
12-
assert_vm_xml_efi,
1312
check_qemu_guest_agent_installed,
1413
check_vm_xml_smbios,
1514
running_vm,
@@ -79,15 +78,12 @@ def test_efi_secureboot_enabled_lockdown_state(self, golden_image_fedora_vm_with
7978
@pytest.mark.polarion("CNV-11834")
8079
def test_efi_secureboot_disabled_and_enabled(
8180
self,
82-
admin_client,
8381
golden_image_fedora_vm_with_instance_type,
8482
):
8583
vm = golden_image_fedora_vm_with_instance_type
8684

8785
def _update_and_verify_secure_boot(vm, secure_boot_value):
8886
update_vm_efi_spec_and_restart(vm=vm, spec={"secureBoot": secure_boot_value})
89-
# assert vm config at hypervisor level
90-
assert_vm_xml_efi(vm=vm, admin_client=admin_client, secure_boot_enabled=secure_boot_value)
9187
assert_linux_efi(vm=vm)
9288

9389
# Disable secureboot

tests/infrastructure/instance_types/supported_os/test_rhel_os.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from utilities.constants import PREFERENCE_STR, U1_MEDIUM_STR
1414
from utilities.virt import (
1515
assert_linux_efi,
16-
assert_vm_xml_efi,
1716
check_qemu_guest_agent_installed,
1817
check_vm_xml_smbios,
1918
migrate_vm_and_verify,
@@ -101,15 +100,12 @@ def test_efi_secureboot_enabled_lockdown_state(self, golden_image_rhel_vm_with_i
101100
@pytest.mark.polarion("CNV-11834")
102101
def test_efi_secureboot_disabled_and_enabled(
103102
self,
104-
admin_client,
105103
golden_image_rhel_vm_with_instance_type,
106104
):
107105
vm = golden_image_rhel_vm_with_instance_type
108106

109107
def _update_and_verify_secure_boot(vm, secure_boot_value):
110108
update_vm_efi_spec_and_restart(vm=vm, spec={"secureBoot": secure_boot_value})
111-
# assert vm config at hypervisor level
112-
assert_vm_xml_efi(vm=vm, admin_client=admin_client, secure_boot_enabled=secure_boot_value)
113109
assert_linux_efi(vm=vm)
114110

115111
# Disable secureboot

tests/virt/cluster/common_templates/fedora/test_fedora_os_support.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from utilities.infra import validate_os_info_vmi_vs_linux_os
2121
from utilities.virt import (
2222
assert_linux_efi,
23-
assert_vm_xml_efi,
2423
migrate_vm_and_verify,
2524
running_vm,
2625
validate_libvirt_persistent_domain,
@@ -132,8 +131,7 @@ def test_os_version(self, matrix_fedora_os_vm_from_template):
132131
@pytest.mark.sno
133132
@pytest.mark.dependency(depends=[f"{TESTS_CLASS_NAME}::start_vm"])
134133
@pytest.mark.polarion("CNV-9666")
135-
def test_efi_secureboot_enabled_by_default(self, admin_client, matrix_fedora_os_vm_from_template):
136-
assert_vm_xml_efi(vm=matrix_fedora_os_vm_from_template, admin_client=admin_client)
134+
def test_efi_secureboot_enabled_by_default(self, matrix_fedora_os_vm_from_template):
137135
assert_linux_efi(vm=matrix_fedora_os_vm_from_template)
138136

139137
@pytest.mark.sno

tests/virt/cluster/common_templates/rhel/test_rhel_os_support.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from utilities.infra import validate_os_info_vmi_vs_linux_os
1919
from utilities.virt import (
2020
assert_linux_efi,
21-
assert_vm_xml_efi,
21+
assert_secureboot_disabled,
2222
check_qemu_guest_agent_installed,
2323
check_vm_xml_smbios,
2424
migrate_vm_and_verify,
@@ -61,7 +61,6 @@ def test_create_vm(self, matrix_rhel_os_vm_from_template):
6161
@pytest.mark.polarion("CNV-3266")
6262
def test_start_vm(self, matrix_rhel_os_vm_from_template):
6363
"""Test CNV common templates VM initiation"""
64-
6564
running_vm(vm=matrix_rhel_os_vm_from_template)
6665

6766
@pytest.mark.arm64
@@ -88,10 +87,9 @@ def test_os_version(self, matrix_rhel_os_vm_from_template):
8887
@pytest.mark.dependency(depends=[f"{TESTS_CLASS_NAME}::start_vm"])
8988
@pytest.mark.polarion("CNV-8712")
9089
@pytest.mark.usefixtures("xfail_on_rhel_version_below_rhel9")
91-
def test_efi_secureboot_enabled_by_default(self, admin_client, matrix_rhel_os_vm_from_template):
90+
def test_efi_secureboot_enabled_by_default(self, matrix_rhel_os_vm_from_template):
9291
"""Test CNV common templates EFI secureboot status"""
9392

94-
assert_vm_xml_efi(vm=matrix_rhel_os_vm_from_template, admin_client=admin_client)
9593
assert_linux_efi(vm=matrix_rhel_os_vm_from_template)
9694

9795
@pytest.mark.arm64
@@ -224,7 +222,7 @@ def test_vmi_guest_agent_info_after_guest_reboot(self, matrix_rhel_os_vm_from_te
224222
def test_efi_secureboot_disabled(self, admin_client, matrix_rhel_os_vm_from_template):
225223
vm = matrix_rhel_os_vm_from_template
226224
update_vm_efi_spec_and_restart(vm=vm, spec={"secureBoot": False})
227-
assert_vm_xml_efi(vm=vm, admin_client=admin_client, secure_boot_enabled=False)
225+
assert_secureboot_disabled(vm=vm, admin_client=admin_client)
228226
assert_linux_efi(vm=vm)
229227

230228
@pytest.mark.arm64

tests/virt/cluster/common_templates/windows/test_windows_os_support.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from utilities.guest_support import assert_windows_efi, check_vm_xml_hyperv, check_windows_vm_hvinfo
1818
from utilities.ssp import validate_os_info_vmi_vs_windows_os
1919
from utilities.virt import (
20-
assert_vm_xml_efi,
2120
check_vm_xml_smbios,
2221
migrate_vm_and_verify,
2322
running_vm,
@@ -58,10 +57,9 @@ def test_start_vm(self, matrix_windows_os_vm_from_template):
5857
@pytest.mark.sno
5958
@pytest.mark.dependency(depends=[f"{TESTS_CLASS_NAME}::start_vm"])
6059
@pytest.mark.polarion("CNV-8854")
61-
def test_efi_secureboot_enabled_by_default(self, admin_client, matrix_windows_os_vm_from_template):
60+
def test_efi_secureboot_enabled_by_default(self, matrix_windows_os_vm_from_template):
6261
"""Test CNV common templates EFI secureboot status"""
6362

64-
assert_vm_xml_efi(vm=matrix_windows_os_vm_from_template, admin_client=admin_client)
6563
assert_windows_efi(vm=matrix_windows_os_vm_from_template)
6664

6765
@pytest.mark.sno

utilities/virt.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,6 +2574,20 @@ def assert_linux_efi(vm: VirtualMachineForTests) -> None:
25742574
return run_ssh_commands(host=vm.ssh_exec, commands=shlex.split("ls -ld /sys/firmware/efi"))[0]
25752575

25762576

2577+
def assert_secureboot_disabled(vm: VirtualMachineForTests, admin_client: DynamicClient) -> None:
2578+
LOGGER.info("Verify VM XML - EFI secureBoot is disabled.")
2579+
xml_dict_os = vm.vmi.get_xml_dict(privileged_client=admin_client)["domain"]["os"]
2580+
vmi_xml_os_secure = xml_dict_os["loader"]["@secure"]
2581+
vmi_xml_efi_vars_path = xml_dict_os["nvram"]["@template"]
2582+
expected_vars_path = "/usr/share/OVMF/OVMF_VARS.fd"
2583+
assert vmi_xml_os_secure == "no", (
2584+
f"EFI secure value {vmi_xml_os_secure} is not set to 'no' — Secure Boot is not disabled"
2585+
)
2586+
assert vmi_xml_efi_vars_path == expected_vars_path, (
2587+
f"EFIVarsPath {vmi_xml_efi_vars_path} does not match expected {expected_vars_path}"
2588+
)
2589+
2590+
25772591
def pause_unpause_vm_and_check_connectivity(vm: VirtualMachineForTests) -> None:
25782592
vm.vmi.pause(wait=True)
25792593
vm.vmi.unpause(wait=True)
@@ -2615,29 +2629,6 @@ def check_vm_xml_smbios(vm: VirtualMachineForTests, cm_values: Dict[str, str], a
26152629
assert all(results.values())
26162630

26172631

2618-
def assert_vm_xml_efi(
2619-
vm: VirtualMachineForTests, admin_client: DynamicClient, *, secure_boot_enabled: bool = True
2620-
) -> None:
2621-
LOGGER.info("Verify VM XML - EFI secureBoot values.")
2622-
xml_dict_os = vm.vmi.get_xml_dict(privileged_client=admin_client)["domain"]["os"]
2623-
ovmf_path = "/usr/share/OVMF"
2624-
efi_path = f"{ovmf_path}/OVMF_CODE.secboot.fd"
2625-
# efi vars path when secure boot is enabled: /usr/share/OVMF/OVMF_VARS.secboot.fd
2626-
# efi vars path when secure boot is disabled: /usr/share/OVMF/OVMF_VARS.fd
2627-
efi_vars_path = f"{ovmf_path}/OVMF_VARS.{'secboot.' if secure_boot_enabled else ''}fd"
2628-
vmi_xml_efi_path = xml_dict_os["loader"]["#text"]
2629-
vmi_xml_efi_vars_path = xml_dict_os["nvram"]["@template"]
2630-
vmi_xml_os_secure = xml_dict_os["loader"]["@secure"]
2631-
os_secure = "yes" if secure_boot_enabled else "no"
2632-
assert vmi_xml_efi_path == efi_path, f"EFIPath value {vmi_xml_efi_path} does not match expected {efi_path} value"
2633-
assert vmi_xml_os_secure == os_secure, (
2634-
f"EFI secure value {vmi_xml_os_secure} does not seem to be set as {os_secure}"
2635-
)
2636-
assert vmi_xml_efi_vars_path == efi_vars_path, (
2637-
f"EFIVarsPath value {vmi_xml_efi_vars_path} does not match expected {efi_vars_path} value"
2638-
)
2639-
2640-
26412632
def update_vm_efi_spec_and_restart(
26422633
vm: VirtualMachineForTests, spec: dict[str, Any] | None = None, wait_for_interfaces: bool = True
26432634
) -> None:

0 commit comments

Comments
 (0)