Skip to content

Commit b7e1dfb

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 b7e1dfb

2 files changed

Lines changed: 64 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()
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()
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,45 @@ 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+
):
423+
"""
424+
Test that uploading a disk image to a DataVolume succeeds in a namespace
425+
with a primary User Defined Network (UDN).
426+
427+
Jira: https://redhat.atlassian.net/browse/CNV-58018 # <skip-jira-utils-check>
428+
429+
Preconditions:
430+
- Namespace with a primary UDN label
431+
- Layer2 User Defined Network with role "Primary" in the namespace
432+
433+
Steps:
434+
1. Upload a disk image to a DataVolume in the UDN namespace via virtctl
435+
436+
Expected:
437+
- Upload completes successfully
438+
- DataVolume phase is "Succeeded"
439+
"""
440+
dv_name = "cnv-16270"
441+
with virtctl_upload_dv(
442+
client=udn_namespace_for_dv_upload.client,
443+
namespace=udn_namespace_for_dv_upload.name,
444+
name=dv_name,
445+
size=DEFAULT_DV_SIZE,
446+
image_path=LOCAL_PATH,
447+
storage_class=py_config["default_storage_class"],
448+
insecure=True,
449+
) as res:
450+
check_upload_virtctl_result(result=res)
451+
dv = DataVolume(namespace=udn_namespace_for_dv_upload.name, name=dv_name, client=admin_client)
452+
dv.wait_for_dv_success(timeout=TIMEOUT_1MIN)
453+
454+
416455
@pytest.mark.tier3
417456
@pytest.mark.parametrize(
418457
("uploaded_dv_with_immediate_binding", "vm_params"),

0 commit comments

Comments
 (0)