def _get_perdb_ycsb_config(self, config: Dict[str, object]):
     if self.target is configurator_enums.DBTarget.cassandra:
         return template.get_tempdir_with_config(
             path.join(self.config_root, "target_cassandra"), config)
     if self.target is configurator_enums.DBTarget.spilo_postgres:
         return template.get_tempdir_with_config(
             path.join(self.config_root, "target_spilo_postgres"), config)
     if self.target is configurator_enums.DBTarget.redis:
         return template.get_tempdir_with_config(
             path.join(self.config_root, "target_redis"), config)
     warnings.warn("Unable to get_perdb_ycsb_config, no client match.")
 def prepare(self, config: Dict[str, object],
             kube_context: launch.KubeContext, pod_ids: Dict[str,
                                                             List[str]]):
     # Load in the configuration file
     ycsb_record_count = config["ycsb_record_count"]
     config.update(
         {"insertcount": (ycsb_record_count // len(pod_ids["ycsb"]))})
     # FIXME: Move this to a cassandra-specific location
     if "ycsb_cassandra_readconsistency" not in config:
         config[
             "ycsb_cassandra_readconsistency"] = "ONE"  # Default for YCSB cassandra-cql
     if "ycsb_cassandra_writeconsistency" not in config:
         config[
             "ycsb_cassandra_writeconsistency"] = "ONE"  # Default for YCSB cassandra-cql
     self._set_database_name(config)
     for pod_idx, pod_id in enumerate(pod_ids["ycsb"]):
         config.update({
             "insertstart":
             (ycsb_record_count // len(pod_ids["ycsb"])) * pod_idx
         })
         ycsb_perdb_configuration_file_dir = self._get_perdb_ycsb_config(
             config)
         assert (ycsb_perdb_configuration_file_dir is not None)
         self.open_temp_dirs.append(ycsb_perdb_configuration_file_dir)
         kube_context.copy_to_pod(pod_id,
                                  ycsb_perdb_configuration_file_dir.name,
                                  "/properties/")
         ycsb_shared_configuration_file_dir = template.get_tempdir_with_config(
             path.join(self.config_root, "shared"), config)
         assert (ycsb_shared_configuration_file_dir is not None)
         self.open_temp_dirs.append(ycsb_shared_configuration_file_dir)
         kube_context.copy_to_pod(pod_id,
                                  ycsb_shared_configuration_file_dir.name,
                                  "/shared/")
     pass
Esempio n. 3
0
 def deploy(self, config: Dict[str, object],
            kube_context: launch.KubeContext):
     for k, v in config["param_config"].items():
         try:
             identifier, param = k.split(":")
             if identifier == "redis":
                 config["redis_config"][param] = v
             else:
                 warnings.warn("Unrecognized {0} parameter: {1}".format(
                     identifier, param))
         except Exception:
             warnings.warn("Unrecognized parameter: {}".format(k))
             continue
     config.update({
         "cluster_enabled_yesno":
         "yes" if config["redis_replicas"] > 1 else "no",
         "cluster_enabled_truefalse":
         "true" if config["redis_replicas"] > 1 else "false",
         "namespace_name":
         kube_context.namespace_name,
         "config_items":
         "\n".join([
             "{0} {1}".format(key, value)
             for key, value in config["redis_config"].items()
         ])
     })
     kubeconfig_dir = template.get_tempdir_with_config(
         path.join(self.config_root, "kubernetes"), config)
     self.open_temp_dirs.append(
         kubeconfig_dir
     )  # TODO: This is only needed for the next line, clean up later?
     kube_context.apply_kubectl_yaml_config(kubeconfig_dir.name)
 def deploy(self, config: Dict[str, object],
            kube_context: launch.KubeContext):
     ycsb_kubernetes_config_dir = template.get_tempdir_with_config(
         path.join(self.config_root, "kubernetes"), config)
     self.open_temp_dirs.append(
         ycsb_kubernetes_config_dir
     )  # TODO: This is only needed for the next line, clean up later?
     kube_context.apply_kubectl_yaml_config(ycsb_kubernetes_config_dir.name)
Esempio n. 5
0
 def deploy(self, config: Dict[str, object],
            kube_context: launch.KubeContext):
     config.update({"namespace_name": kube_context.namespace_name})
     for k, v in config["param_config"].items():
         try:
             identifier, param = k.split(":")
             if identifier == "postgres":
                 config["postgres_config"][param] = v
             else:
                 warnings.warn("Unrecognized {0} parameter: {1}".format(
                     identifier, param))
         except Exception:
             warnings.warn("Unrecognized parameter: {}".format(k))
             continue
     kubeconfig_dir = template.get_tempdir_with_config(
         path.join(self.config_root, "kubernetes"), config)
     self.open_temp_dirs.append(
         kubeconfig_dir
     )  # TODO: This is only needed for the next line, clean up later?
     with open(path.join(kubeconfig_dir.name, "minimal-manifest.yaml"),
               "r+") as manifest_config:
         minimal_manifest_yaml = yaml.load(manifest_config,
                                           Loader=yaml.SafeLoader)
         postgresql_spec = minimal_manifest_yaml["spec"]["postgresql"]
         if "parameters" not in postgresql_spec:
             # convert to string since the postgresql crd spec only accepts string type
             postgresql_spec["parameters"] = {
                 k: str(v)
                 for k, v in config["postgres_config"].items()
             }
         else:
             postgresql_spec["parameters"].update(
                 {k: str(v)
                  for k, v in config["postgres_config"].items()})
         manifest_config.seek(0)
         manifest_config.truncate(0)
         manifest_config.write(yaml.dump(minimal_manifest_yaml))
     # Waiting not necessary for CRD
     kube_context.apply_kubectl_yaml_config(path.join(
         kubeconfig_dir.name, "zalando", "manifests",
         "postgresql.crd.yaml"),
                                            wait_for_ready=False)
     time.sleep(1)
     kube_context.apply_kubectl_yaml_config(kubeconfig_dir.name,
                                            wait_for_ready=False)
     kube_context.apply_kubectl_yaml_config(path.join(
         kubeconfig_dir.name, "cluster-level-rbac-patch.yaml"),
                                            namespaced=False)
     # Need to wait manually because zalando postgres operator uses a CustomResourceDefinition that is not easily parseable to get StatefulSets
     kube_context._sts_wait("acid-minimal-cluster",
                            config["postgres_replicas"])
 def get_kubernetes_yaml(self, config: Dict[str, object] = {}):
     temp_yaml = template.get_tempdir_with_config(self.config_root, config)
     self.open_temp_dirs.append(temp_yaml)
     return temp_yaml.name