def test_config(check, test_case, extra_config, expected_http_kwargs):
    config = {
        'rabbitmq_api_url': common.URL,
        'queues': ['test1'],
        'tags': ["tag1:1", "tag2"],
        'exchanges': ['test1']
    }
    config.update(extra_config)
    check = RabbitMQ('rabbitmq', {}, instances=[config])

    with mock.patch('datadog_checks.base.utils.http.requests') as r:
        r.get.return_value = mock.MagicMock(status_code=200)

        check.check(config)

        http_wargs = dict(auth=mock.ANY,
                          cert=mock.ANY,
                          headers=mock.ANY,
                          proxies=mock.ANY,
                          timeout=mock.ANY,
                          verify=mock.ANY)
        http_wargs.update(expected_http_kwargs)

        r.get.assert_called_with('http://localhost:15672/api/connections',
                                 **http_wargs)
示例#2
0
def test_nodes(aggregator, check):

    # default, node metrics are collected
    check = RabbitMQ('rabbitmq', {}, instances=[common.CONFIG])
    check.check(common.CONFIG)

    for m in metrics.COMMON_METRICS:
        aggregator.assert_metric(m, count=1)

    aggregator.reset()
示例#3
0
def test_disable_nodes(aggregator, check):

    # node metrics collection disabled in config, node metrics should not appear
    check = RabbitMQ('rabbitmq', {}, instances=[common.CONFIG_NO_NODES])
    check.check(common.CONFIG_NO_NODES)

    for m in metrics.COMMON_METRICS:
        aggregator.assert_metric(m, count=0)

    # check to ensure other metrics are being collected
    for m in metrics.Q_METRICS:
        aggregator.assert_metric(m, count=1)