def values(request):
    global data, remote_data, snapshot_object, kubeconfig_value  # are required in every testcase
    kubeconfig_value, clusterconfig_value, namespace_value, runslow_val = scaleop.get_cmd_values(request)

    data = scaleop.read_driver_data(clusterconfig_value, namespace_value)
    operator_data = scaleop.read_operator_data(clusterconfig_value, namespace_value)
    keep_objects = data["keepobjects"]
    if not("remote" in data):
        LOGGER.error("remote data is not provided in cr file")
        assert False
    test_namespace = namespace_value

    remote_data = get_remote_data(data)
    ff.cred_check(data)
    ff.cred_check(remote_data)
    ff.set_data(remote_data)

    operator = scaleop.Scaleoperator(kubeconfig_value, namespace_value)
    operator_object = scaleop.Scaleoperatorobject(operator_data, kubeconfig_value)
    condition = scaleop.check_ns_exists(kubeconfig_value, namespace_value)
    if condition is True:
        if not(operator_object.check()):
            LOGGER.error("Operator custom object is not deployed succesfully")
            assert False
    else:
        operator.create()
        operator.check()
        scaleop.check_nodes_available(operator_data["pluginNodeSelector"], "pluginNodeSelector")
        scaleop.check_nodes_available(
            operator_data["provisionerNodeSelector"], "provisionerNodeSelector")
        scaleop.check_nodes_available(
            operator_data["attacherNodeSelector"], "attacherNodeSelector")
        operator_object.create()
        val = operator_object.check()
        if val is True:
            LOGGER.info("Operator custom object is deployed succesfully")
        else:
            LOGGER.error("Operator custom object is not deployed succesfully")
            assert False
    if runslow_val:
        value_pvc = [{"access_modes": "ReadWriteMany", "storage": "1Gi"},
                     {"access_modes": "ReadWriteOnce", "storage": "1Gi"}]
    else:
        value_pvc = [{"access_modes": "ReadWriteMany", "storage": "1Gi"}]
    value_vs_class = {"deletionPolicy": "Delete"}
    number_of_snapshots = 1
    snapshot_object = scaleop.Snapshot(kubeconfig_value, test_namespace, keep_objects, value_pvc, value_vs_class,
                               number_of_snapshots, data["image_name"], remote_data["id"])
    ff.create_dir(remote_data["volDirBasePath"])
    yield
    if condition is False and not(keep_objects):
        operator_object.delete()
        operator.delete()
        if(ff.fileset_exists(data)):
            ff.delete_fileset(data)
Exemple #2
0
    def test_static(self, pv_value, pvc_value, sc_value=False, wrong=None, root_volume=False):

        config.load_kube_config(config_file=self.kubeconfig)
        created_objects = get_cleanup_dict()
        sc_name = ""
        if sc_value is not False:
            sc_name = d.get_random_name("sc")
            d.create_storage_class(sc_value,  sc_name, created_objects)
            d.check_storage_class(sc_name)
        FSUID = ff.get_FSUID()
        cluster_id = self.cluster_id
        if wrong is not None:
            if wrong["id_wrong"] is True:
                cluster_id = int(cluster_id)+1
                cluster_id = str(cluster_id)
            if wrong["FSUID_wrong"] is True:
                FSUID = "AAAA"

        mount_point = ff.get_mount_point()
        if root_volume is False:
            dir_name = d.get_random_name("dir")
            ff.create_dir(dir_name)
            created_objects["dir"].append(dir_name)
            pv_value["volumeHandle"] = cluster_id+";"+FSUID + \
                ";path="+mount_point+"/"+dir_name
        elif root_volume is True:
            pv_value["volumeHandle"] = cluster_id+";"+FSUID + \
                ";path="+mount_point

        if pvc_value == "Default":
            pvc_value = copy.deepcopy(self.value_pvc)

        num_final = len(pvc_value)
        for num in range(0, num_final):
            pv_name = d.get_random_name("pv")
            d.create_pv(pv_value, pv_name, created_objects, sc_name)
            d.check_pv(pv_name)

            value_pvc_pass = copy.deepcopy(pvc_value[num])
            if (check_key(pv_value, "reason")):
                if not(check_key(value_pvc_pass, "reason")):
                    value_pvc_pass["reason"] = pv_value["reason"]
            LOGGER.info(100*"=")
            pvc_name = d.get_random_name("pvc")
            d.create_pvc(value_pvc_pass, sc_name, pvc_name, created_objects, pv_name)
            val = d.check_pvc(value_pvc_pass, pvc_name, created_objects, pv_name)
            if val is True:
                for num2 in range(0, len(self.value_pod)):
                    LOGGER.info(100*"-")
                    pod_name = d.get_random_name("pod")
                    d.create_pod(self.value_pod[num2], pvc_name, pod_name, created_objects, self.image_name)
                    d.check_pod(self.value_pod[num2], pod_name, created_objects)
                    cleanup.delete_pod(pod_name, created_objects)
                    cleanup.check_pod_deleted(pod_name, created_objects)
                    if value_pvc_pass["access_modes"] == "ReadWriteOnce" and self.keep_objects is True:
                        break
                LOGGER.info(100*"-")
            vol_name = cleanup.delete_pvc(pvc_name, created_objects)
            cleanup.check_pvc_deleted(pvc_name, vol_name, created_objects)
            cleanup.delete_pv(pv_name, created_objects)
            cleanup.check_pv_deleted(pv_name, created_objects)
        LOGGER.info(100*"=")
        cleanup.clean_with_created_objects(created_objects)
