From de11accce82f4773372c0449f17619767ffc339d Mon Sep 17 00:00:00 2001 From: AYUSH-D-PATNI Date: Thu, 9 Jan 2025 13:21:03 +0530 Subject: [PATCH] added comments in vm_pvc_expansion Signed-off-by: AYUSH-D-PATNI --- .../workloads/cnv/test_vm_pvc_expansion.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/functional/workloads/cnv/test_vm_pvc_expansion.py b/tests/functional/workloads/cnv/test_vm_pvc_expansion.py index 9d9f519fe20..1a25b91ebe8 100644 --- a/tests/functional/workloads/cnv/test_vm_pvc_expansion.py +++ b/tests/functional/workloads/cnv/test_vm_pvc_expansion.py @@ -13,36 +13,42 @@ @workloads class TestVmPvcExpansion(E2ETest): """ - Independently expands the PVC attached to the VM - Test Steps: - 1. Create VM PVC following the documented procedure - from ODF official docs. - 2. Get initial PVC size and generate checksum before resize - 3. Resize PVC (increase by 1-5 GiB) - 4. Get new PVC size and generate checksum after resize - 5. Verify resize and data integrity + Test PVC expansion for a CNV VM workload """ + @workloads def test_pvc_expansion(self, cnv_workload): """ - Test PVC expansion for a CNV VM workload. + Independently expands the PVC attached to the VM + Test Steps: + 1. Create VM PVC following the documented procedure + from ODF official docs. + 2. Get initial PVC size and generate checksum before resize + 3. Resize PVC (increase by 1-5 GiB) + 4. Get new PVC size and generate checksum after resize + 5. Verify resize and data integrity """ + # Create VM and attach PVC 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(f"Initial PVC size: {vm_pvc_obj.size} GiB") + # Generate checksum before resize 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}") + # Resize PVC by 1-5 GiB 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) + # Verify new size and checksum after resize 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}") + # Check data integrity and PVC size 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."