diff --git a/ocs_ci/ocs/cnv/virtual_machine.py b/ocs_ci/ocs/cnv/virtual_machine.py index bcf003f65a1..23bfe56d95f 100644 --- a/ocs_ci/ocs/cnv/virtual_machine.py +++ b/ocs_ci/ocs/cnv/virtual_machine.py @@ -778,6 +778,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": { diff --git a/tests/functional/workloads/cnv/test_vm_snapshot_cloning_ops.py b/tests/functional/workloads/cnv/test_vm_snapshot_cloning_ops.py index 81a04794e1b..a1360e42366 100644 --- a/tests/functional/workloads/cnv/test_vm_snapshot_cloning_ops.py +++ b/tests/functional/workloads/cnv/test_vm_snapshot_cloning_ops.py @@ -17,51 +17,67 @@ 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 + 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 in the system 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 index, vl_if in enumerate(volume_interface): - vm_obj = cnv_workload( - volume_interface=vl_if, source_url=constants.CNV_FEDORA_SOURCE - )[index] + 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), )[index] + 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() + log.info("Test completed successfully for all VMs.") @workloads @pytest.mark.polarion_id("OCS-6299")