Skip to content

Commit f935701

Browse files
committed
storage, tests, cdi_upload: Verify CDI upload in primary UDN namespace
Add a regression test for disk image upload to a DataVolume in a PUDN namespace, after a bug (CNV-58018). Signed-off-by: Anat Wax <awax@redhat.com> Assisted-by: Claude <noreply@anthropic.com>
1 parent eee54e9 commit f935701

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

tests/storage/cdi_upload/conftest.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import pytest
99
from ocp_resources.datavolume import DataVolume
10+
from ocp_resources.user_defined_network import Layer2UserDefinedNetwork
1011

12+
from libs.net.ip import random_ipv4_address
13+
from libs.net.udn import create_udn_namespace
1114
from utilities.constants import TIMEOUT_1MIN, TIMEOUT_2MIN, Images
1215
from utilities.storage import check_upload_virtctl_result, create_dv, get_downloaded_artifact, virtctl_upload_dv
1316

@@ -93,3 +96,25 @@ def uploaded_dv_scope_class(unprivileged_client, namespace, storage_class_name_s
9396
) as upload_result:
9497
check_upload_virtctl_result(result=upload_result)
9598
yield dv
99+
100+
101+
@pytest.fixture(scope="module")
102+
def udn_namespace_for_dv_upload(admin_client):
103+
yield from create_udn_namespace(name="test-cdi-upload-udn-ns", client=admin_client)
104+
105+
106+
@pytest.fixture(scope="module")
107+
def primary_udn_for_upload(admin_client, udn_namespace_for_dv_upload):
108+
with Layer2UserDefinedNetwork(
109+
name="layer2-udn-upload",
110+
namespace=udn_namespace_for_dv_upload.name,
111+
role="Primary",
112+
subnets=[f"{random_ipv4_address(net_seed=0, host_address=0)}/24"],
113+
ipam={"lifecycle": "Persistent"},
114+
client=admin_client,
115+
) as udn:
116+
udn.wait_for_condition(
117+
condition="NetworkAllocationSucceeded",
118+
status=udn.Condition.Status.TRUE,
119+
)
120+
yield udn

tests/storage/cdi_upload/test_upload_virtctl.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,46 @@ def test_virtctl_image_upload_dv_with_exist_pvc(
413413
)
414414

415415

416+
@pytest.mark.sno
417+
@pytest.mark.polarion("CNV-16270")
418+
@pytest.mark.usefixtures("primary_udn_for_upload", "download_image")
419+
def test_virtctl_image_upload_dv_in_pudn_namespace(
420+
admin_client,
421+
udn_namespace_for_dv_upload,
422+
storage_class_name_immediate_binding_scope_module,
423+
):
424+
"""
425+
Test that uploading a disk image to a DataVolume succeeds in a namespace
426+
with a primary User Defined Network (UDN).
427+
428+
Jira: https://redhat.atlassian.net/browse/CNV-58018 # <skip-jira-utils-check>
429+
430+
Preconditions:
431+
- Namespace with a primary UDN label
432+
- Layer2 User Defined Network with role "Primary" in the namespace
433+
434+
Steps:
435+
1. Upload a disk image to a DataVolume in the UDN namespace via virtctl
436+
437+
Expected:
438+
- Upload completes successfully
439+
- DataVolume phase is "Succeeded"
440+
"""
441+
dv_name = f"cnv-16270-{storage_class_name_immediate_binding_scope_module}"
442+
with virtctl_upload_dv(
443+
client=udn_namespace_for_dv_upload.client,
444+
namespace=udn_namespace_for_dv_upload.name,
445+
name=dv_name,
446+
size=DEFAULT_DV_SIZE,
447+
image_path=LOCAL_PATH,
448+
storage_class=storage_class_name_immediate_binding_scope_module,
449+
insecure=True,
450+
) as res:
451+
check_upload_virtctl_result(result=res)
452+
dv = DataVolume(namespace=udn_namespace_for_dv_upload.name, name=dv_name, client=admin_client)
453+
dv.wait_for_dv_success(timeout=TIMEOUT_1MIN)
454+
455+
416456
@pytest.mark.tier3
417457
@pytest.mark.parametrize(
418458
("uploaded_dv_with_immediate_binding", "vm_params"),

0 commit comments

Comments
 (0)