-
Notifications
You must be signed in to change notification settings - Fork 68
WIP: [4.19] Add support for datasources + backport online resize tests #4758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ema-aka-young
wants to merge
6
commits into
RedHatQE:cnv-4.19
Choose a base branch
from
ema-aka-young:data-source-test-online-resize-cnv-4.19
base: cnv-4.19
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e8076d2
Storage: use DataSource in test online resize (#2300)
josemacassan 0a2ede7
Refactor data volume source reference handling in storage.py
ema-aka-young a13df63
Update data volume template handling in test_cached_snapshots.py
ema-aka-young 64e2272
Remove unused cirros_vm_name fixture and clean up DataVolume instanti…
ema-aka-young 1124fba
Merge branch 'cnv-4.19' into data-source-test-online-resize-cnv-4.19
ema-aka-young 4f56656
Fix test_online_resize using sudo dmesg
ema-aka-young File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test Execution Plan
Tests to run:
tests/storage/online_resize/test_online_resize.py— New test module restructured from deletedtest_online_resize.py; verify all new online resize tests passtests/storage/golden_image/test_cached_snapshots.py— Updated to usedata_volume_template_with_source_ref_dict(replacing removeddata_volume_dict_modify_to_source_ref); verify snapshot caching tests passtests/storage/test_wffc.py— Usesdata_volume_template_with_source_ref_dictwhose internal implementation changed (create_dvnow passessource_ref); verify WFFC tests pass