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
5 changes: 0 additions & 5 deletions tests/storage/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,6 @@ def hpp_daemonset_scope_module(hco_namespace, hpp_cr_suffix_scope_module):
yield get_hpp_daemonset(hco_namespace=hco_namespace, hpp_cr_suffix=hpp_cr_suffix_scope_module)


@pytest.fixture()
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 (No concrete dependency path found between smoke tests and changed code)

Tests to run:

  • tests/storage/online_resize/test_online_resize.py — New test module restructured from deleted test_online_resize.py; verify all new online resize tests pass
  • tests/storage/golden_image/test_cached_snapshots.py — Updated to use data_volume_template_with_source_ref_dict (replacing removed data_volume_dict_modify_to_source_ref); verify snapshot caching tests pass
  • tests/storage/test_wffc.py — Uses data_volume_template_with_source_ref_dict whose internal implementation changed (create_dv now passes source_ref); verify WFFC tests pass

def cirros_vm_name(request):
return request.param["vm_name"]


@pytest.fixture()
def rhel_vm_name(request):
return request.param["vm_name"]
Expand Down
13 changes: 3 additions & 10 deletions tests/storage/golden_image/test_cached_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from utilities.ssp import wait_for_deleted_data_import_crons
from utilities.storage import (
data_volume_dict_modify_to_source_ref,
data_volume_template_with_source_ref_dict,
verify_dv_and_pvc_does_not_exist,
wait_for_succeeded_dv,
wait_for_volume_snapshot_ready_to_use,
Expand Down Expand Up @@ -201,20 +201,13 @@ def rhel9_golden_image_vm(
unprivileged_client,
namespace,
):
dv = DataVolume(
name=f"{RHEL9_STR}-test-vm",
namespace=namespace.name,
size=rhel9_cached_snapshot.instance.status.get("restoreSize"),
storage_class=snapshot_storage_class_name_scope_module,
api_name="storage",
)
with vm_instance_from_template(
request=request,
unprivileged_client=unprivileged_client,
namespace=namespace,
data_volume_template=data_volume_dict_modify_to_source_ref(
dv=dv,
data_volume_template=data_volume_template_with_source_ref_dict(
data_source=rhel9_data_source_scope_module,
storage_class=snapshot_storage_class_name_scope_module,
),
) as vm:
yield vm
Expand Down
Empty file.
96 changes: 96 additions & 0 deletions tests/storage/online_resize/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-

"""
Fixtures for online resize tests
"""

import pytest

from tests.storage.online_resize.utils import (
SMALLEST_POSSIBLE_EXPAND,
STORED_FILENAME,
cksum_file,
create_rhel_dv_from_data_source,
expand_pvc,
wait_for_resize,
)
from utilities.constants import OS_FLAVOR_RHEL, Images
from utilities.storage import create_dv, is_snapshot_supported_by_sc
from utilities.virt import VirtualMachineForTests, running_vm


@pytest.fixture(scope="module")
def xfail_if_storage_for_online_resize_does_not_support_snapshots(
admin_client, storage_class_matrix_online_resize_matrix__module__
):
sc_name = [*storage_class_matrix_online_resize_matrix__module__][0]
if not is_snapshot_supported_by_sc(
sc_name=sc_name,
client=admin_client,
):
pytest.xfail(f"Storage class for online resize '{sc_name}' doesn't support snapshots")


@pytest.fixture()
def orig_cksum(rhel_vm_for_online_resize, running_rhel_vm):
return cksum_file(vm=rhel_vm_for_online_resize, filename=STORED_FILENAME, create=True)


@pytest.fixture()
def rhel_dv_for_online_resize(
request,
namespace,
unprivileged_client,
storage_class_matrix_online_resize_matrix__module__,
rhel10_data_source_scope_module,
):
with create_rhel_dv_from_data_source(
unprivileged_client=unprivileged_client,
namespace=namespace.name,
name=request.param["dv_name"],
storage_class=[*storage_class_matrix_online_resize_matrix__module__][0],
rhel_data_source=rhel10_data_source_scope_module,
) as dv:
yield dv


@pytest.fixture()
def second_rhel_dv_for_online_resize(rhel_dv_for_online_resize, unprivileged_client):
with create_dv(
source="pvc",
dv_name=f"{rhel_dv_for_online_resize.name}-target",
namespace=rhel_dv_for_online_resize.namespace,
client=unprivileged_client,
size=rhel_dv_for_online_resize.size,
storage_class=rhel_dv_for_online_resize.storage_class,
source_pvc=rhel_dv_for_online_resize.name,
) as rhel_dv:
yield rhel_dv


@pytest.fixture()
def rhel_vm_for_online_resize(
request, unprivileged_client, namespace, rhel_dv_for_online_resize, modern_cpu_for_migration
):
with VirtualMachineForTests(
client=unprivileged_client,
name=request.param["vm_name"],
namespace=namespace.name,
data_volume=rhel_dv_for_online_resize,
memory_guest=Images.Rhel.DEFAULT_MEMORY_SIZE,
os_flavor=OS_FLAVOR_RHEL,
cpu_model=modern_cpu_for_migration,
) as vm:
yield vm


@pytest.fixture()
def rhel_vm_after_expand(rhel_dv_for_online_resize, rhel_vm_for_online_resize, running_rhel_vm):
with wait_for_resize(vm=rhel_vm_for_online_resize):
expand_pvc(dv=rhel_dv_for_online_resize, size_change=SMALLEST_POSSIBLE_EXPAND)
return rhel_vm_for_online_resize


@pytest.fixture()
def running_rhel_vm(rhel_vm_for_online_resize):
return running_vm(vm=rhel_vm_for_online_resize)
194 changes: 194 additions & 0 deletions tests/storage/online_resize/test_online_resize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# -*- coding: utf-8 -*-

"""
Online resize (PVC expanded while VM running)
"""

import logging

import pytest
from ocp_resources.datavolume import DataVolume
from timeout_sampler import TimeoutSampler

from tests.storage.online_resize.utils import (
RHEL_DV_SIZE,
SMALLEST_POSSIBLE_EXPAND,
check_file_unchanged,
expand_pvc,
vm_restore,
wait_for_resize,
)
from utilities.constants import TIMEOUT_1MIN, TIMEOUT_4MIN, TIMEOUT_5SEC
from utilities.storage import add_dv_to_vm, create_dv, vm_snapshot
from utilities.virt import migrate_vm_and_verify, running_vm

LOGGER = logging.getLogger(__name__)


@pytest.mark.gating
@pytest.mark.polarion("CNV-6793")
@pytest.mark.parametrize(
"rhel_dv_for_online_resize, rhel_vm_for_online_resize",
[
pytest.param(
{"dv_name": "sequential-expand-dv"},
{"vm_name": "sequential-expand-vm"},
),
],
indirect=True,
)
def test_sequential_disk_expand(
rhel_dv_for_online_resize,
rhel_vm_for_online_resize,
running_rhel_vm,
):
# Expand PVC and wait for resize 6 times
for _ in range(6):
with wait_for_resize(vm=rhel_vm_for_online_resize):
expand_pvc(dv=rhel_dv_for_online_resize, size_change=SMALLEST_POSSIBLE_EXPAND)


@pytest.mark.polarion("CNV-6794")
@pytest.mark.parametrize(
"rhel_dv_for_online_resize, rhel_vm_for_online_resize",
[
pytest.param(
{"dv_name": "simultaneous-expand-dv"},
{"vm_name": "simultaneous-expand-vm"},
),
],
indirect=True,
)
def test_simultaneous_disk_expand(
rhel_dv_for_online_resize,
second_rhel_dv_for_online_resize,
rhel_vm_for_online_resize,
):
add_dv_to_vm(vm=rhel_vm_for_online_resize, dv_name=second_rhel_dv_for_online_resize.name)
running_vm(vm=rhel_vm_for_online_resize)
with wait_for_resize(vm=rhel_vm_for_online_resize, count=2):
expand_pvc(dv=rhel_dv_for_online_resize, size_change=SMALLEST_POSSIBLE_EXPAND)
expand_pvc(dv=second_rhel_dv_for_online_resize, size_change=SMALLEST_POSSIBLE_EXPAND)


@pytest.mark.polarion("CNV-8257")
@pytest.mark.parametrize(
"rhel_dv_for_online_resize, rhel_vm_for_online_resize",
[
pytest.param(
{"dv_name": "expand-clone-fail-dv"},
{"vm_name": "expand-clone-fail-vm"},
),
],
indirect=True,
)
def test_disk_expand_then_clone_fail(
unprivileged_client,
rhel_dv_for_online_resize,
rhel_vm_after_expand,
):
LOGGER.info("Trying to clone DV with original size - should fail at webhook")
with create_dv(
source="pvc",
dv_name=f"{rhel_dv_for_online_resize.name}-target",
namespace=rhel_dv_for_online_resize.namespace,
client=unprivileged_client,
size=RHEL_DV_SIZE,
storage_class=rhel_dv_for_online_resize.storage_class,
source_pvc=rhel_dv_for_online_resize.name,
) as dv:
for sample in TimeoutSampler(
wait_timeout=TIMEOUT_1MIN,
sleep=TIMEOUT_5SEC,
func=lambda: dv.instance.status.conditions,
):
if any(
"The clone doesn't meet the validation requirements:"
" target resources requests storage size is smaller than the source" in condition["message"]
for condition in sample
):
return


@pytest.mark.gating
@pytest.mark.polarion("CNV-6578")
@pytest.mark.parametrize(
"rhel_dv_for_online_resize, rhel_vm_for_online_resize",
[
pytest.param(
{"dv_name": "expand-clone-success-dv"},
{"vm_name": "expand-clone-success-vm"},
),
],
indirect=True,
)
def test_disk_expand_then_clone_success(
unprivileged_client,
rhel_dv_for_online_resize,
rhel_vm_after_expand,
):
# Can't clone a running VM
rhel_vm_after_expand.stop()

LOGGER.info("Trying to clone DV with new size - should succeed")
with create_dv(
source="pvc",
dv_name=f"{rhel_dv_for_online_resize.name}-target",
namespace=rhel_dv_for_online_resize.namespace,
client=unprivileged_client,
size=rhel_dv_for_online_resize.pvc.instance.spec.resources.requests.storage,
storage_class=rhel_dv_for_online_resize.storage_class,
source_pvc=rhel_dv_for_online_resize.name,
) as cdv:
cdv.wait_for_condition(
condition=DataVolume.Condition.Type.READY,
status=DataVolume.Condition.Status.TRUE,
timeout=TIMEOUT_4MIN,
)


@pytest.mark.polarion("CNV-6580")
@pytest.mark.parametrize(
"rhel_dv_for_online_resize, rhel_vm_for_online_resize",
[
pytest.param(
{"dv_name": "expand-migrate-dv"},
{"vm_name": "expand-migrate-vm"},
),
],
indirect=True,
)
def test_disk_expand_then_migrate(rhel_vm_after_expand, orig_cksum):
migrate_vm_and_verify(
vm=rhel_vm_after_expand,
check_ssh_connectivity=True,
)
check_file_unchanged(orig_cksum=orig_cksum, vm=rhel_vm_after_expand)


@pytest.mark.polarion("CNV-6797")
@pytest.mark.parametrize(
"rhel_dv_for_online_resize, rhel_vm_for_online_resize",
[
pytest.param(
{"dv_name": "expand-snapshot-dv"},
{"vm_name": "expand-snapshot-vm"},
),
],
indirect=True,
)
def test_disk_expand_with_snapshots(
xfail_if_storage_for_online_resize_does_not_support_snapshots,
rhel_dv_for_online_resize,
rhel_vm_for_online_resize,
orig_cksum,
):
with vm_snapshot(vm=rhel_vm_for_online_resize, name="snapshot-before") as vm_snapshot_before:
with wait_for_resize(vm=rhel_vm_for_online_resize):
expand_pvc(dv=rhel_dv_for_online_resize, size_change=SMALLEST_POSSIBLE_EXPAND)
check_file_unchanged(orig_cksum=orig_cksum, vm=rhel_vm_for_online_resize)
with vm_snapshot(vm=rhel_vm_for_online_resize, name="snapshot-after") as vm_snapshot_after:
with vm_restore(vm=rhel_vm_for_online_resize, name=vm_snapshot_before.name) as vm_restored_before:
check_file_unchanged(orig_cksum=orig_cksum, vm=vm_restored_before)
with vm_restore(vm=rhel_vm_for_online_resize, name=vm_snapshot_after.name) as vm_restored_after:
check_file_unchanged(orig_cksum=orig_cksum, vm=vm_restored_after)
Loading