Exemple #3
0
    def test_static(self,
                    pv_value,
                    pvc_value,
                    sc_value=False,
                    wrong=None,
                    root_volume=False):

        config.load_kube_config(config_file=kubeconfig_value)
        d.set_test_namespace_value(self.test_ns)
        sc_name = ""
        if sc_value is not False:
            sc_name = d.get_random_name("sc")
            d.create_storage_class(sc_value, self.config_file, sc_name)
            d.check_storage_class(sc_name)
        FSUID = get_FSUID(self.config_file)
        cluster_id = self.config_file["id"]
        if wrong is not None:
            if wrong["id_wrong"] is True:
                cluster_id = int(cluster_id) + 1
                cluster_id = str(cluster_id)
            if wrong["FSUID_wrong"] is True:
                FSUID = "AAAA"

        mount_point = get_mount_point(self.config_file)
        if root_volume is False:
            dir_name = d.get_random_name("dir")
            create_dir(self.config_file, dir_name)
            pv_value["volumeHandle"] = cluster_id+";"+FSUID + \
                ";path="+mount_point+"/"+dir_name
        elif root_volume is True:
            pv_value["volumeHandle"] = cluster_id+";"+FSUID + \
                ";path="+mount_point
            dir_name = "nodiravailable"

        if pvc_value == "Default":
            pvc_value = copy.deepcopy(self.value_pvc)

        num_final = len(pvc_value)
        for num in range(0, num_final):
            pv_name = d.get_random_name("pv")
            d.create_pv(pv_value, pv_name, sc_name)
            d.check_pv(pv_name)

            value_pvc_pass = copy.deepcopy(pvc_value[num])
            if (check_key(pv_value, "reason")):
                if not (check_key(value_pvc_pass, "reason")):
                    value_pvc_pass["reason"] = pv_value["reason"]
            LOGGER.info(100 * "=")
            pvc_name = d.get_random_name("pvc")
            d.create_pvc(value_pvc_pass, sc_name, pvc_name, self.config_file,
                         pv_name)
            val = d.check_pvc(value_pvc_pass, sc_name, pvc_name, dir_name,
                              pv_name)
            if val is True:
                for num2 in range(0, len(self.value_pod)):
                    LOGGER.info(100 * "-")
                    pod_name = d.get_random_name("pod")
                    d.create_pod(self.value_pod[num2], pvc_name, pod_name)
                    d.check_pod(self.value_pod[num2], sc_name, pvc_name,
                                pod_name, dir_name, pv_name)
                    d.delete_pod(pod_name)
                    d.check_pod_deleted(pod_name)
                LOGGER.info(100 * "-")
            d.delete_pvc(pvc_name)
            d.check_pvc_deleted(pvc_name)
            d.delete_pv(pv_name)
            d.check_pv_deleted(pv_name)
        LOGGER.info(100 * "=")
        delete_dir(self.config_file, dir_name)

        if d.check_storage_class(sc_name):
            d.delete_storage_class(sc_name)
        d.check_storage_class_deleted(sc_name)