-
Notifications
You must be signed in to change notification settings - Fork 68
[4.20][Storage] Storage Tier2: use DataSource instead of artifactory in test_wffc.py 4.20 #4531
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
acinko-rh
wants to merge
6
commits into
RedHatQE:cnv-4.20
Choose a base branch
from
acinko-rh:change_artifactory_to_data_source_in_test_wffc_4_20
base: cnv-4.20
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.
+58
−213
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5d03eb4
[Storage] Storage Tier2: use DataSource instead of artifactory in tes…
acinko-rh 2d79ce5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0536d56
remove dead code
acinko-rh 1530058
Merge branch 'cnv-4.20' into change_artifactory_to_data_source_in_tes…
acinko-rh 11ec22a
add pytest mark post_upgrade back
acinko-rh 6cea4a6
Merge branch 'cnv-4.20' into change_artifactory_to_data_source_in_tes…
acinko-rh 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,133 +1,80 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """ | ||
| HonorWaitForFirstConsumer test suite | ||
| """ | ||
|
|
||
| import logging | ||
|
acinko-rh marked this conversation as resolved.
|
||
|
|
||
| import pytest | ||
| from ocp_resources.cdi import CDI | ||
| from ocp_resources.datavolume import DataVolume | ||
| from ocp_resources.persistent_volume_claim import PersistentVolumeClaim | ||
| from ocp_resources.virtual_machine_instance import VirtualMachineInstance | ||
|
|
||
| from tests.storage.constants import CIRROS_QCOW2_IMG | ||
| from tests.storage.utils import upload_image_to_dv, upload_token_request | ||
| from utilities.constants import ( | ||
| OS_FLAVOR_RHEL, | ||
| TIMEOUT_2MIN, | ||
| TIMEOUT_4MIN, | ||
| TIMEOUT_30SEC, | ||
| Images, | ||
| ) | ||
| from utilities.hco import ( | ||
| ResourceEditorValidateHCOReconcile, | ||
| hco_cr_jsonpatch_annotations_dict, | ||
| ) | ||
| from utilities.infra import get_artifactory_config_map, get_artifactory_secret | ||
| from utilities.storage import ( | ||
| add_dv_to_vm, | ||
| cdi_feature_gate_list_with_added_feature, | ||
| check_cdi_feature_gate_enabled, | ||
| check_disk_count_in_vm, | ||
| check_upload_virtctl_result, | ||
| create_dv, | ||
| create_vm_from_dv, | ||
| data_volume, | ||
| get_downloaded_artifact, | ||
| get_test_artifact_server_url, | ||
| data_volume_template_with_source_ref_dict, | ||
| virtctl_upload_dv, | ||
| ) | ||
| from utilities.virt import VirtualMachineForTests, running_vm, wait_for_ssh_connectivity | ||
|
|
||
| pytestmark = [ | ||
| pytest.mark.usefixtures("enable_wffc_feature_gate"), | ||
| pytest.mark.post_upgrade, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. took it back |
||
| ] | ||
|
|
||
| LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| WFFC_DV_NAME = "wffc-dv-name" | ||
| DV_PARAMS = { | ||
| "dv_name": "dv-wffc-tests", | ||
| "image": CIRROS_QCOW2_IMG, | ||
| "dv_size": Images.Cirros.DEFAULT_DV_SIZE, | ||
| } | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def enable_wffc_feature_gate(hyperconverged_resource_scope_module, cdi_config): | ||
| honor_wffc = "HonorWaitForFirstConsumer" | ||
| if check_cdi_feature_gate_enabled(feature=honor_wffc): | ||
| yield | ||
| else: | ||
| # Feature gate wasn't enabled | ||
| with ResourceEditorValidateHCOReconcile( | ||
| patches={ | ||
| hyperconverged_resource_scope_module: hco_cr_jsonpatch_annotations_dict( | ||
| component="cdi", | ||
| path="featureGates", | ||
| value=cdi_feature_gate_list_with_added_feature(feature=honor_wffc), | ||
| op="replace", | ||
| ) | ||
| }, | ||
| list_resource_reconcile=[CDI], | ||
| ): | ||
| yield | ||
| DEFAULT_BLANK_DV_SIZE = "1Gi" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def data_volume_multi_wffc_storage_scope_module( | ||
| request, | ||
| namespace, | ||
| def wffc_storage_class_name_scope_module( | ||
| storage_class_matrix_wffc_matrix__module__, | ||
| ): | ||
| yield from data_volume( | ||
| request=request, | ||
| namespace=namespace, | ||
| storage_class=[*storage_class_matrix_wffc_matrix__module__][0], | ||
| ) | ||
| return next(iter(storage_class_matrix_wffc_matrix__module__)) | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def data_volume_multi_wffc_storage_scope_function( | ||
| request, | ||
| namespace, | ||
| storage_class_matrix_wffc_matrix__module__, | ||
| ): | ||
| yield from data_volume( | ||
| request=request, | ||
| namespace=namespace, | ||
| storage_class=[*storage_class_matrix_wffc_matrix__module__][0], | ||
| ) | ||
| def blank_dv_wffc_scope_function(request, unprivileged_client, namespace, wffc_storage_class_name_scope_module): | ||
| with create_dv( | ||
| source="blank", | ||
| dv_name=f"dv-{request.param['dv_name']}", | ||
| namespace=namespace.name, | ||
| size=DEFAULT_BLANK_DV_SIZE, | ||
| storage_class=wffc_storage_class_name_scope_module, | ||
| consume_wffc=False, | ||
| client=unprivileged_client, | ||
| ) as dv: | ||
| yield dv | ||
|
|
||
|
|
||
| def get_dv_template_dict(namespace, dv_name, storage_class): | ||
| artifactory_secret = get_artifactory_secret(namespace=namespace) | ||
| artifactory_config_map = get_artifactory_config_map(namespace=namespace) | ||
| return { | ||
| "metadata": { | ||
| "name": f"{dv_name}", | ||
| }, | ||
| "spec": { | ||
| "storage": { | ||
| "resources": {"requests": {"storage": Images.Cirros.DEFAULT_DV_SIZE}}, | ||
| "storageClassName": storage_class, | ||
| }, | ||
| "source": { | ||
| "http": { | ||
| "certConfigMap": artifactory_config_map.name, | ||
| "secretRef": artifactory_secret.name, | ||
| "url": f"{get_test_artifact_server_url()}{CIRROS_QCOW2_IMG}", | ||
| } | ||
| }, | ||
| }, | ||
| } | ||
| @pytest.fixture() | ||
| def blank_dv_template_wffc_scope_function(request, namespace, wffc_storage_class_name_scope_module): | ||
| blank_dv_template = DataVolume( | ||
| name=f"dv-{request.param['dv_name']}", | ||
| namespace=namespace.name, | ||
| source="blank", | ||
| size=DEFAULT_BLANK_DV_SIZE, | ||
| storage_class=wffc_storage_class_name_scope_module, | ||
| api_name="storage", | ||
| ) | ||
| blank_dv_template.to_dict() | ||
| return blank_dv_template.res | ||
|
|
||
|
|
||
| def validate_vm_and_disk_count(vm): | ||
| running_vm(vm=vm, wait_for_interfaces=False) | ||
| running_vm(vm=vm) | ||
| check_disk_count_in_vm(vm=vm) | ||
|
|
||
|
|
||
|
|
@@ -141,14 +88,14 @@ def uploaded_dv_via_virtctl_wffc( | |
| namespace, | ||
| downloaded_cirros_image_full_path, | ||
| downloaded_cirros_image_scope_class, | ||
| storage_class_matrix_wffc_matrix__module__, | ||
| wffc_storage_class_name_scope_module, | ||
| ): | ||
| with virtctl_upload_dv( | ||
| namespace=namespace.name, | ||
| name=WFFC_DV_NAME, | ||
| size=Images.Cirros.DEFAULT_DV_SIZE, | ||
| image_path=downloaded_cirros_image_full_path, | ||
| storage_class=[*storage_class_matrix_wffc_matrix__module__][0], | ||
| storage_class=wffc_storage_class_name_scope_module, | ||
| insecure=True, | ||
| consume_wffc=False, | ||
| ) as res: | ||
|
|
@@ -212,14 +159,14 @@ def test_wffc_create_vm_from_uploaded_dv_via_virtctl( | |
| self, | ||
| downloaded_cirros_image_full_path, | ||
| vm_from_uploaded_dv, | ||
| storage_class_matrix_wffc_matrix__module__, | ||
| wffc_storage_class_name_scope_module, | ||
| ): | ||
| with virtctl_upload_dv( | ||
| namespace=vm_from_uploaded_dv.namespace, | ||
| name=WFFC_DV_NAME, | ||
| size=Images.Cirros.DEFAULT_DV_SIZE, | ||
| image_path=downloaded_cirros_image_full_path, | ||
| storage_class=[*storage_class_matrix_wffc_matrix__module__][0], | ||
| storage_class=wffc_storage_class_name_scope_module, | ||
| insecure=True, | ||
| consume_wffc=False, | ||
| cleanup=False, | ||
|
|
@@ -231,165 +178,63 @@ def test_wffc_create_vm_from_uploaded_dv_via_virtctl( | |
|
|
||
|
|
||
| @pytest.mark.sno | ||
| @pytest.mark.polarion("CNV-4739") | ||
| @pytest.mark.s390x | ||
| def test_wffc_import_registry_dv( | ||
| namespace, | ||
| storage_class_matrix_wffc_matrix__module__, | ||
| ): | ||
| dv_name = "cnv-4739" | ||
| with create_dv( | ||
| source="registry", | ||
| dv_name=dv_name, | ||
| namespace=namespace.name, | ||
| url=f"docker://quay.io/kubevirt/{Images.Cirros.DISK_DEMO}", | ||
| storage_class=[*storage_class_matrix_wffc_matrix__module__][0], | ||
| consume_wffc=True, | ||
| ) as dv: | ||
| dv.wait_for_dv_success() | ||
| with create_vm_from_dv(dv=dv, vm_name=dv_name) as vm_dv: | ||
| check_disk_count_in_vm(vm=vm_dv) | ||
|
|
||
|
|
||
| @pytest.mark.sno | ||
| @pytest.mark.polarion("CNV-4741") | ||
| @pytest.mark.s390x | ||
| def test_wffc_upload_dv_via_token( | ||
| unprivileged_client, | ||
| namespace, | ||
| tmpdir, | ||
| storage_class_matrix_wffc_matrix__module__, | ||
| ): | ||
| dv_name = "cnv-4741" | ||
| local_name = f"{tmpdir}/{Images.Cirros.QCOW2_IMG}" | ||
| get_downloaded_artifact( | ||
| remote_name=CIRROS_QCOW2_IMG, | ||
| local_name=local_name, | ||
| ) | ||
| with upload_image_to_dv( | ||
| dv_name=dv_name, | ||
| storage_class=[*storage_class_matrix_wffc_matrix__module__][0], | ||
| storage_ns_name=namespace.name, | ||
| client=unprivileged_client, | ||
| consume_wffc=True, | ||
| ) as dv: | ||
| upload_token_request(storage_ns_name=namespace.name, pvc_name=dv.pvc.name, data=local_name) | ||
| dv.wait_for_dv_success() | ||
| with create_vm_from_dv(dv=dv, vm_name=dv_name) as vm_dv: | ||
| check_disk_count_in_vm(vm=vm_dv) | ||
|
|
||
|
|
||
| @pytest.mark.sno | ||
| @pytest.mark.parametrize( | ||
| "data_volume_multi_wffc_storage_scope_module", | ||
| [ | ||
| pytest.param( | ||
| {**DV_PARAMS, **{"consume_wffc": True}}, | ||
| marks=pytest.mark.polarion("CNV-4371"), | ||
| ), | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.s390x | ||
| def test_wffc_import_http_dv(data_volume_multi_wffc_storage_scope_module): | ||
| with create_vm_from_dv( | ||
| dv=data_volume_multi_wffc_storage_scope_module, vm_name=data_volume_multi_wffc_storage_scope_module.name | ||
| ) as vm_dv: | ||
| check_disk_count_in_vm(vm=vm_dv) | ||
|
|
||
|
|
||
| @pytest.mark.sno | ||
| @pytest.mark.polarion("CNV-4742") | ||
| @pytest.mark.parametrize( | ||
| "data_volume_multi_wffc_storage_scope_module", | ||
| "blank_dv_wffc_scope_function", | ||
| [ | ||
| pytest.param( | ||
| {**DV_PARAMS, **{"consume_wffc": True}}, | ||
| marks=pytest.mark.polarion("CNV-4379"), | ||
| ), | ||
| pytest.param({"dv_name": "blank-wffc-4742"}), | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.s390x | ||
| def test_wffc_clone_dv(data_volume_multi_wffc_storage_scope_module): | ||
| with create_dv( | ||
| source="pvc", | ||
| dv_name="dv-target", | ||
| namespace=data_volume_multi_wffc_storage_scope_module.namespace, | ||
| size=data_volume_multi_wffc_storage_scope_module.size, | ||
| source_pvc=data_volume_multi_wffc_storage_scope_module.name, | ||
| storage_class=data_volume_multi_wffc_storage_scope_module.storage_class, | ||
| consume_wffc=True, | ||
| ) as cdv: | ||
| cdv.wait_for_dv_success(timeout=TIMEOUT_4MIN) | ||
| with create_vm_from_dv(dv=cdv, vm_name=cdv.name) as vm_dv: | ||
| check_disk_count_in_vm(vm=vm_dv) | ||
|
|
||
|
|
||
| @pytest.mark.sno | ||
| @pytest.mark.parametrize( | ||
| "data_volume_multi_wffc_storage_scope_function", | ||
| [ | ||
| pytest.param( | ||
| { | ||
| "dv_name": "dv-wffc-4742", | ||
| "image": CIRROS_QCOW2_IMG, | ||
| "dv_size": Images.Cirros.DEFAULT_DV_SIZE, | ||
| "consume_wffc": False, | ||
| }, | ||
| marks=pytest.mark.polarion("CNV-4742"), | ||
| ), | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.s390x | ||
| def test_wffc_add_dv_to_vm_with_data_volume_template( | ||
| namespace, | ||
| data_volume_multi_wffc_storage_scope_function, | ||
| wffc_storage_class_name_scope_module, | ||
| rhel10_data_source_scope_module, | ||
| blank_dv_wffc_scope_function, | ||
| ): | ||
| with VirtualMachineForTests( | ||
| name="cnv-4742-vm", | ||
| namespace=namespace.name, | ||
| os_flavor=Images.Cirros.OS_FLAVOR, | ||
| data_volume_template=get_dv_template_dict( | ||
| namespace=namespace.name, | ||
| dv_name="template-dv", | ||
| storage_class=data_volume_multi_wffc_storage_scope_function.storage_class, | ||
| os_flavor=OS_FLAVOR_RHEL, | ||
| data_volume_template=data_volume_template_with_source_ref_dict( | ||
| data_source=rhel10_data_source_scope_module, | ||
| storage_class=wffc_storage_class_name_scope_module, | ||
| ), | ||
| memory_guest=Images.Cirros.DEFAULT_MEMORY_SIZE, | ||
| memory_guest=Images.Rhel.DEFAULT_MEMORY_SIZE, | ||
| ) as vm: | ||
| validate_vm_and_disk_count(vm=vm) | ||
| # Add DV | ||
| vm.stop(wait=True) | ||
| add_dv_to_vm(vm=vm, dv_name=data_volume_multi_wffc_storage_scope_function.name) | ||
| add_dv_to_vm(vm=vm, dv_name=blank_dv_wffc_scope_function.name) | ||
| # Check DV was added | ||
| validate_vm_and_disk_count(vm=vm) | ||
|
|
||
|
|
||
| @pytest.mark.sno | ||
| @pytest.mark.polarion("CNV-4743") | ||
| @pytest.mark.s390x | ||
| @pytest.mark.polarion("CNV-4743") | ||
| @pytest.mark.parametrize( | ||
| "blank_dv_template_wffc_scope_function", [pytest.param({"dv_name": "blank-wffc-4743"})], indirect=True | ||
| ) | ||
| def test_wffc_vm_with_two_data_volume_templates( | ||
| namespace, | ||
| storage_class_matrix_wffc_matrix__module__, | ||
| wffc_storage_class_name_scope_module, | ||
| rhel10_data_source_scope_module, | ||
| blank_dv_template_wffc_scope_function, | ||
| ): | ||
| storage_class = [*storage_class_matrix_wffc_matrix__module__][0] | ||
| with VirtualMachineForTests( | ||
| name="cnv-4743-vm", | ||
| namespace=namespace.name, | ||
| os_flavor=Images.Cirros.OS_FLAVOR, | ||
| data_volume_template=get_dv_template_dict( | ||
| namespace=namespace.name, | ||
| dv_name="template-dv-1", | ||
| storage_class=storage_class, | ||
| os_flavor=OS_FLAVOR_RHEL, | ||
| data_volume_template=data_volume_template_with_source_ref_dict( | ||
| data_source=rhel10_data_source_scope_module, | ||
| storage_class=wffc_storage_class_name_scope_module, | ||
| ), | ||
| memory_guest=Images.Cirros.DEFAULT_MEMORY_SIZE, | ||
| memory_guest=Images.Rhel.DEFAULT_MEMORY_SIZE, | ||
| ) as vm: | ||
| add_dv_to_vm( | ||
| vm=vm, | ||
| template_dv=get_dv_template_dict( | ||
| namespace=namespace.name, | ||
| dv_name="template-dv-2", | ||
| storage_class=storage_class, | ||
| ), | ||
| template_dv=blank_dv_template_wffc_scope_function, | ||
| ) | ||
| validate_vm_and_disk_count(vm=vm) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.