Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3cef639
add `create_windows_vm_with_vtpm_validate_guest_agent_info` function
acinko-rh Apr 24, 2026
7a5f86a
fix the polarion mark
acinko-rh Apr 27, 2026
46a43ce
add source dv Windows from registry
acinko-rh Apr 28, 2026
5b05587
fix `wait_for_windows_vm` version string
acinko-rh Apr 28, 2026
c711566
remove `verify_vtpm_in_windows_vm` from storage utils
acinko-rh Apr 28, 2026
3f2d778
cleanup constants and imports
acinko-rh Apr 28, 2026
7d7914a
fix fixture names
acinko-rh Apr 28, 2026
1b94a4b
fix fixture name in `cloned_windows_dv_from_registry_scope_function`
acinko-rh Apr 29, 2026
c743ba3
remove `WINDOWS_CLONE_TIMEOUT` as per reviewer's suggestion
acinko-rh Apr 29, 2026
5c56e47
fix DV cloning
acinko-rh May 4, 2026
37da3f6
add artifactory secret and config_map cleanup
acinko-rh May 6, 2026
5358edd
clean up artifactory
acinko-rh May 18, 2026
20fc6ee
use the helper functions from `tests/utils.py` merged earlier
acinko-rh May 21, 2026
37beb5b
change timeout to 40 minutes
acinko-rh May 22, 2026
706fd71
replace generic timeout with windows clone specific one
acinko-rh May 22, 2026
c39a16f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2026
b6e402f
remove duplicate constant
acinko-rh May 22, 2026
79553be
use `create_dv` to handle WFFC better
acinko-rh May 22, 2026
8f95979
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 2, 2026
b939af4
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 2, 2026
daa51e0
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 4, 2026
ec1cb79
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 9, 2026
be98715
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 10, 2026
9115620
use CDV directly instead of a template
acinko-rh Jun 10, 2026
0c87b1c
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 10, 2026
20886d9
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 12, 2026
16679bd
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 16, 2026
b7faa5c
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 16, 2026
22e2e26
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 17, 2026
9885737
Merge branch 'main' into add_vtpm_to_cdi_clone
acinko-rh Jun 17, 2026
a8b6a72
apply reviewer's suggestions
acinko-rh Jun 22, 2026
faab71e
consume when wffc is present
acinko-rh Jun 22, 2026
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
45 changes: 43 additions & 2 deletions tests/storage/cdi_clone/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import pytest
from ocp_resources.datavolume import DataVolume

from tests.storage.cdi_clone.constants import WINDOWS_CLONE_TIMEOUT
from tests.storage.constants import QUAY_FEDORA_CONTAINER_IMAGE
Comment thread
coderabbitai[bot] marked this conversation as resolved.
from utilities.constants import REGISTRY_STR, Images
from utilities.storage import create_dv, data_volume
from tests.utils import create_windows2022_dv_from_registry
from utilities.constants import REGISTRY_STR, WIN_2K22, Images
from utilities.storage import create_dummy_first_consumer_pod, create_dv, data_volume, sc_volume_binding_mode_is_wffc


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


@pytest.fixture(scope="class")
def source_dv_windows_registry_scope_class(
unprivileged_client,
namespace,
storage_class_name_scope_class,
):
"""Fixture that creates a Windows 2022 DataVolume from registry."""
with create_windows2022_dv_from_registry(
dv_name=f"dv-source-{WIN_2K22}-registry",
namespace=namespace.name,
client=unprivileged_client,
storage_class=storage_class_name_scope_class,
) as dv:
if sc_volume_binding_mode_is_wffc(sc=storage_class_name_scope_class, client=unprivileged_client):
create_dummy_first_consumer_pod(dv=dv)
dv.wait_for_dv_success(timeout=WINDOWS_CLONE_TIMEOUT)
yield dv


