def test_bad_config(aggregator, instance): instance.update({"url": "http://localhost:5985"}) check = Riak('riak', {}, [instance]) with pytest.raises(ConnectionError): check.check(instance) sc_tags = ['my_tag', 'url:http://localhost:5985'] aggregator.assert_service_check(common.SERVICE_CHECK_NAME, status=Riak.CRITICAL, tags=sc_tags)
def test_bad_config(aggregator, spin_up_riak): riak_check = Riak(CHECK_NAME, {}, {}) with pytest.raises(socket.error): riak_check.check({"url": "http://localhost:5985"}) sc_tags = ['url:http://localhost:5985'] for sc in aggregator.service_checks(SERVICE_CHECK_NAME): assert sc.status == Riak.CRITICAL for tag in sc.tags: assert tag in sc_tags
def test_check(aggregator, spin_up_riak): riak_check = Riak(CHECK_NAME, {}, {}) config = {"url": "{0}/stats".format(BASE_URL), "tags": ["my_tag"]} riak_check.check(config) riak_check.check(config) tags = ['my_tag'] sc_tags = tags + ['url:' + config['url']] for gauge in CHECK_GAUGES + CHECK_GAUGES_STATS: aggregator.assert_metric(gauge, tags=tags, count=2) for sc in aggregator.service_checks(SERVICE_CHECK_NAME): assert sc.status == Riak.OK for tag in sc.tags: assert tag in sc_tags for gauge in GAUGE_OTHER: aggregator.assert_metric(gauge, count=1) aggregator.all_metrics_asserted()
def check(): return Riak('riak', {}, {})