Skip to content

Commit 9cf64d9

Browse files
CherryPicked: [cnv-4.21] storage, tests, cdi_upload: Verify CDI upload in primary UDN namespace (#5399)
Cherry-pick from `main` branch, original PR: #5214, PR owner: Anatw Signed-off-by: ‪Anat Wax <awax@redhat.com> Co-authored-by: ‪Anat Wax <awax@redhat.com>
1 parent fdd5da0 commit 9cf64d9

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(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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,45 @@ def test_virtctl_image_upload_dv_with_exist_pvc(
417417
)
418418

419419

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

0 commit comments

Comments
 (0)