diff --git a/tests/storage/cdi_clone/conftest.py b/tests/storage/cdi_clone/conftest.py index 1a8db95d28..e2aa0a8bd1 100644 --- a/tests/storage/cdi_clone/conftest.py +++ b/tests/storage/cdi_clone/conftest.py @@ -1,9 +1,6 @@ import pytest from ocp_resources.datavolume import DataVolume -from tests.storage.constants import QUAY_FEDORA_CONTAINER_IMAGE -from utilities.constants import Images -from utilities.constants.storage import REGISTRY_STR from utilities.constants.timeouts import TIMEOUT_40MIN from utilities.constants.virt import WIN_2K22 from utilities.storage import create_dv, data_volume, get_dv_size_from_datasource @@ -28,14 +25,18 @@ def data_volume_snapshot_capable_storage_scope_function( def fedora_dv_with_filesystem_volume_mode( unprivileged_client, namespace, + fedora_data_source_scope_module, storage_class_with_filesystem_volume_mode, ): with create_dv( dv_name="dv-fedora-fs", namespace=namespace.name, - source=REGISTRY_STR, - url=QUAY_FEDORA_CONTAINER_IMAGE, - size=Images.Fedora.DEFAULT_DV_SIZE, + source_ref={ + "kind": fedora_data_source_scope_module.kind, + "name": fedora_data_source_scope_module.name, + "namespace": fedora_data_source_scope_module.namespace, + }, + size=get_dv_size_from_datasource(data_source=fedora_data_source_scope_module), storage_class=storage_class_with_filesystem_volume_mode, volume_mode=DataVolume.VolumeMode.FILE, client=unprivileged_client, @@ -48,14 +49,18 @@ def fedora_dv_with_filesystem_volume_mode( def fedora_dv_with_block_volume_mode( unprivileged_client, namespace, + fedora_data_source_scope_module, storage_class_with_block_volume_mode, ): with create_dv( dv_name="dv-fedora-block", namespace=namespace.name, - source=REGISTRY_STR, - url=QUAY_FEDORA_CONTAINER_IMAGE, - size=Images.Fedora.DEFAULT_DV_SIZE, + source_ref={ + "kind": fedora_data_source_scope_module.kind, + "name": fedora_data_source_scope_module.name, + "namespace": fedora_data_source_scope_module.namespace, + }, + size=get_dv_size_from_datasource(data_source=fedora_data_source_scope_module), storage_class=storage_class_with_block_volume_mode, volume_mode=DataVolume.VolumeMode.BLOCK, client=unprivileged_client, diff --git a/tests/storage/cdi_clone/test_clone.py b/tests/storage/cdi_clone/test_clone.py index b2e9aa9f54..fb5f49db68 100644 --- a/tests/storage/cdi_clone/test_clone.py +++ b/tests/storage/cdi_clone/test_clone.py @@ -2,10 +2,12 @@ Clone tests """ +import bitmath import pytest from ocp_resources.datavolume import DataVolume from tests.os_params import FEDORA_LATEST +from tests.storage.cdi_clone.utils import create_vm_from_clone_dv_template from tests.storage.utils import ( assert_pvc_snapshot_clone_annotation, assert_use_populator, @@ -20,44 +22,11 @@ check_disk_count_in_vm, create_dv, create_vm_from_dv, - data_volume_template_dict_with_pvc_source, get_dv_size_from_datasource, overhead_size_for_dv, sc_volume_binding_mode_is_wffc, ) -from utilities.virt import ( - VirtualMachineForTests, - restart_vm_wait_for_running_vm, - running_vm, -) - - -def create_vm_from_clone_dv_template( - vm_name, - dv_name, - namespace_name, - source_dv, - client, - volume_mode, - storage_class, - size=None, -): - with VirtualMachineForTests( - name=vm_name, - namespace=namespace_name, - os_flavor=OS_FLAVOR_FEDORA, - client=client, - memory_guest=Images.Fedora.DEFAULT_MEMORY_SIZE, - data_volume_template=data_volume_template_dict_with_pvc_source( - target_dv_name=dv_name, - target_dv_namespace=namespace_name, - source_dv=source_dv, - volume_mode=volume_mode, - size=size, - storage_class=storage_class, - ), - ) as vm: - running_vm(vm=vm) +from utilities.virt import restart_vm_wait_for_running_vm @pytest.mark.sno @@ -228,6 +197,7 @@ def test_successful_snapshot_clone( @pytest.mark.gating +@pytest.mark.conformance @pytest.mark.polarion("CNV-5607") @pytest.mark.s390x def test_clone_from_fs_to_block_using_dv_template( @@ -248,6 +218,7 @@ def test_clone_from_fs_to_block_using_dv_template( ) +@pytest.mark.conformance @pytest.mark.polarion("CNV-5608") @pytest.mark.smoke() @pytest.mark.s390x @@ -259,16 +230,16 @@ def test_clone_from_block_to_fs_using_dv_template( storage_class_with_filesystem_volume_mode, default_fs_overhead, ): + source_dv = fedora_dv_with_block_volume_mode create_vm_from_clone_dv_template( vm_name="vm-5608", dv_name="dv-5608", namespace_name=namespace.name, - source_dv=fedora_dv_with_block_volume_mode, + source_dv=source_dv, client=unprivileged_client, volume_mode=DataVolume.VolumeMode.FILE, - # add fs overhead and round up the result size=overhead_size_for_dv( - image_size=int(fedora_dv_with_block_volume_mode.size[:-2]), + image_size=bitmath.parse_string(source_dv.size, strict=False).to_GiB().value, overhead_value=default_fs_overhead, ), storage_class=storage_class_with_filesystem_volume_mode, diff --git a/tests/storage/cdi_clone/utils.py b/tests/storage/cdi_clone/utils.py new file mode 100644 index 0000000000..54e808b84c --- /dev/null +++ b/tests/storage/cdi_clone/utils.py @@ -0,0 +1,47 @@ +from utilities.storage import ( + add_dv_to_vm, + check_disk_count_in_vm, + data_volume_template_dict_with_pvc_source, +) +from utilities.virt import VirtualMachineForTests, running_vm + +NUM_CLONE_DISKS = 4 + + +def create_vm_from_clone_dv_template( + vm_name, + dv_name, + namespace_name, + source_dv, + client, + volume_mode, + storage_class, + size=None, +): + """Create a VM with NUM_CLONE_DISKS cloned disks from source_dv and verify all disks are visible. + + DV names are derived as {dv_name}-0, {dv_name}-1, etc. + """ + dv_templates = [ + data_volume_template_dict_with_pvc_source( + target_dv_name=f"{dv_name}-{idx}", + target_dv_namespace=namespace_name, + source_dv=source_dv, + volume_mode=volume_mode, + size=size, + storage_class=storage_class, + ) + for idx in range(NUM_CLONE_DISKS) + ] + with VirtualMachineForTests( + name=vm_name, + namespace=namespace_name, + client=client, + vm_instance_type_infer=True, + vm_preference_infer=True, + data_volume_template=dv_templates[0], + ) as vm: + for template in dv_templates[1:]: + add_dv_to_vm(vm=vm, template_dv=template) + running_vm(vm=vm) + check_disk_count_in_vm(vm=vm)