示例#1
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,
    )
示例#2
0
def test_kong_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                     k8s_namespace):
    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"}
    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,
    )
示例#3
0
def test_spark_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                      k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "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,
    )
示例#4
0
def test_mysql_in_k8s(agent_image, minikube, k8s_observer, k8s_yaml,
                      k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)), 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,
    )
示例#5
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,
    )
示例#6
0
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,
    )
示例#7
0
def test_activemq_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                         k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "activemq-k8s.yaml")
    dockerfile_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                  "../../../test-services/activemq")
    build_opts = {"tag": "activemq:k8s-test"}
    minikube.build_image(dockerfile_dir, 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,
    )
示例#8
0
def test_vmem():
    expected_metrics = get_monitor_metrics_from_selfdescribe("collectd/vmem")
    expected_dims = get_monitor_dims_from_selfdescribe("collectd/vmem")
    with run_agent(
        """
    monitors:
      - type: collectd/vmem
    """
    ) as [backend, get_output, _]:
        assert wait_for(
            p(has_any_metric_or_dim, backend, expected_metrics, expected_dims), timeout_seconds=60
        ), "timed out waiting for metrics and/or dimensions!"
        assert not has_log_message(get_output().lower(), "error"), "error found in agent output!"
示例#9
0
def test_openstack(devstack):
    host = container_ip(devstack)
    config = dedent(f"""
            monitors:
              - type: collectd/openstack
                authURL: http://{host}/identity/v3
                username: admin
                password: testing123
        """)
    with run_agent(config) as [backend, _, _]:
        expected_metrics = get_monitor_metrics_from_selfdescribe(
            "collectd/openstack")
        assert wait_for(p(any_metric_found, backend, expected_metrics),
                        60), "Timed out waiting for openstack metrics"
示例#10
0
def test_cadvisor_in_k8s(agent_image, minikube, k8s_test_timeout,
                         k8s_namespace):
    if semver.match(minikube.k8s_version.lstrip("v"), ">=1.12.0"):
        pytest.skip("cadvisor web removed from kubelet in v1.12.0")
    monitors = [{"type": "cadvisor", "cadvisorURL": "http://localhost:4194"}]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        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,
    )
示例#11
0
def test_docker_in_k8s(agent_image, minikube, k8s_test_timeout, k8s_namespace):
    monitors = [{
        "type": "collectd/docker",
        "dockerURL": "unix:///var/run/docker.sock",
        "collectNetworkStats": True
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        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,
    )
示例#12
0
def test_redis_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout, k8s_namespace):
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "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,
    )
def test_kubernetes_cluster_in_k8s(agent_image, minikube, k8s_test_timeout,
                                   k8s_namespace):
    monitors = [{
        "type": "kubernetes-cluster",
        "kubernetesAPI": {
            "authType": "serviceAccount"
        }
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        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,
    )
示例#14
0
def test_activemq():
    with run_service("activemq") as activemq_container:
        host = container_ip(activemq_container)
        config = dedent(f"""
            monitors:
              - type: collectd/activemq
                host: {host}
                port: 1099
                serviceURL: service:jmx:rmi:///jndi/rmi://{host}:1099/jmxrmi
                username: testuser
                password: testing123
        """)
        assert wait_for(p(tcp_socket_open, host, 1099),
                        60), "service didn't start"
        with run_agent(config) as [backend, _, _]:
            metrics = get_monitor_metrics_from_selfdescribe(
                "collectd/activemq")
            assert wait_for(p(any_metric_found, backend,
                              metrics)), "Didn't get activemq datapoints"
示例#15
0
def test_kubernetes_volumes_in_k8s(agent_image, minikube, k8s_test_timeout,
                                   k8s_namespace):
    monitors = [{
        "type": "kubernetes-volumes",
        "kubeletAPI": {
            "skipVerify": True,
            "authType": "serviceAccount"
        }
    }]
    run_k8s_monitors_test(
        agent_image,
        minikube,
        monitors,
        namespace=k8s_namespace,
        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_signalfx_metadata():
    expected_metrics = get_monitor_metrics_from_selfdescribe(
        "collectd/signalfx-metadata")
    expected_dims = get_monitor_dims_from_selfdescribe(
        "collectd/signalfx-metadata")
    with run_agent("""
    monitors:
      - type: collectd/signalfx-metadata
        procFSPath: /proc
        etcPath: /etc
        persistencePath: /var/run/signalfx-agent
      - type: collectd/cpu
    """) as [backend, get_output, _]:
        assert wait_for(p(has_any_metric_or_dim, backend, expected_metrics,
                          expected_dims),
                        timeout_seconds=60
                        ), "timed out waiting for metrics and/or dimensions!"
        assert not has_log_message(get_output().lower(),
                                   "error"), "error found in agent output!"
示例#17
0
def test_cadvisor():
    cadvisor_opts = dict(
        volumes={
            "/": {
                "bind": "/rootfs",
                "mode": "ro"
            },
            "/var/run": {
                "bind": "/var/run",
                "mode": "ro"
            },
            "/sys": {
                "bind": "/sys",
                "mode": "ro"
            },
            "/var/lib/docker": {
                "bind": "/var/lib/docker",
                "mode": "ro"
            },
            "/dev/disk": {
                "bind": "/dev/disk",
                "mode": "ro"
            },
        })
    with run_container("google/cadvisor:latest",
                       **cadvisor_opts) as cadvisor_container:
        host = container_ip(cadvisor_container)
        config = dedent(f"""
            monitors:
              - type: cadvisor
                cadvisorURL: http://{host}:8080
        """)
        assert wait_for(p(tcp_socket_open, host, 8080),
                        60), "service didn't start"
        with run_agent(config) as [backend, _, _]:
            expected_metrics = get_monitor_metrics_from_selfdescribe(
                "cadvisor")
            assert wait_for(
                p(any_metric_found, backend,
                  expected_metrics)), "Didn't get cadvisor datapoints"
示例#18
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,
    )
示例#19
0
def test_couchbase_in_k8s(agent_image, minikube, k8s_observer,
                          k8s_test_timeout, k8s_namespace):
    dockerfile_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                  "../../../test-services/couchbase")
    build_opts = {
        "buildargs": {
            "COUCHBASE_VERSION": "enterprise-5.1.0"
        },
        "tag": "couchbase:test"
    }
    minikube.build_image(dockerfile_dir, build_opts)
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "couchbase-k8s.yaml")
    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,
    )
示例#20
0
def test_jenkins_in_k8s(agent_image, minikube, k8s_observer, k8s_test_timeout,
                        k8s_namespace):
    dockerfile_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                  "../../../test-services/jenkins")
    build_opts = {
        "buildargs": {
            "JENKINS_VERSION": "2.60.3-alpine",
            "JENKINS_PORT": "8080"
        },
        "tag": "jenkins:test"
    }
    minikube.build_image(dockerfile_dir, build_opts)
    yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "jenkins-k8s.yaml")
    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,
    )