Ejemplo n.º 1
0
 def one_pvc_two_pod(self, value_sc):
     d.set_test_namespace_value(self.test_ns)
     sc_name = d.get_random_name("sc")
     config.load_kube_config(config_file=kubeconfig_value)
     d.create_storage_class(value_sc, self.config_file, sc_name)
     d.check_storage_class(sc_name)
     value_pvc_pass = copy.deepcopy(self.value_pvc[0])
     pvc_name = d.get_random_name("pvc")
     d.create_pvc(value_pvc_pass, sc_name, pvc_name)
     val = d.check_pvc(value_pvc_pass, sc_name, pvc_name)
     if val is True:
         pod_name_1 = d.get_random_name("pod")
         d.create_pod(self.value_pod[0], pvc_name, pod_name_1)
         d.check_pod(self.value_pod[0], sc_name, pvc_name, pod_name_1)
         pod_name_2 = d.get_random_name("pod")
         d.create_pod(self.value_pod[0], pvc_name, pod_name_2)
         d.check_pod(self.value_pod[0], sc_name, pvc_name, pod_name_2)
         d.delete_pod(pod_name_1)
         d.check_pod_deleted(pod_name_1)
         d.delete_pod(pod_name_2)
         d.check_pod_deleted(pod_name_2)
     d.delete_pvc(pvc_name)
     d.check_pvc_deleted(pvc_name)
     if d.check_storage_class(sc_name):
         d.delete_storage_class(sc_name)
     d.check_storage_class_deleted(sc_name)
Ejemplo n.º 2
0
 def test_dynamic(self, value_sc):
     LOGGER.info(
         f"Testing Dynamic Provisioning with following PVC parameters {str(self.value_pvc)}"
     )
     d.set_test_namespace_value(self.test_ns)
     sc_name = d.get_random_name("sc")
     config.load_kube_config(config_file=kubeconfig_value)
     d.create_storage_class(value_sc, self.config_file, sc_name)
     d.check_storage_class(sc_name)
     for num in range(0, len(self.value_pvc)):
         value_pvc_pass = copy.deepcopy(self.value_pvc[num])
         if (check_key(value_sc, "reason")):
             if not (check_key(value_pvc_pass, "reason")):
                 value_pvc_pass["reason"] = value_sc["reason"]
         LOGGER.info(100 * "=")
         pvc_name = d.get_random_name("pvc")
         d.create_pvc(value_pvc_pass, sc_name, pvc_name)
         val = d.check_pvc(value_pvc_pass, sc_name, pvc_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)
                 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)
     LOGGER.info(100 * "=")
     if d.check_storage_class(sc_name):
         d.delete_storage_class(sc_name)
     d.check_storage_class_deleted(sc_name)
 def __init__(self, kubeconfig, test_namespace, keep_objects, value_pvc, value_vs_class, number_of_snapshots, image_name, cluster_id):
     config.load_kube_config(config_file=kubeconfig)
     self.value_pvc = value_pvc
     self.value_vs_class = value_vs_class
     self.number_of_snapshots = number_of_snapshots
     self.image_name = image_name
     self.cluster_id = cluster_id
     d.set_test_namespace_value(test_namespace)
     snapshot.set_test_namespace_value(test_namespace)
     cleanup.set_keep_objects(keep_objects)
     cleanup.set_test_namespace_value(test_namespace)
 def __init__(self, kubeconfig_value, value_pvc, value_pod, cluster_id, test_ns, keep_object, image_name):
     self.value_pvc = value_pvc
     self.value_pod = value_pod
     self.cluster_id = cluster_id
     self.test_ns = test_ns
     self.keep_objects = keep_object
     self.kubeconfig = kubeconfig_value
     self.image_name = image_name
     d.set_test_namespace_value(self.test_ns)
     cleanup.set_keep_objects(self.keep_objects)
     cleanup.set_test_namespace_value(self.test_ns)
Ejemplo n.º 5
0
    def parallel_pvc(self, value_sc):
        d.set_test_namespace_value(self.test_ns)
        sc_name = d.get_random_name("sc")
        config.load_kube_config(config_file=kubeconfig_value)
        d.create_storage_class(value_sc, self.config_file, sc_name)
        d.check_storage_class(sc_name)
        p = []
        number_of_pvc = self.config_file["number_of_parallel_pvc"]
        for num in range(0, number_of_pvc):
            p.append(
                multiprocessing.Process(target=self.parallel_pvc_process,
                                        args=[sc_name]))
            p[num].start()
        for num in range(0, number_of_pvc - 1):
            p[num].join()

        LOGGER.info(100 * "-")
        if d.check_storage_class(sc_name):
            d.delete_storage_class(sc_name)
        d.check_storage_class_deleted(sc_name)
Ejemplo n.º 6
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)