Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions tests/storage/cdi_clone/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from ocp_resources.datavolume import DataVolume

from tests.storage.constants import QUAY_FEDORA_CONTAINER_IMAGE
from utilities.constants import REGISTRY_STR, Images
from utilities.storage import create_dv, data_volume
from utilities.constants import REGISTRY_STR, TIMEOUT_40MIN, WIN_2K22, Images

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Execution Plan

  • Run smoke tests: False. The only smoke test in tests/storage/cdi_clone/test_clone.py uses the Fedora block-volume fixture. It does not request cloned_windows_dv_multi_storage_scope_class. The new session fixture is not autouse.
  • Run gating tests: False. The gated CDI Clone test uses the Fedora DataSource fixture. The gated Hotplug classes use fedora_vm_for_hotplug_scope_class. Neither fixture chain reaches the Windows session fixture or construct_datavolume_source_dict.

Affected tests to run

  • tests/storage/cdi_clone/test_clone.py::TestWindowsClonedDv::test_clone_dv_windows (tier3)
  • tests/storage/cdi_clone/test_clone.py::TestWindowsClonedDv::test_vm_from_cloned_dv_windows (tier3)
  • tests/storage/test_hotplug.py::TestHotPlugWindows::test_windows_hotplug (tier3)
  • tests/storage/test_hotplug.py::TestHotPlugWindows::test_windows_hotplug_migrate (tier3)

Dependency paths:

  • TestWindowsClonedDvcloned_windows_dv_multi_storage_scope_classwindows_validation_os_images_data_source_scope_sessionwindows_validation_os_images_data_volume_scope_sessionconstruct_datavolume_source_dict.
  • TestHotPlugWindowshotplug_volume_windows_scope_classvm_instance_multi_storage_scope_classwindows_validation_os_images_data_source_scope_sessionwindows_validation_os_images_data_volume_scope_sessionconstruct_datavolume_source_dict.

Real tests (cluster required)

Error path: With no win2k22 DataVolume in validation-os-images, run:

pytest tests/storage/cdi_clone/test_clone.py::TestWindowsClonedDv::test_clone_dv_windows -m "tier3 or conformance"

Expected: fixture setup fails with the explicit pre-created-image assertion. It must not import the image.

Happy path: With a valid default storage class and no win2k22 DataVolume, run:

pytest tests/storage/cdi_clone/test_clone.py::TestWindowsClonedDv::test_clone_dv_windows tests/storage/cdi_clone/test_clone.py::TestWindowsClonedDv::test_vm_from_cloned_dv_windows tests/storage/test_hotplug.py::TestHotPlugWindows

Expected: the session fixture imports the image once, creates the DataSource, and both clone and hotplug workflows complete. Repeat with an existing succeeded win2k22 DataVolume to verify reuse.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This thread was automatically unresolved because it was resolved without a substantive response. Please address the review comment and explain how it was resolved before resolving this thread again.

from utilities.storage import create_dv, data_volume, get_dv_size_from_datasource


@pytest.fixture()
Expand Down Expand Up @@ -59,3 +59,26 @@ def fedora_dv_with_block_volume_mode(
) as dv:
dv.wait_for_dv_success()
yield dv


@pytest.fixture(scope="class")
def cloned_windows_dv_multi_storage_scope_class(
unprivileged_client,
namespace,
storage_class_name_scope_class,
windows_validation_os_images_data_source_scope_session,
):
with create_dv(
client=unprivileged_client,
dv_name=f"dv-target-{WIN_2K22}-clone",
namespace=namespace.name,
size=get_dv_size_from_datasource(windows_validation_os_images_data_source_scope_session),
storage_class=storage_class_name_scope_class,
source_ref={
"kind": windows_validation_os_images_data_source_scope_session.kind,
"name": windows_validation_os_images_data_source_scope_session.name,
"namespace": windows_validation_os_images_data_source_scope_session.namespace,
},
) as cdv:
cdv.wait_for_dv_success(timeout=TIMEOUT_40MIN)
yield cdv
141 changes: 62 additions & 79 deletions tests/storage/cdi_clone/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
import pytest
from ocp_resources.datavolume import DataVolume

from tests.os_params import FEDORA_LATEST, WINDOWS_11, WINDOWS_11_TEMPLATE_LABELS
from tests.os_params import FEDORA_LATEST
from tests.storage.utils import (
assert_pvc_snapshot_clone_annotation,
assert_use_populator,
create_windows_vm_validate_guest_agent_info,
)
from tests.utils import create_windows2022_vm_using_existing_dv
from utilities.constants import (
OS_FLAVOR_FEDORA,
OS_FLAVOR_WINDOWS,
TIMEOUT_1MIN,
TIMEOUT_40MIN,
WIN_2K22,
Images,
)
from utilities.ssp import validate_os_info_vmi_vs_windows_os
from utilities.storage import (
check_disk_count_in_vm,
create_dv,
Expand All @@ -33,8 +34,6 @@
running_vm,
)

WINDOWS_CLONE_TIMEOUT = TIMEOUT_40MIN


