示例#1
0
def cleanup(namespace):
    """
    Delete all OBCs created in the cluster

    Args:
        namespace (str): Namespace of OBC's deleting

    """
    obc_name_list = oc_get_all_obc_names()
    log.info(f"Deleting {len(obc_name_list)} OBCs")
    if obc_name_list:
        for i in obc_name_list:
            run_cmd(f"oc delete obc {i} -n {namespace}")
示例#2
0
 def internal_verify_deletion(self):
     return self.name not in oc_get_all_obc_names()
    def test_scale_obc_create_delete_time(self, tmp_path):
        """
        MCG OBC creation and deletion using Noobaa MCG storage class

        """

        log.info(f"Start creating  {self.scale_obc_count} "
                 f"OBCs in a batch of {self.num_obc_batch}")
        obc_create = dict()
        obc_delete = dict()
        for i in range(int(self.scale_obc_count / self.num_obc_batch)):
            obc_dict_list = (
                scale_noobaa_lib.construct_obc_creation_yaml_bulk_for_kube_job(
                    no_of_obc=self.num_obc_batch,
                    sc_name=constants.NOOBAA_SC,
                    namespace=self.namespace,
                ))
            # Create job profile
            job_file = ObjectConfFile(
                name="job_profile",
                obj_dict_list=obc_dict_list,
                project=self.namespace,
                tmp_path=tmp_path,
            )
            # Create kube_job
            job_file.create(namespace=self.namespace)

            # Check all the OBCs to reach Bound state
            obc_bound_list = (
                scale_noobaa_lib.check_all_obc_reached_bound_state_in_kube_job(
                    kube_job_obj=job_file,
                    namespace=self.namespace,
                    no_of_obc=self.num_obc_batch,
                ))
            log.info(f"Number of OBCs in Bound state {len(obc_bound_list)}")

            # Measure obc creation and deletion time
            obc_creation_time = scale_noobaa_lib.measure_obc_creation_time(
                obc_name_list=obc_bound_list)
            obc_create.update(obc_creation_time)

        # Delete all obcs in a batch
        obc_name_list = list(oc_get_all_obc_names())
        new_list = [
            obc_name_list[i:i + 20]
            for i in range(0, len(obc_name_list), self.num_obc_batch)
        ]

        for i in range(len(new_list)):
            scale_noobaa_lib.cleanup(self.namespace, obc_count=new_list[i])
            obc_deletion_time = scale_noobaa_lib.measure_obc_deletion_time(
                obc_name_list=new_list[i])
            obc_delete.update(obc_deletion_time)

        # Store obc creation time on csv file
        log_path = f"{ocsci_log_path()}/obc-creation"
        with open(f"{log_path}-{constants.NOOBAA_SC}.csv", "w") as fd:
            csv_obj = csv.writer(fd)
            for k, v in obc_create.items():
                csv_obj.writerow([k, v])
        log.info(
            f"OBC creation data present in {log_path}-{constants.NOOBAA_SC}.csv"
        )

        # Store obc deletion time on csv file
        log_path = f"{ocsci_log_path()}/obc-deletion"
        with open(f"{log_path}-{constants.NOOBAA_SC}.csv", "w") as fd:
            csv_obj = csv.writer(fd)
            for k, v in obc_create.items():
                csv_obj.writerow([k, v])
        log.info(
            f"OBC deletion data present in {log_path}-{constants.NOOBAA_SC}.csv"
        )