def test_kafka_zk_pvc_info(): obj_name = "kafka-zk-pvc" config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name)) kcf = KubeObjectConfigFile(config_file=config_file, replacing=None) assert len(kcf.kube_objects) == 3 assert len(kcf.ping_info) == 3 for obj in kcf.ping_info: assert obj.validator == obj._validators["poll-for-existence"] assert len(kcf.status_info) == 3 for obj in kcf.status_info: assert obj.validator == obj._validators["poll-pvc-bound"] assert kcf.create_monitor_method == KUBE_OBJ_WAIT_MONITOR assert kcf.delete_monitor_method == KUBE_OBJ_WAIT_MONITOR
def test_axopsbootstrap_info(): obj_name = "axopsbootstrap" config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name)) kcf = KubeObjectConfigFile(config_file=config_file, replacing=None) assert len(kcf.kube_objects) == 1 assert len(kcf.ping_info) == 1 for obj in kcf.ping_info: assert obj.validator == obj._validators["poll-for-existence"] assert len(kcf.status_info) == 1 assert kcf.status_info[0].validator == kcf.status_info[0]._validators[ "poll-pod-healthy"] assert kcf.create_monitor_method == KUBE_OBJ_WAIT_MONITOR assert kcf.delete_monitor_method == KUBE_OBJ_WAIT_POLL
def __init__(self, name, client=None): self.name = name if client is None: self._client = KubernetesApiClient(use_proxy=True) else: self._client = client self._registry_spec = None self._software_info = SoftwareInfo() if self._software_info.registry_is_private(): secret = KubeObjectConfigFile(DEFAULT_SECRET_YAML_PATH, {"REGISTRY_SECRETS": self._software_info.registry_secrets}) for obj in secret.get_swagger_objects(): if isinstance(obj, swagger_client.V1Secret): self._registry_spec = obj assert self._registry_spec, "Argo registry specification is missing" self._am_service_spec = None self._am_deployment_spec = None # AA-2471: Hack to add AXOPS_EXT_DNS to Application Manager elb = InternalRoute("axops", "axsys", client=self._client) elb_status = elb.status(with_loadbalancer_info=True)["loadbalancer"][0] if not elb_status: raise AXPlatformException("Could not get axops elb address {}".format(elb_status)) replacements = {"NAMESPACE": self._software_info.image_namespace, "VERSION": self._software_info.image_version, "REGISTRY": self._software_info.registry, "APPLICATION_NAME": self.name, "AXOPS_EXT_DNS": elb_status} cluster_name_id = os.getenv("AX_CLUSTER_NAME_ID", None) assert cluster_name_id, "Cluster name id is None!" cluster_config = AXClusterConfig(cluster_name_id=cluster_name_id) if not cluster_config.get_cluster_provider().is_user_cluster(): axam_path = DEFAULT_AM_YAML_PATH else: axam_path = "/ax/config/service/argo-all/axam-svc.yml.in" replacements["ARGO_DATA_BUCKET_NAME"] = os.getenv("ARGO_DATA_BUCKET_NAME") logger.info("Using replacements: %s", replacements) k = KubeObjectConfigFile(axam_path, replacements) for obj in k.get_swagger_objects(): if isinstance(obj, swagger_client.V1Service): self._am_service_spec = obj elif isinstance(obj, swagger_client.V1beta1Deployment): self._am_deployment_spec = obj self._add_pod_metadata("deployment", self._am_deployment_spec.metadata.name, is_label=True) self._add_pod_metadata("ax_costid", json.dumps({ "app": self.name, "service": "axam-deployment", "user": "******" })) else: logger.debug("Ignoring specification of type {}".format(type(obj))) assert self._am_service_spec and self._am_deployment_spec, "Application monitor specification is missing"
def test_kafka_zk_svc_info(): obj_name = "kafka-zk-svc" config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name)) kcf = KubeObjectConfigFile(config_file=config_file, replacing=None) assert len(kcf.kube_objects) == 7 assert len(kcf.ping_info) == 7 for obj in kcf.ping_info: assert obj.validator == obj._validators["poll-for-existence"] assert len(kcf.status_info) == 7 for i in range(0, 4): assert kcf.status_info[i].validator == kcf.status_info[i]._validators[ "poll-for-existence"] for i in range(4, 7): assert kcf.status_info[i].validator == kcf.status_info[i]._validators[ "poll-pod-healthy"] assert kcf.create_monitor_method == KUBE_OBJ_WAIT_MONITOR assert kcf.delete_monitor_method == KUBE_OBJ_WAIT_POLL