Skip to content

Commit ae0d6b5

Browse files
committed
increase docstrings coverage and enhance them
Signed-off-by: Emanuele Prella <eprella@redhat.com>
1 parent 35174c2 commit ae0d6b5

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

tests/storage/cdi_import/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040

4141
@pytest.fixture()
4242
def skip_non_shared_storage(storage_class_name_scope_function):
43+
"""Skip tests if the storage class is non-shared."""
4344
if storage_class_name_scope_function in HPP_STORAGE_CLASSES:
4445
pytest.skip("Skipping when storage is non-shared")
4546

4647

4748
@pytest.fixture()
4849
def bridge_on_node(admin_client):
50+
"""Create a Linux Bridge network device and yield it."""
4951
with network_device(
5052
interface_type=LINUX_BRIDGE,
5153
nncp_name=BRIDGE_NAME,
@@ -57,6 +59,7 @@ def bridge_on_node(admin_client):
5759

5860
@pytest.fixture()
5961
def linux_nad(admin_client, namespace, bridge_on_node):
62+
"""Create a Linux Bridge Network Attachment Definition (NAD) and yield it."""
6063
with network_nad(
6164
namespace=namespace,
6265
nad_type=LINUX_BRIDGE,
@@ -71,6 +74,7 @@ def linux_nad(admin_client, namespace, bridge_on_node):
7174
def cirros_pvc(
7275
data_volume_template_metadata,
7376
):
77+
"""Create a PVC from the data volume template metadata."""
7478
return PersistentVolumeClaim(
7579
name=data_volume_template_metadata["name"],
7680
namespace=data_volume_template_metadata["namespace"],
@@ -81,11 +85,13 @@ def cirros_pvc(
8185
def pvc_original_timestamp(
8286
cirros_pvc,
8387
):
88+
"""Get the original creation timestamp of the Cirros PVC."""
8489
return cirros_pvc.instance.metadata.creationTimestamp
8590

8691

8792
@pytest.fixture()
8893
def dv_non_exist_url(namespace, storage_class_name_scope_module):
94+
"""Create a DV with a non-existent URL to test import failure."""
8995
with create_dv(
9096
dv_name=f"cnv-876-{storage_class_name_scope_module}",
9197
namespace=namespace.name,
@@ -104,6 +110,7 @@ def dv_from_http_import(
104110
storage_class_name_scope_module,
105111
images_internal_http_server,
106112
):
113+
"""Create a DV from HTTP import with parameters from the test function."""
107114
with create_dv(
108115
dv_name=f"{request.param.get('dv_name', 'http-dv')}-{storage_class_name_scope_module}",
109116
namespace=namespace.name,
@@ -127,6 +134,7 @@ def running_pod_with_dv_pvc(
127134
storage_class_name_scope_module,
128135
dv_from_http_import,
129136
):
137+
"""Create a running pod with DV's PVC."""
130138
dv_from_http_import.wait_for_dv_success()
131139
with create_pod_for_pvc(
132140
pvc=dv_from_http_import.pvc,
@@ -137,6 +145,7 @@ def running_pod_with_dv_pvc(
137145

138146
@pytest.fixture()
139147
def created_blank_dv_list(unprivileged_client, namespace, storage_class_name_scope_module, number_of_dvs):
148+
"""Create a list of blank DVs."""
140149
dvs_list = []
141150
try:
142151
for dv_index in range(number_of_dvs):
@@ -189,6 +198,7 @@ def created_vm_list(unprivileged_client, created_blank_dv_list, storage_class_na
189198

190199
@pytest.fixture()
191200
def dvs_and_vms_from_public_registry(unprivileged_client, namespace, storage_class_name_scope_function):
201+
"""Create DVs from public registry and VMs from those DVs."""
192202
dvs = []
193203
vms = []
194204
try:
@@ -230,6 +240,7 @@ def dvs_and_vms_from_public_registry(unprivileged_client, namespace, storage_cla
230240

231241
@pytest.fixture()
232242
def dv_with_annotation(admin_client, namespace, linux_nad):
243+
"""Create a DV with multus annotation and yield the importer pod annotations."""
233244
with create_dv(
234245
dv_name="dv-annotation",
235246
namespace=namespace.name,

tests/storage/cdi_import/test_import_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def test_successful_vm_from_imported_dv_windows(
429429
@pytest.mark.polarion("CNV-5509")
430430
@pytest.mark.s390x
431431
def test_importer_pod_annotation(dv_with_annotation, linux_nad):
432-
"""Verify "k8s.v1.cni.cncf.io/networks" can pass to the importer pod"""
432+
"""Verify "k8s.v1.cni.cncf.io/networks" can be passed to the importer pod"""
433433
networks_annotation = f"{Resource.ApiGroup.K8S_V1_CNI_CNCF_IO}/networks"
434434
network_status_annotation = f"{Resource.ApiGroup.K8S_V1_CNI_CNCF_IO}/network-status"
435435

tests/storage/general/test_storage_behavior.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@
3232
@pytest.mark.sno
3333
@pytest.mark.polarion("CNV-675")
3434
def test_pvc_recreates_after_deletion(namespace, storage_class_name_scope_function, fedora_data_source_scope_module):
35+
"""
36+
Test that a PVC is automatically recreated by CDI after manual deletion.
37+
38+
Preconditions:
39+
- Fedora DataSource available
40+
- Storage class available
41+
- DataVolume created from Fedora DataSource
42+
- PVC bound and DataVolume import completed
43+
44+
Steps:
45+
1. Record the PVC original creation timestamp
46+
2. Delete the PVC
47+
3. Wait for PVC to be recreated with a new timestamp
48+
4. Create a dummy first consumer pod if storage class uses WaitForFirstConsumer binding mode
49+
5. Wait for DataVolume to reach Succeeded status
50+
51+
Expected:
52+
- PVC is recreated automatically
53+
- DataVolume status is "Succeeded"
54+
"""
3555
with create_dv(
3656
dv_name=f"cnv-675-{storage_class_name_scope_function}",
3757
namespace=namespace.name,
@@ -60,6 +80,22 @@ def test_pvc_recreates_after_deletion(namespace, storage_class_name_scope_functi
6080
def test_disk_falloc(
6181
storage_class_name_scope_function, unprivileged_client, fedora_data_source_scope_module, namespace
6282
):
83+
"""
84+
Test that attempting to allocate more space than available on a disk fails with the expected error.
85+
86+
Preconditions:
87+
- Fedora DataSource available
88+
- DataVolume created from Fedora DataSource
89+
- VM created and started from the DataVolume with console access
90+
91+
Steps:
92+
1. Connect to VM console
93+
2. Execute fallocate command to allocate a file equal to the disk size
94+
3. Verify the error message
95+
96+
Expected:
97+
- fallocate command fails with "No space left on device" error
98+
"""
6399
size = get_dv_size_from_datasource(data_source=fedora_data_source_scope_module)
64100
with create_dv(
65101
client=unprivileged_client,

0 commit comments

Comments
 (0)