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)
 def test__get_data(self):
     with mock.patch('datadog_checks.rabbitmq.rabbitmq.requests') as r:
         from datadog_checks.rabbitmq import RabbitMQ  # pylint: disable=import-error,no-name-in-module
         from datadog_checks.rabbitmq.rabbitmq import RabbitMQException  # pylint: disable=import-error,no-name-in-module
         check = RabbitMQ(
             'rabbitmq', {},
             {"instances": [{
                 "rabbitmq_api_url": "http://example.com"
             }]})
         r.get.side_effect = [requests.exceptions.HTTPError, ValueError]
         self.assertRaises(RabbitMQException, check._get_data, '')
         self.assertRaises(RabbitMQException, check._get_data, '')
Пример #5
0
def check():
    return RabbitMQ(CHECK_NAME, {}, [CONFIG])
Пример #6
0
def check():
    return RabbitMQ(CHECK_NAME, {}, {})