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
23 changes: 14 additions & 9 deletions tests/storage/cdi_clone/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import pytest
from ocp_resources.datavolume import DataVolume

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.

For the sig-storage PRs, please start the PR title with [Storage] ...
For example:
[Storage] Add conformance test: clone VM with 4-disks


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
Expand All @@ -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,
Expand All @@ -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,
Expand Down
45 changes: 8 additions & 37 deletions tests/storage/cdi_clone/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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(
Comment on lines 221 to 234

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 is a smoke test, and this PR is changing the test completely.
Is there a reason/requirement to have a VM with 4 disks in smoke tests?

Please create a new, separate test that is required for the conformance.
Please add a proper test description to the new test.
(when I hear "clone a VM with 4 disks" - I imagine a VM with four disks passed to the VirtualMachineClone, so I want to understand what we are trying to do here)

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,
),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
storage_class=storage_class_with_filesystem_volume_mode,
Expand Down
47 changes: 47 additions & 0 deletions tests/storage/cdi_clone/utils.py
Original file line number Diff line number Diff line change
@@ -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.
"""
Comment thread
coderabbitai[bot] marked this conversation as resolved.
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)