예제 #1
0
def test_redis_svc_info():
    obj_name = "redis-svc"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 2

    svc = KubeObjectInfo(components[0])
    assert svc.kube_kind == KubeKind.SERVICE
    assert svc.monitor_label == "app=redis"
    assert svc.name == "redis"
    assert svc.replica == 1
    assert not svc.svc_elb
    assert not svc.extra_poll
    assert svc.usage == (0, 0, 0, 0)

    dep = KubeObjectInfo(components[1])
    assert dep.kube_kind == KubeKind.DEPLOYMENT
    assert dep.monitor_label == "app=redis-deployment"
    assert dep.name == "redis-deployment"
    assert dep.replica == 1
    assert not dep.svc_elb
    assert not dep.extra_poll
    assert dep.usage == (50, 50, 0, 0)
예제 #2
0
def test_axdb_svc_info():
    obj_name = "axdb-svc"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 2

    svc = KubeObjectInfo(components[0])
    assert svc.kube_kind == KubeKind.SERVICE
    assert svc.monitor_label == "app=axdb"
    assert svc.name == "axdb"
    assert svc.replica == 1
    assert not svc.svc_elb
    assert not svc.extra_poll
    assert svc.usage == (0, 0, 0, 0)

    dep = KubeObjectInfo(components[1])
    assert dep.kube_kind == KubeKind.STATEFULSET
    assert dep.monitor_label == "app=axdbstatefulset"
    assert dep.name == "axdb"
    assert dep.replica == 3
    assert not dep.svc_elb
    assert not dep.extra_poll
    assert dep.usage == (300, 6900, 0, 0)
예제 #3
0
def test_kafka_zk_svc_info():
    obj_name = "kafka-zk-svc"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 7

    svc = KubeObjectInfo(components[0])
    assert svc.kube_kind == KubeKind.SERVICE
    assert svc.monitor_label == "app=kafka-zk-svc"
    assert svc.name == "kafka-zk"
    assert svc.replica == 1
    assert not svc.svc_elb
    assert not svc.extra_poll
    assert svc.usage == (0, 0, 0, 0)

    for i in range(1, 4):
        sub_svc = KubeObjectInfo(components[i])
        assert sub_svc.kube_kind == KubeKind.SERVICE
        assert sub_svc.monitor_label == "app=kafka-zk-{}-svc".format(i)
        assert sub_svc.name == "kafka-zk-{}".format(i)
        assert sub_svc.replica == 1
        assert not sub_svc.svc_elb
        assert not sub_svc.extra_poll
        assert sub_svc.usage == (0, 0, 0, 0)

    for i in range(4, 7):
        dep = KubeObjectInfo(components[i])
        assert dep.kube_kind == KubeKind.DEPLOYMENT
        assert dep.monitor_label == "app=kafka-zk-{}".format(i-3)
        assert dep.name == "kafka-zk-{}".format(i-3)
        assert dep.replica == 1
        assert not dep.svc_elb
        assert not dep.extra_poll
        assert dep.usage == (150, 700, 0, 0)
예제 #4
0
def test_axopsbootstrap_info():
    obj_name = "axopsbootstrap"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 1

    pod = KubeObjectInfo(components[0])
    assert pod.kube_kind == KubeKind.POD
    assert pod.monitor_label == "app=axops-bootstrap"
    assert pod.name == "axops-bootstrap-pod"
    assert pod.replica == 1
    assert not pod.svc_elb
    assert not pod.extra_poll
    assert pod.usage == (0, 0, 0, 0)
예제 #5
0
def test_axops_svc_info():
    obj_name = "axops-svc"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 1

    svc = KubeObjectInfo(components[0])
    assert svc.kube_kind == KubeKind.SERVICE
    assert svc.monitor_label == "app=axops"
    assert svc.name == "axops"
    assert svc.replica == 1
    assert svc.svc_elb
    assert not svc.extra_poll
    assert svc.usage == (0, 0, 0, 0)
예제 #6
0
def test_elasticsearch_pvc_info():
    obj_name = "redis-pvc"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 1

    dep = KubeObjectInfo(components[0])
    assert dep.kube_kind == KubeKind.PVC
    assert dep.monitor_label == "app=redis"
    assert dep.name == "redis-pvc"
    assert dep.replica == 1
    assert not dep.svc_elb
    assert not dep.extra_poll
    assert dep.usage == (0, 0, 0, 0)
예제 #7
0
def test_registry_secrets_info():
    obj_name = "registry-secrets"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 1

    dep = KubeObjectInfo(components[0])
    assert dep.kube_kind == KubeKind.SECRET
    assert dep.monitor_label == "app=axsecret"
    assert dep.name == "applatix-registry"
    assert dep.replica == 1
    assert not dep.svc_elb
    assert not dep.extra_poll
    assert dep.usage == (0, 0, 0, 0)
예제 #8
0
def test_vmf_info():
    obj_name = "volume-mounts-fixer"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 1

    dep = KubeObjectInfo(components[0])
    assert dep.kube_kind == KubeKind.DAEMONSET
    assert dep.monitor_label == "app=volume-mounts-fixer"
    assert dep.name == "volume-mounts-fixer"
    assert dep.replica == 1
    assert not dep.svc_elb
    assert dep.extra_poll
    assert dep.usage == (0, 0, 25, 60)
예제 #9
0
def test_autoscaler_info():
    obj_name = "autoscaler"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 1

    dep = KubeObjectInfo(components[0])
    assert dep.kube_kind == KubeKind.DEPLOYMENT
    assert dep.monitor_label == "app=autoscaler"
    assert dep.name == "autoscaler-deployment"
    assert dep.replica == 1
    assert not dep.svc_elb
    assert not dep.extra_poll
    assert dep.usage == (25, 50, 0, 0)
예제 #10
0
def test_kafka_zk_pvc_info():
    obj_name = "kafka-zk-pvc"
    config_file = os.path.join(PWD, "testdata/{}.yml.in".format(obj_name))
    with open(config_file) as f:
        data = f.read()
    components = [c for c in yaml.load_all(data)]
    assert len(components) == 3

    for i in range(0, 3):
        dep = KubeObjectInfo(components[i])
        assert dep.kube_kind == KubeKind.PVC
        assert dep.monitor_label == "app=kafka-zk-{}".format(i+1)
        assert dep.name == "kdata-{}".format(i+1)
        assert dep.replica == 1
        assert not dep.svc_elb
        assert not dep.extra_poll
        assert dep.usage == (0, 0, 0, 0)