Skip to content

Commit

Permalink
added comments in vm_pvc_expansion
Browse files Browse the repository at this point in the history
Signed-off-by: AYUSH-D-PATNI <[email protected]>
  • Loading branch information
AYUSH-D-PATNI authored and AYUSH-D-PATNI committed Jan 9, 2025
1 parent 8e72556 commit de11acc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/functional/workloads/cnv/test_vm_pvc_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit de11acc

Please sign in to comment.