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)
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)