diff --git a/tests/conftest.py b/tests/conftest.py index a15cdf1155..0f78b1ee65 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -85,6 +85,7 @@ CLUSTER, CNV_TEST_SERVICE_ACCOUNT, CNV_VM_SSH_KEY_PATH, + DATA_SOURCE_NAME, ES_NONE, EXPECTED_CLUSTER_INSTANCE_TYPE_LABELS, FEATURE_GATES, @@ -881,6 +882,17 @@ def rhel10_data_source_scope_session(golden_images_namespace): ) +@pytest.fixture(scope="session") +def latest_rhel_data_source(golden_images_namespace): + """Provide the DataSource for the latest RHEL version supported on this architecture.""" + return DataSource( + client=golden_images_namespace.client, + name=py_config["latest_instance_type_rhel_os_dict"][DATA_SOURCE_NAME], + namespace=golden_images_namespace.name, + ensure_exists=True, + ) + + """ VM creation from template """ diff --git a/tests/infrastructure/conftest.py b/tests/infrastructure/conftest.py index 53abef4cb3..fa937c306d 100644 --- a/tests/infrastructure/conftest.py +++ b/tests/infrastructure/conftest.py @@ -3,8 +3,6 @@ import pytest from kubernetes.dynamic.exceptions import ResourceNotFoundError -from ocp_resources.data_source import DataSource -from pytest_testconfig import config as py_config from timeout_sampler import TimeoutExpiredError from tests.infrastructure.utils import ( @@ -12,7 +10,6 @@ verify_tekton_operator_installed, ) from tests.utils import verify_cpumanager_workers, verify_hugepages_1gi, verify_rwx_default_storage -from utilities.constants import DATA_SOURCE_NAME from utilities.exceptions import ResourceMissingFieldError, ResourceValueError from utilities.pytest_utils import exit_pytest_execution @@ -99,13 +96,3 @@ def infrastructure_special_infra_sanity( junitxml_property=junitxml_plugin, admin_client=admin_client, ) - - -@pytest.fixture(scope="module") -def latest_rhel_data_source(golden_images_namespace): - return DataSource( - client=golden_images_namespace.client, - name=py_config["latest_instance_type_rhel_os_dict"][DATA_SOURCE_NAME], - namespace=golden_images_namespace.name, - ensure_exists=True, - ) diff --git a/tests/storage/conftest.py b/tests/storage/conftest.py index 80f0e5bcca..07857fe83c 100644 --- a/tests/storage/conftest.py +++ b/tests/storage/conftest.py @@ -50,7 +50,7 @@ CNV_TEST_SERVICE_ACCOUNT, OS_FLAVOR_FEDORA, OS_FLAVOR_RHEL, - RHEL10_PREFERENCE, + PREFERENCE_STR, SECURITY_CONTEXT, TIMEOUT_1MIN, TIMEOUT_5SEC, @@ -393,7 +393,7 @@ def rhel_vm_for_snapshot( admin_client, namespace, rhel_vm_name, - rhel10_data_source_scope_session, + latest_rhel_data_source, snapshot_storage_class_name_scope_module, ): """Create a RHEL VM with using DataSource that supports snapshots""" @@ -403,9 +403,12 @@ def rhel_vm_for_snapshot( client=admin_client, os_flavor=OS_FLAVOR_RHEL, vm_instance_type=VirtualMachineClusterInstancetype(client=admin_client, name=U1_SMALL), - vm_preference=VirtualMachineClusterPreference(client=admin_client, name=RHEL10_PREFERENCE), + vm_preference=VirtualMachineClusterPreference( + client=admin_client, + name=py_config["latest_instance_type_rhel_os_dict"][PREFERENCE_STR], + ), data_volume_template=data_volume_template_with_source_ref_dict( - data_source=rhel10_data_source_scope_session, + data_source=latest_rhel_data_source, storage_class=snapshot_storage_class_name_scope_module, ), ) as vm: diff --git a/tests/storage/vm_export/conftest.py b/tests/storage/vm_export/conftest.py index 97ca00769f..678f88201a 100644 --- a/tests/storage/vm_export/conftest.py +++ b/tests/storage/vm_export/conftest.py @@ -17,10 +17,11 @@ ) from ocp_resources.virtual_machine_export import VirtualMachineExport from ocp_resources.virtual_machine_snapshot import VirtualMachineSnapshot +from pytest_testconfig import config as py_config from tests.storage.constants import TEST_FILE_CONTENT, TEST_FILE_NAME from tests.storage.vm_export.utils import create_blank_dv_by_specific_user, get_manifest_from_vmexport, get_manifest_url -from utilities.constants import OS_FLAVOR_RHEL, U1_SMALL, UNPRIVILEGED_PASSWORD, UNPRIVILEGED_USER +from utilities.constants import OS_FLAVOR_RHEL, PREFERENCE_STR, U1_SMALL, UNPRIVILEGED_PASSWORD, UNPRIVILEGED_USER from utilities.infra import create_ns, login_with_user_password from utilities.storage import data_volume_template_with_source_ref_dict, write_file_via_ssh from utilities.virt import VirtualMachineForTests, running_vm @@ -200,7 +201,7 @@ def vmexport_download_path(tmp_path): def rhel_vm_for_snapshot_with_content( unprivileged_client, namespace, - rhel10_data_source_scope_session, + latest_rhel_data_source, snapshot_storage_class_name_scope_module, ): with VirtualMachineForTests( @@ -209,9 +210,11 @@ def rhel_vm_for_snapshot_with_content( client=unprivileged_client, os_flavor=OS_FLAVOR_RHEL, vm_instance_type=VirtualMachineClusterInstancetype(name=U1_SMALL), - vm_preference=VirtualMachineClusterPreference(name="rhel.10"), + vm_preference=VirtualMachineClusterPreference( + name=py_config["latest_instance_type_rhel_os_dict"][PREFERENCE_STR], + ), data_volume_template=data_volume_template_with_source_ref_dict( - data_source=rhel10_data_source_scope_session, + data_source=latest_rhel_data_source, storage_class=snapshot_storage_class_name_scope_module, ), ) as vm: