Пример #1
0
def test_bad_status(aggregator):
    instance = {
        'status_url': 'http://foo:9001/status',
        'tags': ['expectedbroken']
    }
    check = PHPFPMCheck('php_fpm', {}, [instance])
    check.check(instance)
    assert len(aggregator.metric_names) == 0
Пример #2
0
def test_bad_ping(aggregator):
    instance = {'ping_url': 'http://foo:9001/ping', 'tags': ['some_tag']}
    check = PHPFPMCheck('php_fpm', {}, [instance])
    check.check(instance)
    aggregator.assert_service_check(
        'php_fpm.can_ping', status=check.CRITICAL, tags=['ping_url:http://foo:9001/ping', 'some_tag']
    )
    aggregator.all_metrics_asserted()
Пример #3
0
def test_config(test_case, extra_config, expected_http_kwargs):
    instance = {'ping_url': 'http://foo:9001/ping'}
    instance.update(extra_config)
    check = PHPFPMCheck('php_fpm', {}, instances=[instance])

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

        check.check(instance)

        http_kwargs = dict(
            auth=mock.ANY, cert=mock.ANY, headers=mock.ANY, proxies=mock.ANY, timeout=mock.ANY, verify=mock.ANY
        )
        http_kwargs.update(expected_http_kwargs)
        r.get.assert_called_with('http://foo:9001/ping', **http_kwargs)