Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Comment thread
acinko-rh marked this conversation as resolved.
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