Skip to content

Commit dc2e27a

Browse files
committed
adjust dv size to fit GCP minimumSupportedPvcSize
1 parent 0e7b393 commit dc2e27a

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

tests/storage/cdi_import/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ def cirros_dv_unprivileged(
142142
name=f"cirros-dv-{storage_class_name_scope_module}",
143143
storage_class=storage_class_name_scope_module,
144144
client=unprivileged_client,
145-
dv_size=DEFAULT_DV_SIZE,
146145
)
147146

148147

tests/storage/cdi_import/test_import_http.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ def test_blank_disk_import_validate_status(data_volume_multi_storage_scope_funct
542542
],
543543
)
544544
def test_vmi_image_size(
545+
xfail_test_if_gcp_sc,
545546
namespace,
546547
storage_class_matrix__module__,
547548
storage_class_name_scope_module,

tests/storage/cdi_upload/test_upload_virtctl.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ def test_virtctl_image_upload_with_exist_dv_image(
228228
@pytest.mark.sno
229229
@pytest.mark.gating
230230
@pytest.mark.polarion("CNV-3728")
231-
def test_virtctl_image_upload_pvc(download_image, namespace, storage_class_name_scope_module):
231+
def test_virtctl_image_upload_pvc(
232+
download_image, namespace, storage_class_name_scope_module, storage_profile_minimum_supported_pvc_size
233+
):
232234
"""
233235
Check that virtctl can create a new PVC and upload an image to it
234236
"""
@@ -237,7 +239,7 @@ def test_virtctl_image_upload_pvc(download_image, namespace, storage_class_name_
237239
namespace=namespace.name,
238240
pvc=True,
239241
name=pvc_name,
240-
size="1Gi",
242+
size=storage_profile_minimum_supported_pvc_size,
241243
image_path=LOCAL_PATH,
242244
storage_class=storage_class_name_scope_module,
243245
insecure=True,
@@ -283,14 +285,15 @@ def empty_pvc(
283285
storage_class_matrix__module__,
284286
storage_class_name_scope_module,
285287
worker_node1,
288+
storage_profile_minimum_supported_pvc_size,
286289
):
287290
with PersistentVolumeClaim(
288291
name="empty-pvc",
289292
namespace=namespace.name,
290293
storage_class=storage_class_name_scope_module,
291294
volume_mode=storage_class_matrix__module__[storage_class_name_scope_module]["volume_mode"],
292295
accessmodes=storage_class_matrix__module__[storage_class_name_scope_module]["access_mode"],
293-
size="1Gi",
296+
size=storage_profile_minimum_supported_pvc_size,
294297
hostpath_node=worker_node1.name
295298
if sc_is_hpp_with_immediate_volume_binding(sc=storage_class_name_scope_module)
296299
else None,
@@ -311,14 +314,15 @@ def test_virtctl_image_upload_with_exist_pvc(
311314
namespace,
312315
storage_class_name_scope_module,
313316
schedulable_nodes,
317+
storage_profile_minimum_supported_pvc_size,
314318
):
315319
"""
316320
Check that virtctl can upload an local disk image to an existing empty PVC
317321
"""
318322
with virtctl_upload_dv(
319323
namespace=namespace.name,
320324
name=empty_pvc.name,
321-
size="1Gi",
325+
size=storage_profile_minimum_supported_pvc_size,
322326
pvc=True,
323327
image_path=LOCAL_PATH,
324328
storage_class=storage_class_name_scope_module,
@@ -387,6 +391,7 @@ def test_virtctl_image_upload_dv_with_exist_pvc(
387391
namespace,
388392
storage_class_name_scope_module,
389393
schedulable_nodes,
394+
storage_profile_minimum_supported_pvc_size,
390395
):
391396
"""
392397
Check that virtctl fails gracefully when attempting to upload an image to a new data volume
@@ -395,7 +400,7 @@ def test_virtctl_image_upload_dv_with_exist_pvc(
395400
with virtctl_upload_dv(
396401
namespace=namespace.name,
397402
name=empty_pvc.name,
398-
size="1Gi",
403+
size=storage_profile_minimum_supported_pvc_size,
399404
image_path=LOCAL_PATH,
400405
storage_class=storage_class_name_scope_module,
401406
insecure=True,

tests/storage/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from ocp_resources.route import Route
2020
from ocp_resources.secret import Secret
2121
from ocp_resources.storage_class import StorageClass
22+
from ocp_resources.storage_profile import StorageProfile
2223
from ocp_resources.virtual_machine_snapshot import VirtualMachineSnapshot
2324
from pytest_testconfig import config as py_config
2425
from timeout_sampler import TimeoutSampler
@@ -45,6 +46,7 @@
4546
OS_FLAVOR_CIRROS,
4647
SECURITY_CONTEXT,
4748
Images,
49+
StorageClassNames,
4850
)
4951
from utilities.hco import (
5052
ResourceEditorValidateHCOReconcile,
@@ -190,6 +192,15 @@ def skip_test_if_no_hpp_sc(cluster_storage_classes):
190192
pytest.skip(f"This test runs only on one of the hpp storage classes: {HPP_STORAGE_CLASSES}")
191193

192194

195+
@pytest.fixture(scope="session")
196+
def xfail_test_if_gcp_sc(cluster_storage_classes):
197+
existing_gcp_sc = [sc.name for sc in cluster_storage_classes if sc.name in StorageClassNames.GCP]
198+
if existing_gcp_sc:
199+
pytest.xfail(
200+
reason=f"This test is X failed due to non supporting GCP storage class dv less than 4Gi'{existing_gcp_sc}'"
201+
)
202+
203+
193204
@pytest.fixture(scope="module")
194205
def skip_when_hpp_no_waitforfirstconsumer(storage_class_matrix_hpp_matrix__module__):
195206
if not sc_volume_binding_mode_is_wffc(sc=[*storage_class_matrix_hpp_matrix__module__][0]):
@@ -591,3 +602,9 @@ def storage_class_name_scope_module(storage_class_matrix__module__):
591602
@pytest.fixture(scope="session")
592603
def cluster_csi_drivers_names():
593604
yield [csi_driver.name for csi_driver in list(CSIDriver.get())]
605+
606+
607+
@pytest.fixture()
608+
def storage_profile_minimum_supported_pvc_size(storage_class_matrix__function__):
609+
storage_profile = StorageProfile(name=[*storage_class_matrix__function__][0])
610+
return storage_profile.instance.metadata.annotations.get("cdi.kubevirt.io/minimumSupportedPvcSize", "1Gi")

tests/storage/fs_overhead/test_fs_overhead.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from ocp_resources.persistent_volume_claim import PersistentVolumeClaim
1010

1111
from tests.utils import create_cirros_vm
12-
from utilities.constants import Images
1312
from utilities.hco import ResourceEditorValidateHCOReconcile
1413
from utilities.storage import virtctl_upload_dv
1514

@@ -64,12 +63,13 @@ def uploaded_cirros_dv(
6463
downloaded_cirros_image_full_path,
6564
downloaded_cirros_image_scope_class,
6665
storage_class_with_filesystem_volume_mode,
66+
storage_profile_minimum_supported_pvc_size,
6767
):
6868
dv_name = "uploaded-dv"
6969
with virtctl_upload_dv(
7070
namespace=namespace.name,
7171
name=dv_name,
72-
size=Images.Cirros.DEFAULT_DV_SIZE,
72+
size=storage_profile_minimum_supported_pvc_size,
7373
image_path=downloaded_cirros_image_full_path,
7474
storage_class=storage_class_with_filesystem_volume_mode,
7575
volume_mode=DataVolume.VolumeMode.FILE,
@@ -93,10 +93,9 @@ def test_import_vm_with_specify_fs_overhead(updated_fs_overhead_20_with_hco, vm_
9393

9494
@pytest.mark.polarion("CNV-8637")
9595
def test_upload_dv_with_specify_fs_overhead(
96-
updated_fs_overhead_20_with_hco,
97-
uploaded_cirros_dv,
96+
updated_fs_overhead_20_with_hco, uploaded_cirros_dv, storage_profile_minimum_supported_pvc_size
9897
):
9998
assert_fs_overhead_added(
10099
actual_size=get_pvc_size_gib(pvc=uploaded_cirros_dv.pvc),
101-
requested_size=bitmath.GiB(int(Images.Cirros.DEFAULT_DV_SIZE[0])),
100+
requested_size=bitmath.parse_string_unsafe(storage_profile_minimum_supported_pvc_size).to_GiB(),
102101
)

tests/storage/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from pytest_testconfig import config as py_config
2424
from timeout_sampler import TimeoutExpiredError, TimeoutSampler
2525

26+
from tests.utils import get_default_storage_profile_minimum_supported_pvc_size
2627
from utilities.constants import (
2728
CDI_UPLOADPROXY,
2829
TIMEOUT_2MIN,
@@ -398,17 +399,16 @@ def create_cirros_dv(
398399
access_modes=None,
399400
volume_mode=None,
400401
client=None,
401-
dv_size=Images.Cirros.DEFAULT_DV_SIZE,
402402
):
403403
with create_dv(
404404
dv_name=f"dv-{name}",
405405
namespace=namespace,
406406
url=get_http_image_url(image_directory=Images.Cirros.DIR, image_name=Images.Cirros.QCOW2_IMG),
407-
size=dv_size,
408407
storage_class=storage_class,
409408
access_modes=access_modes,
410409
volume_mode=volume_mode,
411410
client=client,
411+
size=get_default_storage_profile_minimum_supported_pvc_size(),
412412
) as dv:
413413
dv.wait_for_dv_success()
414414
yield dv

tests/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
from ocp_resources.datavolume import DataVolume
1717
from ocp_resources.kubevirt import KubeVirt
1818
from ocp_resources.resource import ResourceEditor
19+
from ocp_resources.storage_profile import StorageProfile
1920
from ocp_resources.template import Template
2021
from ocp_resources.virtual_machine import VirtualMachine
2122
from ocp_resources.virtual_machine_instance_migration import VirtualMachineInstanceMigration
2223
from pyhelper_utils.shell import run_ssh_commands
24+
from pytest_testconfig import config as py_config
2325
from timeout_sampler import TimeoutExpiredError, TimeoutSampler
2426

2527
from utilities.constants import (
@@ -585,7 +587,7 @@ def create_cirros_vm(
585587
source="http",
586588
url=get_http_image_url(image_directory=Images.Cirros.DIR, image_name=Images.Cirros.QCOW2_IMG),
587589
storage_class=storage_class,
588-
size=Images.Cirros.DEFAULT_DV_SIZE,
590+
size=get_default_storage_profile_minimum_supported_pvc_size(),
589591
api_name="storage",
590592
volume_mode=volume_mode,
591593
secret=artifactory_secret,
@@ -608,3 +610,9 @@ def create_cirros_vm(
608610
if wait_running:
609611
running_vm(vm=vm, wait_for_interfaces=False)
610612
yield vm
613+
614+
615+
def get_default_storage_profile_minimum_supported_pvc_size() -> str:
616+
return StorageProfile(
617+
name=next(iter(py_config["system_storage_class_matrix"][0]))
618+
).instance.metadata.annotations.get("cdi.kubevirt.io/minimumSupportedPvcSize", "1Gi")

0 commit comments

Comments
 (0)