def create_vm_from_clone_dv_template(
vm_name,
Expand Down Expand Up @@ -64,38 +63,6 @@ def create_vm_from_clone_dv_template(
running_vm(vm=vm)


@pytest.mark.tier3
@pytest.mark.parametrize(
"data_volume_multi_storage_scope_function",
[
pytest.param(
{
"dv_name": "dv-source",
"image": f"{Images.Windows.DIR}/{Images.Windows.WIN11_IMG}",
"dv_size": Images.Windows.DEFAULT_DV_SIZE,
},
marks=(pytest.mark.polarion("CNV-1892")),
),
],
indirect=True,
)
@pytest.mark.s390x
def test_successful_clone_of_large_image(
namespace,
data_volume_multi_storage_scope_function,
):
with create_dv(
source="pvc",
dv_name="dv-target",
namespace=namespace.name,
size=data_volume_multi_storage_scope_function.size,
source_pvc=data_volume_multi_storage_scope_function.name,
storage_class=data_volume_multi_storage_scope_function.storage_class,
client=namespace.client,
) as cdv:
cdv.wait_for_dv_success(timeout=WINDOWS_CLONE_TIMEOUT)


@pytest.mark.sno
@pytest.mark.polarion("CNV-2148")
@pytest.mark.gating()
Expand Down Expand Up @@ -144,50 +111,66 @@ def test_successful_vm_restart_with_cloned_dv(


@pytest.mark.tier3
@pytest.mark.parametrize(
("data_volume_multi_storage_scope_function", "vm_params"),
[
pytest.param(
{
"dv_name": "dv-source",
"source": "http",
"image": f"{Images.Windows.DIR}/{Images.Windows.WIN11_IMG}",
"dv_size": Images.Windows.DEFAULT_DV_SIZE,
},
{
"vm_name": f"vm-win-{WINDOWS_11.get('os_version')}",
"template_labels": WINDOWS_11_TEMPLATE_LABELS,
"os_version": WINDOWS_11.get("os_version"),
"ssh": True,
},
marks=pytest.mark.polarion("CNV-3638"),
),
],
indirect=["data_volume_multi_storage_scope_function"],
)
def test_successful_vm_from_cloned_dv_windows(
unprivileged_client,
data_volume_multi_storage_scope_function,
vm_params,
namespace,
):
with create_dv(
client=unprivileged_client,
source="pvc",
dv_name="dv-target",
namespace=data_volume_multi_storage_scope_function.namespace,
size=data_volume_multi_storage_scope_function.size,
source_pvc=data_volume_multi_storage_scope_function.name,
storage_class=data_volume_multi_storage_scope_function.storage_class,
) as cdv:
cdv.wait_for_dv_success(timeout=WINDOWS_CLONE_TIMEOUT)
create_windows_vm_validate_guest_agent_info(
dv=cdv,
namespace=namespace,
unprivileged_client=unprivileged_client,
vm_params=vm_params,
@pytest.mark.incremental
class TestWindowsClonedDv:
"""
Tests for Windows 2022 DV cloning, and VM creation with vTPM.

Preconditions:
- Windows Server 2022 DataVolume
- Cloned DataVolume created from the source DataVolume (PVC clone)
"""

@pytest.mark.polarion("CNV-1892")
def test_clone_dv_windows(self, cloned_windows_dv_multi_storage_scope_class):
"""
Test that a large image can be cloned.

Preconditions:
- Cloned DataVolume created from the source DataVolume (PVC clone)

Steps:
1. Verify the cloned DataVolume status

Expected:
- Cloned DataVolume status is "Succeeded"
"""
assert cloned_windows_dv_multi_storage_scope_class.status == DataVolume.Status.SUCCEEDED, (
f"Cloned DV status is {cloned_windows_dv_multi_storage_scope_class.status},"
f" expected {DataVolume.Status.SUCCEEDED}"
)

@pytest.mark.polarion("CNV-3638")
def test_vm_from_cloned_dv_windows(
self,
unprivileged_client,
namespace,
modern_cpu_for_migration,
cloned_windows_dv_multi_storage_scope_class,
):
"""
Test that a Windows 2022 VM with vTPM boots from a cloned DataVolume.

Preconditions:
- Cloned DataVolume created from the source DataVolume (PVC clone)

Steps:
1. Create a Windows 2022 VM with vTPM from the cloned DataVolume using instance type and preference
2. Wait for the VM to reach Running state
3. Wait for Windows OS to be ready inside the VM

Expected:
- VM OS info reported by VMI matches the expected Windows OS parameters
"""
with create_windows2022_vm_using_existing_dv(
namespace=namespace.name,
client=unprivileged_client,
vm_name=f"vm-{WIN_2K22}",
cpu_model=modern_cpu_for_migration,
existing_data_volume=cloned_windows_dv_multi_storage_scope_class,
) as vm:
validate_os_info_vmi_vs_windows_os(vm=vm)


@pytest.mark.parametrize(
"data_volume_snapshot_capable_storage_scope_function",
Expand Down
Loading