Пример #1
0
def test_verify_new_cbp_creation_not_blocked_by_invalid_cbp(teardown_factory):
    """
    Test to verify new ceph block pool can be created without deleting
    ceph block pool having invalid parameters
    Verifies bz 1711814
    """
    log.info("Trying creating ceph block pool with invalid failure domain.")
    cbp_invalid = helpers.create_ceph_block_pool(
        failure_domain="no-failure-domain", verify=False)
    teardown_factory(cbp_invalid)
    assert not helpers.verify_block_pool_exists(cbp_invalid.name), (
        f"Unexpected: Ceph Block Pool {cbp_invalid.name} created with "
        f"invalid failure domain.")
    log.info(
        f"Expected: {cbp_invalid.name} with invalid failure domain is not "
        f"present in pools list")

    log.info("Create valid ceph block pool")
    cbp_valid = helpers.create_ceph_block_pool(verify=False)
    teardown_factory(cbp_valid)
    assert helpers.verify_block_pool_exists(
        cbp_valid.name), f"Ceph Block Pool {cbp_valid.name} is not created."
    log.info(f"Verified: {cbp_valid.name} is created")
Пример #2
0
def setup_rbd():
    """
    Setting up the environment
    Creating replicated pool,secret,storageclass for rbd
    """
    log.info("Creating CephBlockPool")
    global RBD_POOL
    RBD_POOL = helpers.create_ceph_block_pool()
    global RBD_SECRET_OBJ
    RBD_SECRET_OBJ = helpers.create_secret(constants.CEPHBLOCKPOOL)
    global RBD_SC_OBJ
    log.info("Creating RBD Storage class ")
    RBD_SC_OBJ = helpers.create_storage_class(
        interface_type=constants.CEPHBLOCKPOOL,
        interface_name=RBD_POOL.name,
        secret_name=RBD_SECRET_OBJ.name,
    )
Пример #3
0
def create_ceph_block_pool(request):
    """
    Create a Ceph block pool
    """
    class_instance = request.node.cls

    def finalizer():
        """
        Delete the Ceph block pool
        """
        if hasattr(class_instance, "cbp_obj"):
            class_instance.cbp_obj.delete()

    request.addfinalizer(finalizer)

    class_instance.cbp_obj = helpers.create_ceph_block_pool()
    assert class_instance.cbp_obj, "Failed to create block pool"
    def test_remove_mon_pod_from_cluster(self):
        """
        To remove mon pod from the cluster
        after the I/O is performed on the pool
        and waiting for the operator to create a
        new mon pod on its own

        """
        ceph_cluster = CephCluster()
        pods = ocp.OCP(
            kind=constants.POD, namespace=config.ENV_DATA["cluster_namespace"]
        )
        list_mons = ceph_cluster.get_mons_from_cluster()
        assert len(list_mons) > 1, pytest.skip(
            "INVALID: Mon count should be more than one to delete."
        )
        self.pool_obj = create_ceph_block_pool()
        assert run_io_on_pool(self.pool_obj), "Failed to run I/O on the pool"
        assert delete_cephblockpools([self.pool_obj]), "Failed to delete pool"
        ceph_cluster.cluster_health_check(timeout=0)
        ceph_cluster.remove_mon_from_cluster()
        assert verify_mon_pod_up(pods), "Mon pods are not up and running state"
        ceph_cluster.cluster_health_check(timeout=60)
    def test_create_multiple_sc_with_different_pool_name(
            self, teardown_factory):
        """
        This test function does below,
        *. Creates multiple Storage Classes with different pool name
        *. Creates PVCs using each Storage Class
        *. Mount each PVC to an app pod
        *. Run IO on each app pod
        """

        # Create 2 storageclasses, each with different pool name
        cbp_list = []
        sc_list = []
        for i in range(2):
            log.info("Creating cephblockpool")
            cbp_obj = helpers.create_ceph_block_pool()
            log.info(f"{cbp_obj.name} created successfully")
            log.info(f"Creating a RBD storage class using {cbp_obj.name}")
            cbp_list.append(cbp_obj)
            sc_obj = helpers.create_storage_class(
                interface_type=constants.CEPHBLOCKPOOL,
                interface_name=cbp_obj.name,
                secret_name=self.rbd_secret_obj.name,
            )

            log.info(f"StorageClass: {sc_obj.name} "
                     f"created successfully using {cbp_obj.name}")
            sc_list.append(sc_obj)
            teardown_factory(cbp_obj)
            teardown_factory(sc_obj)

        # Create PVCs using each SC
        pvc_list = []
        for i in range(2):
            log.info(f"Creating a PVC using {sc_list[i].name}")
            pvc_obj = helpers.create_pvc(sc_list[i].name)
            log.info(f"PVC: {pvc_obj.name} created successfully using "
                     f"{sc_list[i].name}")
            pvc_list.append(pvc_obj)
            teardown_factory(pvc_obj)
            helpers.wait_for_resource_state(pvc_obj, constants.STATUS_BOUND)
            pvc_obj.reload()

        # Create app pod and mount each PVC
        pod_list = []
        for i in range(2):
            log.info(f"Creating an app pod and mount {pvc_list[i].name}")
            pod_obj = helpers.create_pod(
                interface_type=constants.CEPHBLOCKPOOL,
                pvc_name=pvc_list[i].name,
            )
            log.info(f"{pod_obj.name} created successfully and "
                     f"mounted {pvc_list[i].name}")
            pod_list.append(pod_obj)
            teardown_factory(pod_obj)
            helpers.wait_for_resource_state(pod_obj, constants.STATUS_RUNNING)
            pod_obj.reload()

        # Run IO on each app pod for sometime
        for pod in pod_list:
            log.info(f"Running FIO on {pod.name}")
            pod.run_io("fs", size="2G")

        for pod in pod_list:
            get_fio_rw_iops(pod)