Beispiel #1
0
def test_kong_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                     k8s_namespace, kong_version):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "kong-k8s.yaml")
    dockerfile_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                  "../../../test-services/kong")
    build_opts = {
        "tag": "kong:k8s-test",
        "buildargs": {
            "KONG_VERSION": kong_version
        }
    }
    minikube.build_image(dockerfile_dir, build_opts)
    monitors = [{
        "type":
        "collectd/kong",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace)
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #2
0
def test_genericjmx_in_k8s(agent_image, minikube, k8s_observer,
                           k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "genericjmx-k8s.yaml")
    monitors = [{
        "type":
        "collectd/genericjmx",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "serviceURL":
        "service:jmx:rmi:///jndi/rmi://{{.Host}}:{{.Port}}/jmxrmi",
        "username":
        "******",
        "password":
        "******",
    }]
    with open(
            os.path.join(os.path.dirname(os.path.realpath(__file__)),
                         "metrics.txt"), "r") as fd:
        expected_metrics = {
            m.strip()
            for m in fd.readlines() if len(m.strip()) > 0
        }
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=expected_metrics,
        test_timeout=k8s_test_timeout,
    )
def test_postgresql_in_k8s(agent_image, minikube, k8s_observer,
                           k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "postgresql-k8s.yaml")
    monitors = [{
        "type":
        "collectd/postgresql",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "databases": [{
            "name": "test",
            "username": "******",
            "password": "******"
        }],
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
        passwords=["test_pwd"],
    )
Beispiel #4
0
def test_couchbase_in_k8s(agent_image, minikube, k8s_observer,
                          k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "couchbase-k8s.yaml")
    build_opts = {
        "buildargs": {
            "COUCHBASE_VERSION": "enterprise-5.1.0"
        },
        "tag": "couchbase:test"
    }
    minikube.build_image("couchbase", build_opts)
    monitors = [{
        "type":
        "collectd/couchbase",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "collectTarget":
        "NODE",
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
def test_elasticsearch_in_k8s(agent_image, minikube, k8s_observer,
                              k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "elasticsearch-k8s.yaml")
    dockerfile_dir = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        "../../../test-services/elasticsearch/6.4.2")
    build_opts = {"tag": "elasticsearch:k8s-test"}
    minikube.build_image(dockerfile_dir, build_opts)
    monitors = [{
        "type":
        "collectd/elasticsearch",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "detailedMetrics":
        True,
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
def test_health_checker_in_k8s(agent_image, minikube, k8s_observer,
                               k8s_test_timeout, k8s_namespace):
    yaml = SCRIPT_DIR / "health-checker-k8s.yaml"
    monitors = [{
        "type":
        "collectd/health-checker",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "path":
        "/health",
        "jsonKey":
        "status",
        "jsonVal":
        "ok",
    }]
    expected_metrics = get_metrics(SCRIPT_DIR)
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=expected_metrics,
        test_timeout=k8s_test_timeout,
    )
def test_consul_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                       k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "consul-k8s.yaml")
    monitors = [{
        "type":
        "collectd/consul",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "aclToken":
        "testing123",
        "signalFxAccessToken":
        "testing123",
        "enhancedMetrics":
        True,
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #8
0
def test_cassandra_in_k8s(agent_image, minikube, k8s_observer,
                          k8s_test_timeout, k8s_namespace):
    yaml = SCRIPT_DIR / "cassandra-k8s.yaml"
    monitors = [{
        "type":
        "collectd/cassandra",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #9
0
def test_jenkins_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                        k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "jenkins-k8s.yaml")
    build_opts = {
        "buildargs": {
            "JENKINS_VERSION": "2.60.3-alpine",
            "JENKINS_PORT": "8080"
        },
        "tag": "jenkins:test"
    }
    minikube.build_image("jenkins", build_opts)
    monitors = [{
        "type":
        "collectd/jenkins",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "metricsKey":
        "33DD8B2F1FD645B814993275703F_EE1FD4D4E204446D5F3200E0F6-C55AC14E",
        "enhancedMetrics":
        True,
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #10
0
def test_genericjmx_in_k8s(agent_image, minikube, k8s_observer,
                           k8s_test_timeout, k8s_namespace):
    yaml = SCRIPT_DIR / "genericjmx-k8s.yaml"
    monitors = [{
        "type":
        "collectd/genericjmx",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "serviceURL":
        "service:jmx:rmi:///jndi/rmi://{{.Host}}:{{.Port}}/jmxrmi",
        "username":
        "******",
        "password":
        "******",
    }]
    expected_metrics = get_metrics(SCRIPT_DIR)
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=expected_metrics,
        test_timeout=k8s_test_timeout,
    )
def test_mysql_in_k8s(agent_image, minikube, k8s_observer, k8s_yaml,
                      k8s_test_timeout, k8s_namespace):
    yaml = DIR / k8s_yaml
    monitors = [{
        "type":
        "collectd/mysql",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "databases": [{
            "name": "mysql",
            "username": "******",
            "password": "******"
        }],
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
def test_rabbitmq_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                         k8s_namespace):
    yaml = SCRIPT_DIR / "rabbitmq-k8s.yaml"
    monitors = [{
        "type":
        "collectd/rabbitmq",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "collectChannels":
        True,
        "collectConnections":
        True,
        "collectExchanges":
        True,
        "collectNodes":
        True,
        "collectQueues":
        True,
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #13
0
def test_etcd_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                     k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "etcd-k8s.yaml")
    monitors = [{
        "type":
        "collectd/etcd",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "clusterName":
        "etcd-cluster",
        "skipSSLValidation":
        True,
        "enhancedMetrics":
        True,
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
def test_spark_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                      k8s_namespace):
    yaml = SCRIPT_DIR / "spark-k8s.yaml"
    monitors = [{
        "type":
        "collectd/spark",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "clusterType":
        "Standalone",
        "isMaster":
        True,
        "collectApplicationMetrics":
        True,
        "enhancedMetrics":
        True,
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
def test_activemq_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                         k8s_namespace):
    yaml = SCRIPT_DIR / "activemq-k8s.yaml"
    build_opts = {"tag": "activemq:k8s-test"}
    minikube.build_image("activemq", build_opts)
    monitors = [{
        "type":
        "collectd/activemq",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "serviceURL":
        "service:jmx:rmi:///jndi/rmi://{{.Host}}:{{.Port}}/jmxrmi",
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #16
0
def test_kafka_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                      k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "kafka-k8s.yaml")
    monitors = [{
        "type":
        "collectd/kafka",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "serviceURL":
        "service:jmx:rmi:///jndi/rmi://{{.Host}}:{{.Port}}/jmxrmi",
        "username":
        "******",
        "password":
        "******",
        "clusterName":
        "testcluster",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #17
0
def test_apache_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                       k8s_namespace):
    yaml = SCRIPT_DIR / "apache-k8s.yaml"
    monitors = [{
        "type":
        "collectd/apache",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "url":
        "http://{{.Host}}:{{.Port}}/mod_status?auto",
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #18
0
def test_nginx_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                      k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "nginx-k8s.yaml")
    monitors = [{
        "type":
        "collectd/nginx",
        "discoveryRule":
        get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
        "url":
        "http://{{.Host}}:{{.Port}}/nginx_status",
        "username":
        "******",
        "password":
        "******",
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(
            monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #19
0
def test_memcached_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "memcached-k8s.yaml")
    monitors = [
        {"type": "collectd/memcached", "discoveryRule": get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace)}
    ]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
def test_redis_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout, k8s_namespace):
    yaml = SCRIPT_DIR / "redis-k8s.yaml"
    monitors = [
        {"type": "collectd/redis", "discoveryRule": get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace)}
    ]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #21
0
def test_kong_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout, k8s_namespace, kong_version):
    yaml = SCRIPT_DIR / "kong-k8s.yaml"
    build_opts = {"tag": "kong:k8s-test", "buildargs": {"KONG_VERSION": kong_version}}
    minikube.build_image("kong", build_opts)
    monitors = [
        {"type": "collectd/kong", "discoveryRule": get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace)}
    ]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=get_monitor_metrics_from_selfdescribe(monitors[0]["type"]),
        expected_dims=get_monitor_dims_from_selfdescribe(monitors[0]["type"]),
        test_timeout=k8s_test_timeout,
    )
Beispiel #22
0
def test_health_checker_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "health-checker-k8s.yaml")
    monitors = [
        {
            "type": "collectd/health-checker",
            "discoveryRule": get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
            "path": "/health",
            "jsonKey": "status",
            "jsonVal": "ok",
        }
    ]
    with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "metrics.txt"), "r") as fd:
        expected_metrics = {m.strip() for m in fd.readlines() if len(m.strip()) > 0}
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=expected_metrics,
        test_timeout=k8s_test_timeout,
    )
Beispiel #23
0
def test_prometheus_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "prometheus-k8s.yaml")
    monitors = [
        {
            "type": "prometheus-exporter",
            "discoveryRule": get_discovery_rule(yaml, k8s_observer, namespace=k8s_namespace),
            "useHTTPS": False,
            "skipVerify": True,
            "metricPath": "/metrics",
        }
    ]
    with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "metrics.txt"), "r") as fd:
        expected_metrics = {m.strip() for m in fd.readlines() if len(m.strip()) > 0}
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        yamls=[yaml],
        observer=k8s_observer,
        expected_metrics=expected_metrics,
        test_timeout=k8s_test_timeout,
    )