def test_connection_failure(aggregator, spin_up_apache): apache_check = Apache(CHECK_NAME, {}, {}) with pytest.raises(Exception): apache_check.check(BAD_CONFIG) assert aggregator.service_checks( 'apache.can_connect')[0].status == Apache.CRITICAL assert len(aggregator._metrics) == 0
def test_check(aggregator, spin_up_apache): apache_check = Apache(CHECK_NAME, {}, {}) apache_check.check(STATUS_CONFIG) tags = STATUS_CONFIG['tags'] for mname in APACHE_GAUGES + APACHE_RATES: aggregator.assert_metric(mname, tags=tags, count=1) assert aggregator.service_checks( 'apache.can_connect')[0].status == Apache.OK sc_tags = ['host:' + HOST, 'port:' + PORT] + tags for sc in aggregator.service_checks('apache.can_connect'): for tag in sc.tags: assert tag in sc_tags assert aggregator.metrics_asserted_pct == 100.0
def check(): return lambda instance: Apache(CHECK_NAME, {}, [instance])
def check(): return Apache(CHECK_NAME, {}, {})