Skip to content

Commit 19e3cf5

Browse files
committed
apply reviewer's suggestions
Signed-off-by: Adam Cinko <acinko@redhat.com>
1 parent dd432bc commit 19e3cf5

File tree

1 file changed

+32
-53
lines changed

1 file changed

+32
-53
lines changed

tests/storage/test_wffc.py

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""
23
HonorWaitForFirstConsumer test suite
34
"""
@@ -34,32 +35,39 @@
3435

3536

3637
WFFC_DV_NAME = "wffc-dv-name"
38+
DEFAULT_BLANK_DV_SIZE = "1Gi"
39+
40+
41+
@pytest.fixture(scope="module")
42+
def wffc_storage_class_name_scope_module(
43+
storage_class_matrix_wffc_matrix__module__,
44+
):
45+
return next(iter(storage_class_matrix_wffc_matrix__module__))
3746

3847

3948
@pytest.fixture()
40-
def blank_dv_wffc_scope_function(request, unprivileged_client, namespace, storage_class_matrix_wffc_matrix__module__):
49+
def blank_dv_wffc_scope_function(request, unprivileged_client, namespace, wffc_storage_class_name_scope_module):
4150
with create_dv(
4251
source="blank",
4352
dv_name=f"dv-{request.param['dv_name']}",
4453
namespace=namespace.name,
45-
size="1Gi",
46-
storage_class=next(iter(storage_class_matrix_wffc_matrix__module__)),
54+
size=DEFAULT_BLANK_DV_SIZE,
55+
storage_class=wffc_storage_class_name_scope_module,
4756
consume_wffc=False,
4857
client=unprivileged_client,
4958
) as dv:
5059
yield dv
5160

5261

5362
@pytest.fixture()
54-
def blank_dv_template_wffc_scope_function(request, namespace, storage_class_matrix_wffc_matrix__module__):
55-
storage_class_name = next(iter(storage_class_matrix_wffc_matrix__module__))
63+
def blank_dv_template_wffc_scope_function(request, namespace, wffc_storage_class_name_scope_module):
5664
blank_dv_template = DataVolume(
5765
name=f"dv-{request.param['dv_name']}",
5866
namespace=namespace.name,
5967
source="blank",
60-
size="1Gi",
61-
storage_class=storage_class_name,
62-
access_modes=storage_class_matrix_wffc_matrix__module__[storage_class_name]["access_mode"],
68+
size=DEFAULT_BLANK_DV_SIZE,
69+
storage_class=wffc_storage_class_name_scope_module,
70+
api_name="storage",
6371
)
6472
blank_dv_template.to_dict()
6573
return blank_dv_template.res
@@ -79,24 +87,23 @@ def uploaded_wffc_dv(namespace, unprivileged_client):
7987
def uploaded_dv_via_virtctl_wffc(
8088
namespace,
8189
downloaded_cirros_image_full_path,
82-
downloaded_cirros_image_scope_class,
83-
storage_class_matrix_wffc_matrix__module__,
90+
wffc_storage_class_name_scope_module,
8491
):
8592
with virtctl_upload_dv(
8693
client=namespace.client,
8794
namespace=namespace.name,
8895
name=WFFC_DV_NAME,
8996
size=Images.Cirros.DEFAULT_DV_SIZE,
9097
image_path=downloaded_cirros_image_full_path,
91-
storage_class=[*storage_class_matrix_wffc_matrix__module__][0],
98+
storage_class=wffc_storage_class_name_scope_module,
9299
insecure=True,
93100
consume_wffc=False,
94101
) as res:
95102
yield res
96103

97104

98105
@pytest.fixture()
99-
def vm_from_uploaded_dv(namespace, uploaded_dv_via_virtctl_wffc, uploaded_wffc_dv, unprivileged_client):
106+
def vm_from_uploaded_dv(uploaded_wffc_dv, unprivileged_client):
100107
with create_vm_from_dv(
101108
dv=uploaded_wffc_dv,
102109
vm_name=WFFC_DV_NAME,
@@ -124,7 +131,6 @@ class TestWFFCUploadVirtctl:
124131
@pytest.mark.s390x
125132
def test_wffc_fail_to_upload_dv_via_virtctl(
126133
self,
127-
namespace,
128134
uploaded_dv_via_virtctl_wffc,
129135
uploaded_wffc_dv,
130136
):
@@ -154,15 +160,15 @@ def test_wffc_create_vm_from_uploaded_dv_via_virtctl(
154160
self,
155161
downloaded_cirros_image_full_path,
156162
vm_from_uploaded_dv,
157-
storage_class_matrix_wffc_matrix__module__,
163+
wffc_storage_class_name_scope_module,
158164
):
159165
with virtctl_upload_dv(
160166
client=vm_from_uploaded_dv.client,
161167
namespace=vm_from_uploaded_dv.namespace,
162168
name=WFFC_DV_NAME,
163169
size=Images.Cirros.DEFAULT_DV_SIZE,
164170
image_path=downloaded_cirros_image_full_path,
165-
storage_class=[*storage_class_matrix_wffc_matrix__module__][0],
171+
storage_class=wffc_storage_class_name_scope_module,
166172
insecure=True,
167173
consume_wffc=False,
168174
cleanup=False,
@@ -173,59 +179,32 @@ def test_wffc_create_vm_from_uploaded_dv_via_virtctl(
173179
check_disk_count_in_vm(vm=vm_from_uploaded_dv)
174180

175181

176-
@pytest.mark.sno
177-
@pytest.mark.polarion("CNV-4739")
178-
@pytest.mark.s390x
179-
def test_wffc_import_registry_dv(
180-
unprivileged_client,
181-
namespace,
182-
storage_class_matrix_wffc_matrix__module__,
183-
):
184-
dv_name = "cnv-4739"
185-
with create_dv(
186-
source="registry",
187-
dv_name=dv_name,
188-
namespace=namespace.name,
189-
url=f"docker://quay.io/kubevirt/{Images.Cirros.DISK_DEMO}",
190-
storage_class=[*storage_class_matrix_wffc_matrix__module__][0],
191-
consume_wffc=True,
192-
client=unprivileged_client,
193-
) as dv:
194-
dv.wait_for_dv_success()
195-
create_vm_from_dv(client=unprivileged_client, dv=dv, vm_name=dv_name)
196-
197-
198182
@pytest.mark.sno
199183
@pytest.mark.s390x
200184
@pytest.mark.polarion("CNV-4742")
201185
@pytest.mark.parametrize(
202-
"rhel10_data_source_scope_module",
203-
[pytest.param({"dv_name": "wffc-4742"})],
204-
indirect=True,
205-
)
206-
@pytest.mark.parametrize(
207-
"blank_dv_wffc_scope_function",
208-
[pytest.param({"dv_name": "blank-wffc-4742"})],
186+
"rhel10_data_source_scope_module,blank_dv_wffc_scope_function",
187+
[
188+
({"dv_name": "wffc-4742"}, {"dv_name": "blank-wffc-4742"}),
189+
],
209190
indirect=True,
210191
)
211192
def test_wffc_add_dv_to_vm_with_data_volume_template(
212193
unprivileged_client,
213194
namespace,
214-
storage_class_matrix_wffc_matrix__module__,
195+
wffc_storage_class_name_scope_module,
215196
rhel10_data_source_scope_module,
216197
blank_dv_wffc_scope_function,
217198
):
218-
dv_template = data_volume_template_with_source_ref_dict(
219-
data_source=rhel10_data_source_scope_module,
220-
storage_class=next(iter(storage_class_matrix_wffc_matrix__module__)),
221-
)
222-
223199
with VirtualMachineForTests(
224200
client=unprivileged_client,
225201
name="cnv-4742-vm",
226202
namespace=namespace.name,
227203
os_flavor=OS_FLAVOR_RHEL,
228-
data_volume_template=dv_template,
204+
data_volume_template=data_volume_template_with_source_ref_dict(
205+
data_source=rhel10_data_source_scope_module,
206+
storage_class=wffc_storage_class_name_scope_module,
207+
),
229208
memory_guest=Images.Rhel.DEFAULT_MEMORY_SIZE,
230209
) as vm:
231210
validate_vm_and_disk_count(vm=vm)
@@ -245,7 +224,7 @@ def test_wffc_add_dv_to_vm_with_data_volume_template(
245224
def test_wffc_vm_with_two_data_volume_templates(
246225
unprivileged_client,
247226
namespace,
248-
storage_class_matrix_wffc_matrix__module__,
227+
wffc_storage_class_name_scope_module,
249228
rhel10_data_source_scope_module,
250229
blank_dv_template_wffc_scope_function,
251230
):
@@ -256,7 +235,7 @@ def test_wffc_vm_with_two_data_volume_templates(
256235
os_flavor=OS_FLAVOR_RHEL,
257236
data_volume_template=data_volume_template_with_source_ref_dict(
258237
data_source=rhel10_data_source_scope_module,
259-
storage_class=next(iter(storage_class_matrix_wffc_matrix__module__)),
238+
storage_class=wffc_storage_class_name_scope_module,
260239
),
261240
memory_guest=Images.Rhel.DEFAULT_MEMORY_SIZE,
262241
) as vm:

0 commit comments

Comments
 (0)