Skip to content
Merged
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
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,9 +1272,9 @@ def available_storage_classes_names():


@pytest.fixture(scope="session")
def storage_class_with_filesystem_volume_mode(available_storage_classes_names):
def storage_class_with_filesystem_volume_mode(admin_client, available_storage_classes_names):
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
jpeimer marked this conversation as resolved.
yield get_storage_class_with_specified_volume_mode(
volume_mode=DataVolume.VolumeMode.FILE, sc_names=available_storage_classes_names
volume_mode=DataVolume.VolumeMode.FILE, sc_names=available_storage_classes_names, client=admin_client
Comment thread
coderabbitai[bot] marked this conversation as resolved.
)


Expand All @@ -1285,10 +1285,11 @@ def skip_test_if_no_block_sc(storage_class_with_block_volume_mode):


@pytest.fixture(scope="session")
def storage_class_with_block_volume_mode(available_storage_classes_names):
def storage_class_with_block_volume_mode(admin_client, available_storage_classes_names):
yield get_storage_class_with_specified_volume_mode(
volume_mode=DataVolume.VolumeMode.BLOCK,
sc_names=available_storage_classes_names,
client=admin_client,
)


Expand Down
16 changes: 11 additions & 5 deletions tests/data_protection/oadp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def velero_backup_multiple_namespaces(admin_client, imported_dv_second_namespace
def velero_restore_multiple_namespaces(admin_client, velero_backup_multiple_namespaces):
# Delete NS in order to restore it
for ns in velero_backup_multiple_namespaces.included_namespaces:
Namespace(name=ns).delete(wait=True)
Namespace(name=ns, client=admin_client).delete(wait=True)
Comment thread
davmarro marked this conversation as resolved.
with VeleroRestore(
client=admin_client,
included_namespaces=velero_backup_multiple_namespaces.included_namespaces,
Expand Down Expand Up @@ -228,7 +228,9 @@ def velero_restore_first_namespace_without_datamover(
admin_client,
velero_backup_first_namespace_without_datamover,
):
Namespace(name=velero_backup_first_namespace_without_datamover.included_namespaces[0]).delete(wait=True)
Namespace(name=velero_backup_first_namespace_without_datamover.included_namespaces[0], client=admin_client).delete(
wait=True
)
with VeleroRestore(
client=admin_client,
included_namespaces=velero_backup_first_namespace_without_datamover.included_namespaces,
Expand Down Expand Up @@ -259,7 +261,9 @@ def velero_restore_first_namespace_with_datamover(
velero_backup_first_namespace_using_datamover,
):
# Delete NS in order to restore it
Namespace(name=velero_backup_first_namespace_using_datamover.included_namespaces[0]).delete(wait=True)
Namespace(name=velero_backup_first_namespace_using_datamover.included_namespaces[0], client=admin_client).delete(
wait=True
)
with VeleroRestore(
client=admin_client,
included_namespaces=velero_backup_first_namespace_using_datamover.included_namespaces,
Expand Down Expand Up @@ -337,7 +341,7 @@ def uploaded_rhel_dv(
insecure=True,
) as res:
check_upload_virtctl_result(result=res)
yield DataVolume(namespace=namespace_for_backup2.name, name=dv_name)
yield DataVolume(namespace=namespace_for_backup2.name, name=dv_name, client=namespace_for_backup2.client)


@pytest.fixture()
Expand All @@ -360,7 +364,9 @@ def velero_restore_second_namespace_with_datamover(
velero_backup_second_namespace_using_datamover,
):
# Delete NS in order to restore it
Namespace(name=velero_backup_second_namespace_using_datamover.included_namespaces[0]).delete(wait=True)
Namespace(name=velero_backup_second_namespace_using_datamover.included_namespaces[0], client=admin_client).delete(
Comment thread
davmarro marked this conversation as resolved.
wait=True
)
with VeleroRestore(
client=admin_client,
included_namespaces=velero_backup_second_namespace_using_datamover.included_namespaces,
Expand Down
4 changes: 3 additions & 1 deletion tests/storage/cdi_config/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def cdi_with_extra_non_existent_feature_gate(admin_client, cdi):
cdi: {
"spec": {
"config": {
"featureGates": cdi_feature_gate_list_with_added_feature(feature="ExtraNonExistentFeature")
"featureGates": cdi_feature_gate_list_with_added_feature(
feature="ExtraNonExistentFeature", client=admin_client
)
}
},
},
Expand Down
3 changes: 2 additions & 1 deletion tests/storage/cdi_config/test_cdi_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_cdi_config_exists(cdi_config, upload_proxy_route):

@pytest.mark.destructive
@pytest.mark.polarion("CNV-2209")
def test_different_route_for_upload_proxy(hco_namespace, cdi_config, uploadproxy_route_deleted):
def test_different_route_for_upload_proxy(admin_client, hco_namespace, cdi_config, uploadproxy_route_deleted):
"""
Test that CDIConfig's upload_proxy_url changes when the upload-proxy route is deleted
and recreated with a different host
Expand All @@ -44,6 +44,7 @@ def test_different_route_for_upload_proxy(hco_namespace, cdi_config, uploadproxy
namespace=hco_namespace.name,
name="new-route-uploadproxy",
service=CDI_UPLOADPROXY,
client=admin_client,
) as new_route:
cdi_config.wait_until_upload_url_changed(uploadproxy_url=new_route.host)

Expand Down
7 changes: 4 additions & 3 deletions tests/storage/cdi_upload/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def wait_for_upload_response_code(token, data, response_code, asynchronous=False

@pytest.mark.polarion("CNV-2318")
@pytest.mark.s390x
def test_cdi_uploadproxy_route_owner_references(hco_namespace):
route = Route(name=CDI_UPLOADPROXY, namespace=hco_namespace.name)
def test_cdi_uploadproxy_route_owner_references(admin_client, hco_namespace):
route = Route(name=CDI_UPLOADPROXY, namespace=hco_namespace.name, client=admin_client)
assert route.instance
assert route.instance["metadata"]["ownerReferences"][0]["name"] == "cdi-deployment"
assert route.instance["metadata"]["ownerReferences"][0]["kind"] == "Deployment"
Expand Down Expand Up @@ -295,14 +295,15 @@ def _upload_image(dv_name, namespace, storage_class, local_name, client):
indirect=True,
)
def test_successful_concurrent_uploads(
admin_client,
unprivileged_client,
upload_file_path,
namespace,
storage_class_matrix__module__,
):
dvs_processes = []
storage_class = [*storage_class_matrix__module__][0]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
available_pv = PersistentVolume(name=namespace).max_available_pvs
available_pv = PersistentVolume(name=namespace, client=admin_client).max_available_pvs
for dv in range(available_pv):
dv_process = multiprocessing.Process(
target=_upload_image,
Expand Down
12 changes: 8 additions & 4 deletions tests/storage/cdi_upload/test_upload_virtctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
LATEST_WINDOWS_OS_DICT = py_config.get("latest_windows_os_dict", {})


def get_population_method_by_provisioner(storage_class, cluster_csi_drivers_names):
def get_population_method_by_provisioner(storage_class, cluster_csi_drivers_names, client):
return (
POPULATED_STR
if StorageClass(name=storage_class).instance.get("provisioner") in cluster_csi_drivers_names
if StorageClass(name=storage_class, client=client).instance.get("provisioner") in cluster_csi_drivers_names
else NON_CSI_POPULATED_STR
)

Expand Down Expand Up @@ -200,6 +200,7 @@ def test_virtctl_image_upload_dv(
)
@pytest.mark.s390x
def test_virtctl_image_upload_with_exist_dv_image(
admin_client,
data_volume_multi_storage_scope_function,
storage_class_name_scope_function,
download_image,
Expand Down Expand Up @@ -228,6 +229,7 @@ def test_virtctl_image_upload_with_exist_dv_image(
populated=get_population_method_by_provisioner(
storage_class=storage_class_name_scope_function,
cluster_csi_drivers_names=cluster_csi_drivers_names,
client=admin_client,
),
),
)
Expand Down Expand Up @@ -257,7 +259,7 @@ def test_virtctl_image_upload_pvc(download_image, namespace, storage_class_name_
insecure=True,
) as res:
check_upload_virtctl_result(result=res)
pvc = PersistentVolumeClaim(namespace=namespace.name, name=pvc_name)
pvc = PersistentVolumeClaim(namespace=namespace.name, name=pvc_name, client=namespace.client)
assert pvc.bound()


Expand Down Expand Up @@ -303,7 +305,7 @@ def empty_pvc(
if sc_volume_binding_mode_is_wffc(sc=storage_class_name_scope_module, client=namespace.client):
# For PVC to bind on WFFC, it must be consumed
# (this was previously solved by hard coding hostpath_node at all times)
create_dummy_first_consumer_pod(pvc=pvc)
create_dummy_first_consumer_pod(client=namespace.client, pvc=pvc)
pvc.wait_for_status(status=PersistentVolumeClaim.Status.BOUND, timeout=60)
yield pvc

Expand Down Expand Up @@ -346,6 +348,7 @@ def test_virtctl_image_upload_with_exist_pvc(
@pytest.mark.polarion("CNV-3729")
@pytest.mark.s390x
def test_virtctl_image_upload_with_exist_pvc_image(
admin_client,
download_image,
namespace,
storage_class_name_scope_module,
Expand Down Expand Up @@ -383,6 +386,7 @@ def test_virtctl_image_upload_with_exist_pvc_image(
populated=get_population_method_by_provisioner(
storage_class=storage_class_name_scope_module,
cluster_csi_drivers_names=cluster_csi_drivers_names,
client=admin_client,
),
),
)
Expand Down
13 changes: 7 additions & 6 deletions tests/storage/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,24 @@ def upload_proxy_route(admin_client):


@pytest.fixture()
def uploadproxy_route_deleted(hco_namespace):
def uploadproxy_route_deleted(admin_client, hco_namespace):
"""
Delete uploadproxy route from kubevirt-hyperconverged namespace.

This scales down cdi-operator replicas to 0 so that the route is not auto-created by the cdi-operator pod.
Once the cdi-operator is terminated, route is deleted to perform the test.
"""
ns = hco_namespace.name
deployment = Deployment(name=CDI_OPERATOR, namespace=ns)
deployment = Deployment(name=CDI_OPERATOR, namespace=ns, client=admin_client)
Comment thread
davmarro marked this conversation as resolved.
try:
deployment.scale_replicas(replica_count=0)
deployment.wait_for_replicas(deployed=False)
Route(name=CDI_UPLOADPROXY, namespace=ns).delete(wait=True)
Route(name=CDI_UPLOADPROXY, namespace=ns, client=admin_client).delete(wait=True)
yield
finally:
deployment.scale_replicas(replica_count=1)
deployment.wait_for_replicas()
Route(name=CDI_UPLOADPROXY, namespace=ns).wait()
Route(name=CDI_UPLOADPROXY, namespace=ns, client=admin_client).wait()


@pytest.fixture()
Expand All @@ -258,11 +258,12 @@ def cdi_config_upload_proxy_overridden(


@pytest.fixture()
def new_route_created(hco_namespace):
existing_route = Route(name=CDI_UPLOADPROXY, namespace=hco_namespace.name)
def new_route_created(admin_client, hco_namespace):
existing_route = Route(name=CDI_UPLOADPROXY, namespace=hco_namespace.name, client=admin_client)
route = Route(
name="newuploadroute-cdi",
namespace=hco_namespace.name,
client=admin_client,
destination_ca_cert=existing_route.ca_cert,
service=CDI_UPLOADPROXY,
)
Expand Down
10 changes: 7 additions & 3 deletions tests/storage/data_import_cron/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def vm_for_data_source_import(
os_flavor=OS_FLAVOR_FEDORA,
data_volume_template=data_volume_template_with_source_ref_dict(
data_source=DataSource(
name=imported_data_source.name, namespace=data_import_cron_pvc_target_namespace.name
name=imported_data_source.name,
namespace=data_import_cron_pvc_target_namespace.name,
client=unprivileged_client,
),
storage_class=storage_class_name_scope_module,
),
Expand Down Expand Up @@ -98,8 +100,10 @@ def data_import_cron_with_pvc_source(


@pytest.fixture(scope="class")
def imported_data_source(data_import_cron_pvc_target_namespace):
yield DataSource(namespace=data_import_cron_pvc_target_namespace.name, name="target-data-source")
def imported_data_source(admin_client, data_import_cron_pvc_target_namespace):
yield DataSource(
namespace=data_import_cron_pvc_target_namespace.name, name="target-data-source", client=admin_client
)
Comment thread
davmarro marked this conversation as resolved.


@pytest.fixture(scope="class")
Expand Down
6 changes: 3 additions & 3 deletions tests/storage/fs_overhead/test_fs_overhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ def uploaded_cirros_dv(
volume_mode=DataVolume.VolumeMode.FILE,
insecure=True,
):
yield DataVolume(name=dv_name, namespace=namespace.name)
yield DataVolume(name=dv_name, namespace=namespace.name, client=namespace.client)


@pytest.mark.polarion("CNV-8635")
def test_import_vm_with_specify_fs_overhead(updated_fs_overhead_20_with_hco, vm_for_fs_overhead_test):
def test_import_vm_with_specify_fs_overhead(admin_client, updated_fs_overhead_20_with_hco, vm_for_fs_overhead_test):
vm_metadata = vm_for_fs_overhead_test.data_volume_template["metadata"]
assert_fs_overhead_added(
actual_size=get_pvc_size_gib(
pvc=PersistentVolumeClaim(name=vm_metadata["name"], namespace=vm_metadata["namespace"])
pvc=PersistentVolumeClaim(name=vm_metadata["name"], namespace=vm_metadata["namespace"], client=admin_client)
),
requested_size=bitmath.GiB(
int(
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/general/test_storage_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_pvc_recreates_after_deletion(fedora_data_volume, namespace, storage_cla
pvc.delete()
wait_for_pvc_recreate(pvc=pvc, pvc_creation_timestamp=pvc_original_timestamp)
if sc_volume_binding_mode_is_wffc(sc=storage_class_name_scope_function, client=namespace.client):
create_dummy_first_consumer_pod(pvc=pvc)
create_dummy_first_consumer_pod(client=namespace.client, pvc=pvc)
fedora_data_volume.wait_for_dv_success()


Expand Down
11 changes: 8 additions & 3 deletions tests/storage/golden_image/test_cached_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def updated_templates_rhel9_data_import_cron(
namespace=golden_images_namespace.name,
client=admin_client,
).clean_up()
wait_for_succeeded_dv(namespace=golden_images_namespace.name, dv_name=rhel9_boot_source_name)
wait_for_succeeded_dv(
namespace=golden_images_namespace.name, dv_name=rhel9_boot_source_name, client=admin_client
)
wait_for_auto_boot_config_stabilization(admin_client=admin_client, hco_namespace=hco_namespace)


Expand Down Expand Up @@ -117,15 +119,18 @@ def rhel9_boot_source_name(rhel9_data_source_scope_session):

@pytest.fixture(scope="module")
def rhel9_cached_snapshot(
admin_client,
rhel9_boot_source_name,
golden_images_namespace,
updated_rhel9_boot_source,
):
# wait for the snapshot to be created
rhel9_volume_snapshot = wait_for_volume_snapshot_ready_to_use(
namespace=golden_images_namespace.name, name=rhel9_boot_source_name
namespace=golden_images_namespace.name, name=rhel9_boot_source_name, client=admin_client
)
verify_dv_and_pvc_does_not_exist(
name=rhel9_boot_source_name, namespace=golden_images_namespace.name, client=admin_client
)
verify_dv_and_pvc_does_not_exist(name=rhel9_boot_source_name, namespace=golden_images_namespace.name)
yield rhel9_volume_snapshot


Expand Down
4 changes: 3 additions & 1 deletion tests/storage/hpp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ def cirros_pvc_on_hpp(cirros_vm_for_node_placement_tests):
return PersistentVolumeClaim(
namespace=cirros_vm_for_node_placement_tests.namespace,
name=cirros_vm_for_node_placement_tests.data_volume_template["metadata"]["name"],
client=cirros_vm_for_node_placement_tests.client,
)


@pytest.fixture()
def cirros_pv_on_hpp(cirros_pvc_on_hpp):
def cirros_pv_on_hpp(admin_client, cirros_pvc_on_hpp):
Comment thread
davmarro marked this conversation as resolved.
return PersistentVolume(
name=cirros_pvc_on_hpp.instance.spec.volumeName,
client=admin_client,
)
Loading
Loading