def test_dev_path_block_volume_create(self): """Validate dev path mapping for block volumes""" pvc_size, pvc_amount = 2, 5 pvs_info_before = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) self.detach_and_attach_vmdk(self.vm_name, self.node_hostname, self.devices_list) pvs_info_after = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) # Compare pvs info before and after for (path, uuid, vg_name), (_path, _uuid, _vg_name) in zip(pvs_info_before[:-1], pvs_info_after[1:]): self.assertEqual( uuid, _uuid, "pv_uuid check failed. Expected:{}," "Actual: {}".format(uuid, _uuid)) self.assertEqual( vg_name, _vg_name, "vg_name check failed. Expected:" "{}, Actual:{}".format(vg_name, _vg_name)) # Create block volumes pvcs = self.create_and_wait_for_pvcs(pvc_size=pvc_size, pvc_amount=pvc_amount) self.create_dcs_with_pvc(pvcs) self.validate_block_volumes_count(self.h_node, self.h_server, self.node_ip)
def _create_app_pod_and_verify_pvs(self): """Create block volume with app pod and verify IO's. Compare path, uuid, vg_name. """ pvc_size, pvc_amount = 2, 1 # Space to use for io's in KB space_to_use = 104857600 # Create block volumes pvc_name = self.create_and_wait_for_pvcs(pvc_size=pvc_size, pvc_amount=pvc_amount) # Create dcs and app pods with I/O on it dc_name = self.create_dcs_with_pvc(pvc_name, space_to_use=space_to_use) # Pod names list pod_name = [pod_name for _, pod_name in list(dc_name.values())][0] self.assertTrue(pod_name, "Failed to get the pod name from {}".format(dc_name)) # Fetch dc list dc_name = [pod for pod, _ in list(dc_name.values())][0] pvs_info_before = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) # Check if IO's are running use_percent_before = self._get_space_use_percent_in_app_pod(pod_name) # Compare volumes self.validate_file_volumes_count(self.h_node, self.h_server, self.node_ip) self.detach_and_attach_vmdk(self.vm_name, self.node_hostname, self.devices_list) # Check if IO's are running use_percent_after = self._get_space_use_percent_in_app_pod(pod_name) self.assertNotEqual( use_percent_before, use_percent_after, "Failed to execute IO's in the app pod {}".format(pod_name)) pvs_info_after = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) # Compare pvs info before and after for (path, uuid, vg_name), (_path, _uuid, _vg_name) in zip(pvs_info_before[:-1], pvs_info_after[1:]): self.assertEqual( uuid, _uuid, "pv_uuid check failed. Expected: {}," " Actual: {}".format(uuid, _uuid)) self.assertEqual( vg_name, _vg_name, "vg_name check failed. Expected: {}," " Actual:{}".format(vg_name, _vg_name)) return pod_name, dc_name, use_percent_before
def test_dev_path_block_volume_delete(self): """Validate device path name changes the deletion of already existing file volumes """ pvc_size, pvc_amount = 2, 5 pvc_names, gluster_block_list, vol_details = [], [], [] # Fetch BHV list h_bhv_list_before = heketi_ops.get_block_hosting_volume_list( self.h_node, self.h_server).keys() # Create storage class sc_name = self.create_storage_class() # Delete created BHV and BV as cleanup during failures self.addCleanup(self._cleanup_heketi_volumes, h_bhv_list_before) # Create PVC's for i in range(0, pvc_amount): pvc_name = openshift_ops.oc_create_pvc(self.node, sc_name, pvc_size=pvc_size) pvc_names.append(pvc_name) self.addCleanup(openshift_ops.wait_for_resource_absence, self.node, 'pvc', pvc_name) self.addCleanup(openshift_ops.oc_delete, self.node, 'pvc', pvc_name, raise_on_absence=False) # Wait for PVC's to be bound openshift_ops.wait_for_pvc_be_bound(self.node, pvc_names) # Get volume name list for pvc_name in pvc_names: pv_name = openshift_ops.get_pv_name_from_pvc(self.node, pvc_name) volume_name = openshift_ops.get_vol_names_from_pv(self.node, pv_name, vol_type='block') vol_details.append(volume_name) # Get BHV list after BV creation h_bhv_list_after = heketi_ops.get_block_hosting_volume_list( self.h_node, self.h_server).keys() self.assertTrue(h_bhv_list_after, "Failed to get the BHV list") # Validate BV's count self.validate_block_volumes_count(self.h_node, self.h_server, self.node_ip) # Collect pvs info and detach disks and collect pvs info pvs_info_before = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) self.detach_and_attach_vmdk(self.vm_name, self.node_hostname, self.devices_list) pvs_info_after = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) # Compare pvs info before and after for (path, uuid, vg_name), (_path, _uuid, _vg_name) in zip(pvs_info_before[:-1], pvs_info_after[1:]): self.assertEqual( uuid, _uuid, "pv_uuid check failed. Expected:{}," "Actual: {}".format(uuid, _uuid)) self.assertEqual( vg_name, _vg_name, "vg_name check failed. Expected:" "{}, Actual:{}".format(vg_name, _vg_name)) # Delete created PVC's for pvc_name in pvc_names: openshift_ops.oc_delete(self.node, 'pvc', pvc_name) # Wait for pvc to get deleted openshift_ops.wait_for_resources_absence(self.node, 'pvc', pvc_names) # Get existing BHV list for bhv_name in h_bhv_list_after: b_list = block_libs.get_block_list(self.node_ip, volname=bhv_name) self.assertIsNotNone(gluster_block_list, "Failed to get gluster block list") gluster_block_list.append(b_list) # Get list of block volumes using heketi h_blockvol_list = heketi_ops.heketi_blockvolume_list(self.h_node, self.h_server, json=True) # Validate volumes created are not present for vol in vol_details: self.assertNotIn(vol, gluster_block_list, "Failed to delete volume {}".format(vol)) self.assertNotIn(vol, h_blockvol_list['blockvolumes'], "Failed to delete blockvolume '{}'".format(vol))
def test_dev_path_file_volume_delete(self): """Validate device path name changes the deletion of already existing file volumes """ pvc_size, pvc_amount = 2, 5 vol_details, pvc_names = [], [] # Create PVC's sc_name = self.create_storage_class() for i in range(0, pvc_amount): pvc_name = openshift_ops.oc_create_pvc(self.node, sc_name, pvc_size=pvc_size) pvc_names.append(pvc_name) self.addCleanup(openshift_ops.wait_for_resource_absence, self.node, 'pvc', pvc_name) self.addCleanup(openshift_ops.oc_delete, self.node, 'pvc', pvc_name, raise_on_absence=False) # Wait for PVC's to be bound openshift_ops.wait_for_pvcs_be_bound(self.node, pvc_names) # Get Volumes name and validate volumes count for pvc_name in pvc_names: pv_name = openshift_ops.get_pv_name_from_pvc(self.node, pvc_name) volume_name = openshift_ops.get_vol_names_from_pv( self.node, pv_name) vol_details.append(volume_name) # Verify file volumes count self.validate_file_volumes_count(self.h_node, self.h_server, self.node_ip) # Collect pvs info and detach disks and get pvs info pvs_info_before = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) self.detach_and_attach_vmdk(self.vm_name, self.node_hostname, self.devices_list) pvs_info_after = openshift_storage_libs.get_pvs_info( self.node, self.node_ip, self.devices_list, raise_on_error=False) # Compare pvs info before and after for (path, uuid, vg_name), (_path, _uuid, _vg_name) in zip(pvs_info_before[:-1], pvs_info_after[1:]): self.assertEqual( uuid, _uuid, "pv_uuid check failed. Expected:{}," "Actual: {}".format(uuid, _uuid)) self.assertEqual( vg_name, _vg_name, "vg_name check failed. Expected:" "{}, Actual:{}".format(vg_name, _vg_name)) # Delete created PVC's for pvc_name in pvc_names: openshift_ops.oc_delete(self.node, 'pvc', pvc_name) # Wait for resource absence and get volume list openshift_ops.wait_for_resources_absence(self.node, 'pvc', pvc_names) vol_list = volume_ops.get_volume_list(self.node_ip) self.assertIsNotNone(vol_list, "Failed to get volumes list") # Validate volumes created are not present for vol in vol_details: self.assertNotIn(vol, vol_list, "Failed to delete volume {}".format(vol))