def create_pvc_invalid_size(pvcsize): """ Creates a pvc with an user provided data Args: pvcsize (str): Size of the pvc to be created Returns: None """ pvc_data = defaults.CSI_PVC_DICT.copy() pvc_data['metadata']['name'] = "auto" pvc_data['spec']['resources']['requests']['storage'] = pvcsize pvc_data['spec']['storageClassName'] = SC_OBJ.name pvc_obj = PVC(**pvc_data) log.info(f"Creating a PVC with size {pvcsize}") try: pvc_obj.create() except CommandFailed as ex: error = "quantities must match the regular expression '^([+-]?[0-9.]"\ "+)([eEinumkKMGTP]*[-+]?[0-9]*)$'" if error in str(ex): log.info(f"PVC creation failed with error \n {ex} \n as " "invalid pvc size is provided. EXPECTED") else: assert ("PVC creation with invalid size succeeded : " "NOT expected")
def create_pvc_invalid_name(pvcname): """ Creates a pvc with an user provided data Args: pvcname (str): Name of the pvc to be created Returns: None """ pvc_data = defaults.CSI_PVC_DICT.copy() pvc_data['metadata']['name'] = pvcname pvc_data['spec']['storageClassName'] = SC_OBJ.name pvc_obj = PVC(**pvc_data) log.info(f"Creating a pvc with name {pvcname}") try: pvc_obj.create() except CommandFailed as ex: error = "subdomain must consist of lower case alphanumeric "\ "characters, '-' or '.', and must start and end with "\ "an alphanumeric character" if error in str(ex): log.info(f"PVC creation failed with error \n {ex} \n as " "invalid pvc name is provided. EXPECTED") else: assert ("PVC creation with invalid name succeeded : " "NOT expected")
def test_ocs_336(self, test_fixture): """ Testing basics: secret creation, storage class creation and pvc with cephfs """ self.cephfs_secret = defaults.CSI_CEPHFS_SECRET.copy() del self.cephfs_secret['data']['userID'] del self.cephfs_secret['data']['userKey'] self.cephfs_secret['data']['adminKey'] = ( get_admin_key_from_ceph_tools()) self.cephfs_secret['data']['adminID'] = constants.ADMIN_BASE64 logging.info(self.cephfs_secret) secret = OCS(**self.cephfs_secret) secret.create() self.cephfs_sc = defaults.CSI_CEPHFS_STORAGECLASS_DICT.copy() self.cephfs_sc['parameters']['monitors'] = self.mons self.cephfs_sc['parameters']['pool'] = ( f"{self.fs_data['metadata']['name']}-data0") storage_class = OCS(**self.cephfs_sc) storage_class.create() self.cephfs_pvc = defaults.CSI_CEPHFS_PVC.copy() pvc = PVC(**self.cephfs_pvc) pvc.create() log.info(pvc.status) assert 'Bound' in pvc.status pvc.delete() storage_class.delete() secret.delete()
def test_storageclass_invalid(self, invalid_storageclass): """ Test that Persistent Volume Claim can not be created from misconfigured CephFS Storage Class. """ pvc_data = defaults.CSI_PVC_DICT.copy() pvc_name = helpers.create_unique_resource_name('test', 'pvc') pvc_data['metadata']['name'] = pvc_name pvc_data['metadata']['namespace'] = defaults.ROOK_CLUSTER_NAMESPACE pvc_data['spec']['storageClassName'] = invalid_storageclass[ 'metadata']['name'] logger.info(f"Create PVC {pvc_name} " f"with storageClassName " f"{invalid_storageclass['metadata']['name']}") pvc = PVC(**pvc_data) pvc.create() pvc_status = pvc.status logger.debug(f"Status of PVC {pvc_name} after creation: {pvc_status}") assert pvc_status == constants.STATUS_PENDING logger.info(f"Waiting for status '{constants.STATUS_BOUND}' " f"for 60 seconds (it shouldn't change)") with pytest.raises(TimeoutExpiredError): # raising TimeoutExpiredError is expected behavior pvc_status_changed = pvc.ocp.wait_for_resource( resource_name=pvc_name, condition=constants.STATUS_BOUND, timeout=60, sleep=20) logger.debug('Check that PVC status did not changed') assert not pvc_status_changed pvc_status = pvc.status logger.info(f"Status of PVC {pvc_name} after 60 seconds: {pvc_status}") assert_msg = (f"PVC {pvc_name} hasn't reached status " f"{constants.STATUS_PENDING}") assert pvc_status == constants.STATUS_PENDING, assert_msg logger.info(f"Deleting PVC {pvc_name}") pvc.delete()
def test_ocs_346(self): """ Testing basics: secret creation, storage class creation and pvc with rbd """ self.rbd_secret = defaults.CSI_RBD_SECRET.copy() del self.rbd_secret['data']['kubernetes'] self.rbd_secret['data']['admin'] = get_admin_key_from_ceph_tools() logging.info(self.rbd_secret) secret = OCS(**self.rbd_secret) secret.create() self.rbd_sc = defaults.CSI_RBD_STORAGECLASS_DICT.copy() self.rbd_sc['parameters']['monitors'] = self.mons del self.rbd_sc['parameters']['userid'] storage_class = OCS(**self.rbd_sc) storage_class.create() self.rbd_pvc = defaults.CSI_RBD_PVC.copy() pvc = PVC(**self.rbd_pvc) pvc.create() assert 'Bound' in pvc.status pvc.delete() storage_class.delete() secret.delete()