Skip to content

Commit 005daf1

Browse files
committed
adjust pvc size to match minimumSupportedPvcSize in T2
1 parent 18a6475 commit 005daf1

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

tests/storage/cdi_clone/conftest.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import pytest
22
from ocp_resources.data_source import DataSource
33
from ocp_resources.datavolume import DataVolume
4+
from ocp_resources.storage_profile import StorageProfile
45

56
from tests.storage.utils import create_cirros_dv
6-
from utilities.constants import OS_FLAVOR_FEDORA
7+
from utilities.constants import OS_FLAVOR_FEDORA, Images
78
from utilities.storage import data_volume
89

910

11+
def get_storage_profile_minimum_supported_pvc_size(storage_class_name, admin_client):
12+
storage_profile = StorageProfile(name=storage_class_name, client=admin_client)
13+
annotations = getattr(storage_profile.instance.metadata, "annotations", {}) or {}
14+
return annotations.get("cdi.kubevirt.io/minimumSupportedPvcSize")
15+
16+
1017
@pytest.fixture(scope="module")
1118
def cirros_dv_with_filesystem_volume_mode(
1219
unprivileged_client,
@@ -25,6 +32,7 @@ def cirros_dv_with_filesystem_volume_mode(
2532
@pytest.fixture(scope="module")
2633
def cirros_dv_with_block_volume_mode(
2734
unprivileged_client,
35+
admin_client,
2836
namespace,
2937
storage_class_with_block_volume_mode,
3038
):
@@ -34,6 +42,11 @@ def cirros_dv_with_block_volume_mode(
3442
name="cirros-block",
3543
storage_class=storage_class_with_block_volume_mode,
3644
volume_mode=DataVolume.VolumeMode.BLOCK,
45+
dv_size=get_storage_profile_minimum_supported_pvc_size(
46+
storage_class_name=storage_class_with_block_volume_mode,
47+
admin_client=admin_client,
48+
)
49+
or Images.Cirros.DEFAULT_DV_SIZE,
3750
)
3851

3952

tests/storage/cdi_upload/test_upload_virtctl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,15 @@ def empty_pvc(
275275
storage_class_matrix__module__,
276276
storage_class_name_scope_module,
277277
worker_node1,
278+
storage_profile_minimum_supported_pvc_size,
278279
):
279280
with PersistentVolumeClaim(
280281
name="empty-pvc",
281282
namespace=namespace.name,
282283
storage_class=storage_class_name_scope_module,
283284
volume_mode=storage_class_matrix__module__[storage_class_name_scope_module]["volume_mode"],
284285
accessmodes=storage_class_matrix__module__[storage_class_name_scope_module]["access_mode"],
285-
size=DEFAULT_DV_SIZE,
286+
size=storage_profile_minimum_supported_pvc_size or DEFAULT_DV_SIZE,
286287
hostpath_node=worker_node1.name
287288
if sc_is_hpp_with_immediate_volume_binding(sc=storage_class_name_scope_module)
288289
else None,

tests/storage/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from ocp_resources.route import Route
2222
from ocp_resources.secret import Secret
2323
from ocp_resources.storage_class import StorageClass
24+
from ocp_resources.storage_profile import StorageProfile
2425
from ocp_resources.virtual_machine_cluster_instancetype import (
2526
VirtualMachineClusterInstancetype,
2627
)
@@ -552,6 +553,12 @@ def data_volume_template_metadata(multi_storage_cirros_vm):
552553
return multi_storage_cirros_vm.data_volume_template["metadata"]
553554

554555

556+
def get_storage_profile_minimum_supported_pvc_size(storage_class_name, admin_client):
557+
storage_profile = StorageProfile(name=storage_class_name, client=admin_client)
558+
annotations = getattr(storage_profile.instance.metadata, "annotations", {}) or {}
559+
return annotations.get("cdi.kubevirt.io/minimumSupportedPvcSize")
560+
561+
555562
@pytest.fixture()
556563
def storage_class_name_scope_function(storage_class_matrix__function__):
557564
return [*storage_class_matrix__function__][0]
@@ -562,6 +569,13 @@ def storage_class_name_scope_module(storage_class_matrix__module__):
562569
return [*storage_class_matrix__module__][0]
563570

564571

572+
@pytest.fixture(scope="module")
573+
def storage_profile_minimum_supported_pvc_size(storage_class_name_scope_module, admin_client):
574+
return get_storage_profile_minimum_supported_pvc_size(
575+
storage_class_name=storage_class_name_scope_module, admin_client=admin_client
576+
)
577+
578+
565579
@pytest.fixture(scope="module")
566580
def storage_class_name_immediate_binding_scope_module(storage_class_matrix_immediate_matrix__module__):
567581
return [*storage_class_matrix_immediate_matrix__module__][0]

0 commit comments

Comments
 (0)