@@ -15,10 +15,14 @@ class TestVMSnapshotClone(E2ETest):
15
15
"""
16
16
17
17
def test_vm_snapshot_clone (
18
- self , cnv_workload , snapshot_factory , snapshot_restore_factory
18
+ self ,
19
+ cnv_workload ,
20
+ snapshot_factory ,
21
+ snapshot_restore_factory ,
22
+ pvc_clone_factory ,
19
23
):
20
24
"""
21
- creates snapshot of a deployed vm and clones it
25
+ creates snapshot of a deployed vm, restores the snapshot, and then clones the restored PVC.
22
26
"""
23
27
24
28
# create a VM
@@ -27,16 +31,16 @@ def test_vm_snapshot_clone(
27
31
source_url = constants .CNV_FEDORA_SOURCE ,
28
32
)[- 1 ]
29
33
30
- # put some content onto it
34
+ # Write data to the VM
31
35
file_paths = ["/source_file.txt" , "/new_file.txt" ]
32
36
source_csum = run_dd_io (vm_obj = vm_obj , file_path = file_paths [0 ], verify = True )
33
37
vm_obj .stop ()
34
38
35
- # take a snapshot
39
+ # Take a snapshot of the VM's PVC
36
40
pvc_obj = vm_obj .get_vm_pvc_obj ()
37
41
snap_obj = snapshot_factory (pvc_obj )
38
42
39
- # restoring the snapshot
43
+ # Restore the snapshot to a new PVC
40
44
res_snap_obj = snapshot_restore_factory (
41
45
snapshot_obj = snap_obj ,
42
46
storageclass = vm_obj .sc_name ,
@@ -46,17 +50,20 @@ def test_vm_snapshot_clone(
46
50
status = constants .STATUS_BOUND ,
47
51
timeout = 300 ,
48
52
)
49
- # verify snapshot and data persist
50
- # restore the snapshot to a new PVC
53
+ # Clone the restored snapshot PVC to create a new PVC
54
+ cloned_pvc_obj = pvc_clone_factory (
55
+ pvc_obj = res_snap_obj , clone_name = f"{ res_snap_obj .name } -clone"
56
+ )
57
+ # Create a new VM with the cloned PVC
51
58
res_vm_obj = cnv_workload (
52
59
volume_interface = constants .VM_VOLUME_PVC ,
53
60
source_url = constants .CNV_FEDORA_SOURCE ,
54
- pvc_obj = res_snap_obj ,
61
+ pvc_obj = cloned_pvc_obj ,
55
62
namespace = vm_obj .namespace ,
56
63
)[1 ]
57
- # make sure data integrity is present
64
+ # Verify data integrity in the cloned VM
58
65
run_dd_io (vm_obj = res_vm_obj , file_path = file_paths [1 ], verify = True )
59
- # getting the md5sum from the clone vm
66
+ # Check the MD5 checksum to verify that data persisted after cloning
60
67
res_csum = cal_md5sum_vm (vm_obj = res_vm_obj , file_path = file_paths [0 ])
61
68
assert source_csum == res_csum , (
62
69
f"Failed: MD5 comparison between source { vm_obj .name } and cloned "
0 commit comments