def test_jenkins_enhanced(version): with run_service("jenkins", buildargs={ "JENKINS_REPO": version[0], "JENKINS_VERSION": version[1], "JENKINS_PORT": "8080" }) as jenkins_container: host = container_ip(jenkins_container) config = dedent(f""" monitors: - type: collectd/jenkins host: {host} port: 8080 metricsKey: {METRICS_KEY} enhancedMetrics: true """) assert wait_for(p(tcp_socket_open, host, 8080), 60), "service not listening on port" assert wait_for( p(http_status, url=f"http://{host}:8080/metrics/{METRICS_KEY}/ping/", status=[200]), 120), "service didn't start" with Agent.run(config) as agent: verify_expected_is_subset(agent, ENHANCED_METRICS[version])
def test_collectd_vmem_all(): metrics = METADATA.all_metrics with Agent.run(f""" monitors: - type: collectd/vmem extraMetrics: ["*"] """) as agent: verify_expected_is_subset(agent, metrics)
def test_disk_all(): with Agent.run( """ monitors: - type: collectd/disk extraMetrics: ["*"] """ ) as agent: # pending_operations only shows up sometimes on CI. Maybe only reported when non-zero? verify_expected_is_subset(agent, METADATA.all_metrics - {"pending_operations"})
def test_http_minimal_metrics(): # config to get only minimal metrics with Agent.run(f""" monitors: - type: http urls: - {URL_HTTP} """) as agent: # https metric(s) should not be reported for http site verify_expected_is_subset(agent, METADATA.all_metrics - METRICS_OPTIONAL)
def test_zookeeper_leader_metrics(): with run_zookeeper(version="zookeeper:3.5", env=ENV) as host: with Agent.run( f""" monitors: - type: collectd/zookeeper host: {host} port: 2181 extraGroups: [leader] """ ) as agent: verify_expected_is_subset(agent, METADATA.metrics_by_group["leader"])
def test_zookeeper_all_common_metrics(): with run_zookeeper() as host: with Agent.run( f""" monitors: - type: collectd/zookeeper host: {host} port: 2181 extraMetrics: ["*"] """ ) as agent: verify_expected_is_subset(agent, METADATA.all_metrics - METADATA.metrics_by_group["leader"])
def test_docker_enhanced(): with run_service( "elasticsearch/6.6.1" ): # just get a container that does some block io running so we have some stats with Agent.run(f""" monitors: - type: docker-container-stats enableExtraBlockIOMetrics: true enableExtraCPUMetrics: true enableExtraMemoryMetrics: true enableExtraNetworkMetrics: true """) as agent: verify_expected_is_subset(agent, ENHANCED_METRICS)
def test_etcd_monitor_enhanced(): with run_etcd() as etcd_cont: host = container_ip(etcd_cont) with Agent.run(f""" monitors: - type: collectd/etcd host: {host} port: 2379 clusterName: test-cluster enhancedMetrics: true """) as agent: verify_expected_is_subset(agent, ENHANCED_METRICS)