diff --git a/tests/storage/memory_dump/conftest.py b/tests/storage/memory_dump/conftest.py index 0c3f00d8dd..ecadbe007b 100644 --- a/tests/storage/memory_dump/conftest.py +++ b/tests/storage/memory_dump/conftest.py @@ -7,26 +7,34 @@ from ocp_resources.persistent_volume_claim import PersistentVolumeClaim from tests.storage.memory_dump.utils import wait_for_memory_dump_status_completed +from tests.utils import create_windows2022_vm_with_data_volume_template from utilities.constants import Images from utilities.constants.timeouts import TIMEOUT_2MIN -from utilities.storage import PodWithPVC, get_containers_for_pods_with_pvc, virtctl_memory_dump -from utilities.virt import running_vm, vm_instance_from_template +from utilities.constants.virt import WIN_2K22 +from utilities.storage import ( + PodWithPVC, + data_volume_template_with_source_ref_dict, + get_containers_for_pods_with_pvc, + virtctl_memory_dump, +) @pytest.fixture() -def windows_vm_for_memory_dump( - request, +def windows_vm_with_vtpm_for_memory_dump( unprivileged_client, namespace, - golden_image_data_source_scope_function, + modern_cpu_for_migration, + windows_validation_os_images_data_source_scope_session, ): - with vm_instance_from_template( - request=request, - unprivileged_client=unprivileged_client, - namespace=namespace, - data_source=golden_image_data_source_scope_function, + with create_windows2022_vm_with_data_volume_template( + dv_template=data_volume_template_with_source_ref_dict( + data_source=windows_validation_os_images_data_source_scope_session, + ), + namespace=namespace.name, + client=unprivileged_client, + vm_name=f"vm-{WIN_2K22}-memory-dump", + cpu_model=modern_cpu_for_migration, ) as vm: - running_vm(vm=vm) yield vm @@ -50,11 +58,11 @@ def pvc_for_windows_memory_dump(unprivileged_client, namespace, storage_class_wi @pytest.fixture() -def windows_vm_memory_dump(namespace, windows_vm_for_memory_dump, pvc_for_windows_memory_dump): +def windows_vm_memory_dump(namespace, windows_vm_with_vtpm_for_memory_dump, pvc_for_windows_memory_dump): status, out, err = virtctl_memory_dump( action="get", namespace=namespace.name, - vm_name=windows_vm_for_memory_dump.name, + vm_name=windows_vm_with_vtpm_for_memory_dump.name, claim_name=pvc_for_windows_memory_dump.name, ) assert status, f"Failed to get memory dump, out: {out}, err: {err}." @@ -62,12 +70,14 @@ def windows_vm_memory_dump(namespace, windows_vm_for_memory_dump, pvc_for_window @pytest.fixture() -def windows_vm_memory_dump_completed(windows_vm_for_memory_dump): - wait_for_memory_dump_status_completed(vm=windows_vm_for_memory_dump) +def windows_vm_memory_dump_completed(windows_vm_with_vtpm_for_memory_dump): + wait_for_memory_dump_status_completed(vm=windows_vm_with_vtpm_for_memory_dump) @pytest.fixture() -def consumer_pod_for_verifying_windows_memory_dump(namespace, windows_vm_for_memory_dump, pvc_for_windows_memory_dump): +def consumer_pod_for_verifying_windows_memory_dump( + namespace, windows_vm_with_vtpm_for_memory_dump, pvc_for_windows_memory_dump +): with PodWithPVC( namespace=namespace.name, name="consumer-pod", @@ -80,18 +90,18 @@ def consumer_pod_for_verifying_windows_memory_dump(namespace, windows_vm_for_mem pod.wait_for_status(status=pod.Status.RUNNING, timeout=TIMEOUT_2MIN) assert re.match( - rf"{windows_vm_for_memory_dump.name}-{pvc_for_windows_memory_dump.name}-\d*-\d*.memory.dump", + rf"{windows_vm_with_vtpm_for_memory_dump.name}-{pvc_for_windows_memory_dump.name}-\d*-\d*.memory.dump", pod.execute(command=shlex.split("bash -c 'ls -1 /pvc | grep dump'")), re.IGNORECASE, ), "Memory dump file doesn't exist" @pytest.fixture() -def windows_vm_memory_dump_deletion(namespace, windows_vm_for_memory_dump): +def windows_vm_memory_dump_deletion(namespace, windows_vm_with_vtpm_for_memory_dump): status, out, err = virtctl_memory_dump( action="remove", namespace=namespace.name, - vm_name=windows_vm_for_memory_dump.name, + vm_name=windows_vm_with_vtpm_for_memory_dump.name, ) assert status, f"Failed to remove memory dump, out: {out}, err: {err}." yield diff --git a/tests/storage/memory_dump/test_memory_dump.py b/tests/storage/memory_dump/test_memory_dump.py index 5d71061236..eabc712966 100644 --- a/tests/storage/memory_dump/test_memory_dump.py +++ b/tests/storage/memory_dump/test_memory_dump.py @@ -3,39 +3,19 @@ """ import pytest -from pytest_testconfig import config as py_config -from tests.os_params import WINDOWS_LATEST, WINDOWS_LATEST_LABELS from tests.storage.memory_dump.utils import wait_for_memory_dump_status_removed @pytest.mark.tier3 -@pytest.mark.parametrize( - "golden_image_data_volume_scope_function, windows_vm_for_memory_dump", - [ - pytest.param( - { - "dv_name": "dv-windows", - "image": WINDOWS_LATEST.get("image_path"), - "storage_class": py_config["default_storage_class"], - "dv_size": WINDOWS_LATEST.get("dv_size"), - }, - { - "vm_name": "windows-vm-mem", - "template_labels": WINDOWS_LATEST_LABELS, - }, - marks=pytest.mark.polarion("CNV-8518"), - ), - ], - indirect=True, -) +@pytest.mark.polarion("CNV-8518") def test_windows_memory_dump( namespace, - windows_vm_for_memory_dump, + windows_vm_with_vtpm_for_memory_dump, pvc_for_windows_memory_dump, windows_vm_memory_dump, windows_vm_memory_dump_completed, consumer_pod_for_verifying_windows_memory_dump, windows_vm_memory_dump_deletion, ): - wait_for_memory_dump_status_removed(vm=windows_vm_for_memory_dump) + wait_for_memory_dump_status_removed(vm=windows_vm_with_vtpm_for_memory_dump)