Skip to content

Commit f2b48fc

Browse files
jpeimerrnetser
authored andcommitted
[Storage] Remove skip_block_volumemode from archive import test (RedHatQE#5099)
##### What this PR does / why we need it: - Archive import only supports `Filesystem` volume mode, so explicitly set it on the DV instead of skipping Block volume mode at runtime - Remove the unused `skip_block_volumemode_scope_module` fixture. - Use PVC volume mode in `running_pod_with_dv_pvc` fixture - Ignore 'lost+found' file that may be created by some storage providers Assisted-by: Claude <noreply@anthropic.com> ##### Which issue(s) this PR fixes: Remove programmatic skip ##### Special notes for reviewer: ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Enhanced test configuration to support volume mode settings for HTTP import scenarios. * Simplified test fixture dependencies to improve maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jenia Peimer <jpeimer@redhat.com>
1 parent a8e3e62 commit f2b48fc

4 files changed

Lines changed: 10 additions & 24 deletions

File tree

tests/storage/cdi_import/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def dv_from_http_import(
9292
content_type=request.param.get("content_type", DataVolume.ContentType.KUBEVIRT),
9393
cert_configmap=request.param.get("configmap_name"),
9494
size=request.param.get("size", DEFAULT_DV_SIZE),
95+
volume_mode=request.param.get("volume_mode"),
9596
storage_class=storage_class_name_scope_module,
9697
client=namespace.client,
9798
) as dv:
@@ -101,15 +102,13 @@ def dv_from_http_import(
101102

102103
@pytest.fixture()
103104
def running_pod_with_dv_pvc(
104-
storage_class_matrix__module__,
105-
storage_class_name_scope_module,
106105
dv_from_http_import,
107106
):
108107
"""Create a running pod with DV's PVC."""
109108
dv_from_http_import.wait_for_dv_success()
110109
with create_pod_for_pvc(
111110
pvc=dv_from_http_import.pvc,
112-
volume_mode=storage_class_matrix__module__[storage_class_name_scope_module]["volume_mode"],
111+
volume_mode=dv_from_http_import.pvc.instance.spec.volumeMode,
113112
) as pod:
114113
yield pod
115114

tests/storage/cdi_import/test_import_http.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def test_successful_import_image(
123123
"source": HTTPS,
124124
"content_type": DataVolume.ContentType.ARCHIVE,
125125
"configmap_name": INTERNAL_HTTP_CONFIGMAP_NAME,
126+
"volume_mode": DataVolume.VolumeMode.FILE, # Archive type only supports Filesystem volume mode
126127
},
127128
marks=pytest.mark.polarion("CNV-2338"),
128129
),
@@ -131,13 +132,7 @@ def test_successful_import_image(
131132
)
132133
@pytest.mark.sno
133134
@pytest.mark.s390x
134-
def test_successful_import_secure_archive(
135-
skip_block_volumemode_scope_module, internal_http_configmap, running_pod_with_dv_pvc
136-
):
137-
"""
138-
Skip block volume mode - archive does not support block mode DVs,
139-
https://github.com/kubevirt/containerized-data-importer/blob/main/doc/supported_operations.md
140-
"""
135+
def test_successful_import_secure_archive(internal_http_configmap, running_pod_with_dv_pvc):
141136
assert_num_files_in_pod(pod=running_pod_with_dv_pvc, expected_num_of_files=3)
142137

143138

tests/storage/conftest.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,6 @@ def download_image():
296296
get_downloaded_artifact(remote_name=f"{Images.Cdi.DIR}/{Images.Cdi.QCOW2_IMG}", local_name=LOCAL_PATH)
297297

298298

299-
def _skip_block_volumemode(storage_class_matrix):
300-
storage_class = [*storage_class_matrix][0]
301-
if storage_class_matrix[storage_class]["volume_mode"] == "Block":
302-
pytest.skip("Test is not supported on Block volume mode")
303-
304-
305-
@pytest.fixture(scope="module")
306-
def skip_block_volumemode_scope_module(storage_class_matrix__module__):
307-
_skip_block_volumemode(storage_class_matrix=storage_class_matrix__module__)
308-
309-
310299
@pytest.fixture()
311300
def default_fs_overhead(cdi_config):
312301
return float(cdi_config.instance.status.filesystemOverhead["global"])

tests/storage/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,12 @@ def get_file_url(url, file_name):
440440

441441

442442
def assert_num_files_in_pod(pod, expected_num_of_files):
443-
num_of_file_in_pod = pod.execute(command=shlex.split("ls -1 /pvc")).count("\n")
444-
assert num_of_file_in_pod == expected_num_of_files, (
445-
f"Number of file in pod is {num_of_file_in_pod}, while the expected is {expected_num_of_files}"
443+
files = [
444+
line for line in pod.execute(command=shlex.split("ls -1 /pvc")).splitlines() if line and line != "lost+found"
445+
]
446+
num_of_files_in_pod = len(files)
447+
assert num_of_files_in_pod == expected_num_of_files, (
448+
f"Number of files in pod is {num_of_files_in_pod}, while the expected is {expected_num_of_files}"
446449
)
447450

448451

0 commit comments

Comments
 (0)