Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating TestVmSnapshotClone tests with multi_cnv_workload fixture #11099

Merged
merged 21 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ocs_ci/ocs/cnv/virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ def _configure_dvt_clone(self, vm_data):
"storage": {
"accessModes": [self.pvc_access_mode],
"resources": {"requests": {"storage": self.pvc_size}},
"storageClassName": self.sc_name,
},
"source": {
"pvc": {
Expand Down
65 changes: 38 additions & 27 deletions tests/functional/workloads/cnv/test_vm_snapshot_cloning_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,62 @@ class TestVmSnapshotClone(E2ETest):

@workloads
@pytest.mark.polarion_id("OCS-6288")
def test_vm_clone(self, cnv_workload, clone_vm_workload, setup_cnv):
def test_vm_clone(
self, project_factory, multi_cnv_workload, clone_vm_workload, setup_cnv
):
"""
This test performs the VM cloning and IOs created using different volume interfaces(PVC/DV/DVT)
This test performs the VM cloning and IOs created using different
volume interfaces(PVC/DVT)

Test steps:
1. Create a clone of a VM PVC by following the documented procedure from ODF official docs.
1. Create a clone of a VM PVC by following the documented procedure
from ODF official docs.
1.1 Create clone of the pvc associated with VM.
1.2 Cloned pvc successfully created and listed
2. Verify the cloned PVc is created.
3. create vm using cloned pvc.
4. Verify that the data on VM backed by cloned pvc is same as that in the original VM.
2. Verify the cloned PVC is created.
3. Create a VM using cloned PVC.
4. Verify that the data on VM backed by cloned PVC is the
same as that in the original VM.
5. Add additional data to the cloned VM.
6. Delete the clone by following the documented procedure from ODF official docs
6.1 Delete clone of the pvc associated with VM.
6.2 cloned pvc successfully deleted
7. Repeat the above procedure for all the VMs in the system
6. Delete the clone by following the documented procedure from
ODF official docs
6.1 Delete the clone of the PVC associated with VM.
6.2 Cloned PVC successfully deleted
7. Repeat the above procedure for all the VMs
8. Delete all the clones created as part of this test
"""

proj_obj = project_factory()
file_paths = ["/source_file.txt", "/new_file.txt"]
# TODO: Add multi_cnv fixture to configure VMs based on specifications
volume_interface = [
constants.VM_VOLUME_PVC,
constants.VM_VOLUME_DV,
constants.VM_VOLUME_DVT,
]
for vl_if in volume_interface:
vm_obj = cnv_workload(
volume_interface=vl_if, source_url=constants.CNV_FEDORA_SOURCE
vm_objs_def, vm_objs_aggr, _, _ = multi_cnv_workload(
namespace=proj_obj.namespace
)
vm_list = vm_objs_def + vm_objs_aggr
log.info(f"Total VMs to process: {len(vm_list)}")
for index, vm_obj in enumerate(vm_list):
log.info(
f"Starting I/O operation on VM {vm_obj.name} using "
f"{file_paths[0]}..."
)
source_csum = run_dd_io(vm_obj=vm_obj, file_path=file_paths[0], verify=True)
log.info(f"Source checksum for {vm_obj.name}: {source_csum}")
log.info(f"Stopping VM {vm_obj.name}...")
vm_obj.stop()
log.info(f"Cloning VM {vm_obj.name}...")
clone_obj = clone_vm_workload(
vm_obj=vm_obj,
volume_interface=vl_if,
namespace=(
vm_obj.namespace if vl_if == constants.VM_VOLUME_PVC else None
),
volume_interface=vm_obj.volume_interface,
namespace=vm_obj.namespace,
)
log.info(
f"Clone created successfully for VM {vm_obj.name}: " f"{clone_obj.name}"
)
new_csum = cal_md5sum_vm(vm_obj=clone_obj, file_path=file_paths[0])
assert (
source_csum == new_csum
), f"Failed: MD5 comparison between source {vm_obj.name} and cloned {clone_obj.name} VMs"
assert source_csum == new_csum, (
f"Failed: MD5 comparison between source {vm_obj.name} "
f"and cloned {clone_obj.name} VMs"
)
run_dd_io(vm_obj=clone_obj, file_path=file_paths[1])
clone_obj.stop()

@workloads
@pytest.mark.polarion_id("OCS-6299")
Expand Down
Loading