15
15
from ocp_resources .volume_snapshot import VolumeSnapshot
16
16
from timeout_sampler import TimeoutExpiredError , TimeoutSampler
17
17
18
+ from tests .storage .utils import wait_for_data_import_cron_ready_and_updated
18
19
from utilities .constants import (
19
20
BIND_IMMEDIATE_ANNOTATION ,
20
21
OUTDATED ,
25
26
Images ,
26
27
)
27
28
from utilities .storage import (
29
+ create_dummy_first_consumer_pod ,
30
+ sc_volume_binding_mode_is_wffc ,
28
31
wait_for_succeeded_dv ,
29
32
wait_for_volume_snapshot_ready_to_use ,
30
33
)
@@ -205,6 +208,63 @@ def second_object_cleanup(
205
208
resource_class (namespace = namespace .name , name = second_object_name ).clean_up ()
206
209
207
210
211
+ @pytest .fixture ()
212
+ def data_import_cron_pvc_source (
213
+ unprivileged_client ,
214
+ data_import_cron_namespace ,
215
+ storage_class_with_filesystem_volume_mode ,
216
+ pvc_for_source_data_import_cron ,
217
+ ):
218
+ # cron_template_spec = golden_images_data_import_cron_spec.template.spec
219
+ with DataImportCron (
220
+ name = "pvc-import-cron" ,
221
+ namespace = data_import_cron_namespace .name ,
222
+ schedule = "*/1 * * * *" ,
223
+ managed_data_source = "pvc-import-datasource" ,
224
+ annotations = BIND_IMMEDIATE_ANNOTATION ,
225
+ template = {
226
+ "spec" : {
227
+ "source" : {
228
+ "pvc" : {
229
+ "name" : pvc_for_source_data_import_cron .name ,
230
+ "namespace" : pvc_for_source_data_import_cron .namespace ,
231
+ }
232
+ },
233
+ "sourceFormat" : "pvc" ,
234
+ "volumeMode" : "Filesystem" ,
235
+ "storage" : {
236
+ "storageClassName" : storage_class_with_filesystem_volume_mode ,
237
+ "accessModes" : [PersistentVolumeClaim .AccessMode .RWO ],
238
+ "resources" : {"requests" : {"storage" : "10Gi" }},
239
+ },
240
+ }
241
+ },
242
+ ) as data_import_cron :
243
+ wait_for_data_import_cron_ready_and_updated (
244
+ namespace = data_import_cron_namespace .name , name = data_import_cron .name
245
+ )
246
+ yield data_import_cron
247
+
248
+
249
+ @pytest .fixture ()
250
+ def pvc_for_source_data_import_cron (
251
+ namespace , storage_class_with_filesystem_volume_mode , storage_class_name_scope_module
252
+ ):
253
+ with PersistentVolumeClaim (
254
+ name = "source-pvc-test" ,
255
+ namespace = namespace .name ,
256
+ accessmodes = PersistentVolumeClaim .AccessMode .RWO ,
257
+ size = "1Gi" ,
258
+ storage_class = storage_class_with_filesystem_volume_mode ,
259
+ ) as pvc :
260
+ if sc_volume_binding_mode_is_wffc (sc = storage_class_name_scope_module ):
261
+ # For PVC to bind on WFFC, it must be consumed
262
+ # (this was previously solved by hard coding hostpath_node at all times)
263
+ create_dummy_first_consumer_pod (pvc = pvc )
264
+ pvc .wait_for_status (status = PersistentVolumeClaim .Status .BOUND , timeout = 60 )
265
+ yield pvc
266
+
267
+
208
268
@pytest .mark .gating
209
269
@pytest .mark .polarion ("CNV-7602" )
210
270
def test_data_import_cron_garbage_collection (
@@ -224,3 +284,16 @@ def test_data_import_cron_garbage_collection(
224
284
assert resource_class (namespace = namespace .name , name = second_object_name ).exists , (
225
285
f"Second { resource_class .kind } '{ second_object_name } ' does not exist"
226
286
)
287
+
288
+
289
+ class TestDataImportCronPvcSource :
290
+ @pytest .mark .polarion ("CNV-11842" )
291
+ def test_data_import_cron_with_pvc_source_ready (
292
+ self , namespace , pvc_for_source_data_import_cron , data_import_cron_pvc_source
293
+ ):
294
+ pvc_uid = pvc_for_source_data_import_cron .instance .metadata .uid
295
+ digest_full = data_import_cron_pvc_source .instance .status .currentImports [0 ].Digest
296
+ digest_uid = digest_full .split ("uid:" )[1 ] # Extract just the UUID part
297
+ assert pvc_for_source_data_import_cron .instance .metadata .uid == digest_uid , (
298
+ f"PVC UID { pvc_uid } does not match DataImportCron Digest { digest_uid } "
299
+ )
0 commit comments