diff --git a/tests/functional/workloads/cnv/test_vm_pvc_expansion.py b/tests/functional/workloads/cnv/test_vm_pvc_expansion.py index 191df9d6ac1..26dd0602538 100644 --- a/tests/functional/workloads/cnv/test_vm_pvc_expansion.py +++ b/tests/functional/workloads/cnv/test_vm_pvc_expansion.py @@ -18,26 +18,25 @@ class TestVmPvcExpansion(E2ETest): def test_pvc_expansion(self, cnv_workload): """ - Test PVC expansion for a CNV VM workload + Test PVC expansion for a CNV VM workload. """ vm_obj = cnv_workload( volume_interface=constants.VM_VOLUME_PVC, source_url=constants.CNV_FEDORA_SOURCE, )[-1] vm_pvc_obj = vm_obj.get_vm_pvc_obj() - log.info(vm_pvc_obj.size) - # writing data to the PVC - file_paths = "/source_file.txt" - source_csum = run_dd_io(vm_obj=vm_obj, file_path=file_paths, verify=True) - log.info(source_csum) - # Resize PVC to a random size between 31 and 35 GiB as 30GiB is default - new_size = random.randint(31, 35) - log.info(f"Size of VM PVC before expansion: {vm_pvc_obj.size}") - vm_pvc_obj.resize_pvc(new_size) - log.info(f"Size of VM PVC after expansion: {vm_pvc_obj.size}") - res_csum = cal_md5sum_vm(vm_obj=vm_obj, file_path=file_paths) - log.info(res_csum) - assert source_csum == res_csum and vm_obj.get_vm_pvc_obj().size == new_size, ( - f"Failed: Either VM PVC Expansion or MD5 comparison of {vm_obj.name} before and after " - f"PVC expansion" + log.info(f"Initial PVC size: {vm_pvc_obj.size} GiB") + file_path = "/source_file.txt" + source_csum = run_dd_io(vm_obj=vm_obj, file_path=file_path, verify=True) + log.info(f"Checksum before resize: {source_csum}") + new_size = random.randint(vm_pvc_obj.size + 1, vm_pvc_obj.size + 5) + log.info(f"Resizing PVC to {new_size} GiB") + vm_pvc_obj.resize_pvc(new_size, True) + vm_pvc_obj_n = vm_obj.get_vm_pvc_obj() + log.info(f"New PVC size: {vm_pvc_obj_n.size} GiB") + res_csum = cal_md5sum_vm(vm_obj=vm_obj, file_path=file_path) + log.info(f"Checksum after resize: {res_csum}") + assert source_csum == res_csum and vm_pvc_obj_n.size == new_size, ( + f"Failed: PVC expansion or MD5 mismatch for VM '{vm_obj.name}'. " + f"Expected size: {new_size} GiB, but got: {vm_pvc_obj.size} GiB." ) diff --git a/tests/functional/workloads/cnv/test_vm_snapshot_clone.py b/tests/functional/workloads/cnv/test_vm_snapshot_clone.py index 2cd23755afa..450c0fa4960 100644 --- a/tests/functional/workloads/cnv/test_vm_snapshot_clone.py +++ b/tests/functional/workloads/cnv/test_vm_snapshot_clone.py @@ -15,10 +15,14 @@ class TestVMSnapshotClone(E2ETest): """ def test_vm_snapshot_clone( - self, cnv_workload, snapshot_factory, snapshot_restore_factory + self, + cnv_workload, + snapshot_factory, + snapshot_restore_factory, + pvc_clone_factory, ): """ - creates snapshot of a deployed vm and clones it + creates snapshot of a deployed vm, restores the snapshot, and then clones the restored PVC. """ # create a VM @@ -27,16 +31,16 @@ def test_vm_snapshot_clone( source_url=constants.CNV_FEDORA_SOURCE, )[-1] - # put some content onto it + # Write data to the VM file_paths = ["/source_file.txt", "/new_file.txt"] source_csum = run_dd_io(vm_obj=vm_obj, file_path=file_paths[0], verify=True) vm_obj.stop() - # take a snapshot + # Take a snapshot of the VM's PVC pvc_obj = vm_obj.get_vm_pvc_obj() snap_obj = snapshot_factory(pvc_obj) - # restoring the snapshot + # Restore the snapshot to a new PVC res_snap_obj = snapshot_restore_factory( snapshot_obj=snap_obj, storageclass=vm_obj.sc_name, @@ -46,17 +50,20 @@ def test_vm_snapshot_clone( status=constants.STATUS_BOUND, timeout=300, ) - # verify snapshot and data persist - # restore the snapshot to a new PVC + # Clone the restored snapshot PVC to create a new PVC + cloned_pvc_obj = pvc_clone_factory( + pvc_obj=res_snap_obj, clone_name=f"{res_snap_obj.name}-clone" + ) + # Create a new VM with the cloned PVC res_vm_obj = cnv_workload( volume_interface=constants.VM_VOLUME_PVC, source_url=constants.CNV_FEDORA_SOURCE, - pvc_obj=res_snap_obj, + pvc_obj=cloned_pvc_obj, namespace=vm_obj.namespace, )[1] - # make sure data integrity is present + # Verify data integrity in the cloned VM run_dd_io(vm_obj=res_vm_obj, file_path=file_paths[1], verify=True) - # getting the md5sum from the clone vm + # Check the MD5 checksum to verify that data persisted after cloning res_csum = cal_md5sum_vm(vm_obj=res_vm_obj, file_path=file_paths[0]) assert source_csum == res_csum, ( f"Failed: MD5 comparison between source {vm_obj.name} and cloned "