@pytest.fixture(scope="class")
def cloned_windows_dv_scope_class(
unprivileged_client,
source_dv_windows_registry_scope_class,
):
"""Fixture that creates a cloned DataVolume from registry source."""
source_dv_spec = source_dv_windows_registry_scope_class.instance.spec
with create_dv(
client=unprivileged_client,
source="pvc",
dv_name=f"dv-target-{WIN_2K22}-clone",
namespace=source_dv_windows_registry_scope_class.namespace,
size=Images.Windows.CONTAINER_DISK_DV_SIZE,
source_pvc=source_dv_windows_registry_scope_class.name,
storage_class=source_dv_spec.storage.storageClassName,
) as cdv:
cdv.wait_for_dv_success(timeout=WINDOWS_CLONE_TIMEOUT)
yield cdv
7 changes: 7 additions & 0 deletions tests/storage/cdi_clone/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Constants for CDI clone tests.
"""

from utilities.constants import TIMEOUT_40MIN

WINDOWS_CLONE_TIMEOUT = TIMEOUT_40MIN
140 changes: 61 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_from_dv_with_vtpm
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,65 @@ 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 from registry and VM creation with vTPM.

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

@pytest.mark.polarion("CNV-1892")
def test_clone_dv_windows(self, cloned_windows_dv_scope_class):
"""
Test that a Windows 2022 DataVolume can be cloned from a registry source.

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_scope_class.status == DataVolume.Status.SUCCEEDED, (
f"Cloned DV status is {cloned_windows_dv_scope_class.status}, 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_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_from_dv_with_vtpm(
dv=cloned_windows_dv_scope_class,
namespace=namespace.name,
client=unprivileged_client,
vm_name=f"vm-{WIN_2K22}",
cpu_model=modern_cpu_for_migration,
) as vm:
validate_os_info_vmi_vs_windows_os(vm=vm)


@pytest.mark.parametrize(
"data_volume_snapshot_capable_storage_scope_function",
Expand Down
11 changes: 9 additions & 2 deletions tests/storage/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
is_hpp_cr_legacy,
)
from tests.utils import create_cirros_vm
from utilities.artifactory import get_artifactory_config_map, get_artifactory_secret
from utilities.artifactory import (
get_artifactory_config_map,
get_artifactory_secret,
)
from utilities.constants import (
CDI_OPERATOR,
CDI_UPLOADPROXY,
Expand All @@ -66,7 +69,11 @@
INTERNAL_HTTP_SERVER_ADDRESS,
ExecCommandOnPod,
)
from utilities.storage import data_volume_template_with_source_ref_dict, get_downloaded_artifact, write_file_via_ssh
from utilities.storage import (
data_volume_template_with_source_ref_dict,
get_downloaded_artifact,
write_file_via_ssh,
)
from utilities.virt import VirtualMachineForTests, running_vm

LOGGER = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions tests/storage/test_hotplug.py
Comment thread
acinko-rh marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ocp_resources.storage_profile import StorageProfile

from tests.storage.utils import assert_disk_bus
from tests.utils import create_windows2022_dv_from_registry, create_windows2022_vm_with_vtpm_from_registry
from tests.utils import create_windows2022_dv_template_from_registry, create_windows2022_vm_from_template_with_vtpm
from utilities.constants import HOTPLUG_DISK_SCSI_BUS, HOTPLUG_DISK_SERIAL, HOTPLUG_DISK_VIRTIO_BUS, Images
from utilities.hco import ResourceEditorValidateHCOReconcile
from utilities.jira import is_jira_open
Expand Down Expand Up @@ -78,7 +78,7 @@ def windows_dv_from_registry_scope_class(
storage_class_matrix__class__,
):
"""Creates a Windows 2022 DataVolume from registry container disk."""
with create_windows2022_dv_from_registry(
with create_windows2022_dv_template_from_registry(
dv_name="dv-windows-2022-hotplug",
namespace=namespace.name,
client=unprivileged_client,
Expand All @@ -95,8 +95,8 @@ def vm_instance_from_template_multi_storage_scope_class(
windows_dv_from_registry_scope_class,
):
"""Creates a Windows 2022 VM with vTPM from registry container disk."""
with create_windows2022_vm_with_vtpm_from_registry(
dv_dict=windows_dv_from_registry_scope_class,
with create_windows2022_vm_from_template_with_vtpm(
dv_template=windows_dv_from_registry_scope_class,
namespace=namespace.name,
client=unprivileged_client,
vm_name="vm-win-2022-hotplug",
Expand Down
Loading