示例#1
0
def test_gunicorn_instance(aggregator, setup_gunicorn):
    instance = INSTANCE.copy()
    instance['gunicorn'] = setup_gunicorn['gunicorn_bin_path']

    check = GUnicornCheck(CHECK_NAME, {}, [instance])
    check.check(instance)
    _assert_metrics(aggregator)
示例#2
0
def test_collect_metadata_docker(aggregator, datadog_agent, setup_gunicorn):
    instance = INSTANCE.copy()
    instance['gunicorn'] = 'docker exec {} gunicorn'.format(CONTAINER_NAME)

    check = GUnicornCheck(CHECK_NAME, {}, [instance])
    check.check_id = CHECK_ID
    check.check(instance)

    _assert_metadata(datadog_agent)
示例#3
0
def test_collect_metadata_count(aggregator, datadog_agent, setup_gunicorn):
    instance = INSTANCE.copy()
    instance['gunicorn'] = setup_gunicorn['gunicorn_bin_path']

    check = GUnicornCheck(CHECK_NAME, {}, [instance])
    check.check_id = 'test:123'
    check.check(instance)

    datadog_agent.assert_metadata_count(5)
示例#4
0
def test_collect_metadata_init_config(aggregator, datadog_agent,
                                      setup_gunicorn):
    init_config = {'gunicorn': setup_gunicorn['gunicorn_bin_path']}

    check = GUnicornCheck(CHECK_NAME, init_config, [INSTANCE])
    check.check_id = CHECK_ID
    check.check(INSTANCE)

    _assert_metadata(datadog_agent)
示例#5
0
def test_collect_metadata_instance(aggregator, datadog_agent, setup_gunicorn):
    instance = INSTANCE.copy()
    instance['gunicorn'] = setup_gunicorn['gunicorn_bin_path']

    check = GUnicornCheck(CHECK_NAME, {}, [instance])
    check.check_id = CHECK_ID
    check.check(instance)

    _assert_metadata(datadog_agent)
示例#6
0
def test_collect_metadata_parsing_matching(aggregator, datadog_agent, stdout, stderr, expect_metadata_count):
    """ Test all metadata collection code paths """
    check = GUnicornCheck(CHECK_NAME, {}, [INSTANCE])
    check.check_id = 'test:123'

    with mock.patch('datadog_checks.gunicorn.gunicorn.get_subprocess_output', return_value=(stdout, stderr, 0)):
        check.check(INSTANCE)

    datadog_agent.assert_metadata_count(expect_metadata_count)
def test_gunicorn(aggregator, setup_gunicorn):
    check = GUnicornCheck(CHECK_NAME, {}, {})
    check.check(INSTANCE)

    aggregator.assert_metric("gunicorn.workers", tags=['app:dd-test-gunicorn', 'state:idle'], value=4, count=1)
    aggregator.assert_metric("gunicorn.workers", tags=['app:dd-test-gunicorn', 'state:working'], value=0, count=1)

    aggregator.assert_service_check("gunicorn.is_running", count=1)

    aggregator.assert_all_metrics_covered()
示例#8
0
def test_collect_metadata_invalid_binary(aggregator, datadog_agent,
                                         setup_gunicorn):
    instance = INSTANCE.copy()
    instance['gunicorn'] = '/bin/not_exist'

    check = GUnicornCheck(CHECK_NAME, {}, [instance])
    check.check_id = CHECK_ID
    check.check(instance)

    datadog_agent.assert_metadata_count(0)
示例#9
0
def test_no_master_proc(aggregator, setup_gunicorn):
    instance = {'proc_name': 'no_master_proc'}
    check = GUnicornCheck(CHECK_NAME, {}, [instance])
    check.check(instance)
    aggregator.assert_service_check("gunicorn.is_running", check.CRITICAL)
示例#10
0
def test_gunicorn(aggregator, setup_gunicorn):
    check = GUnicornCheck(CHECK_NAME, {}, {})
    check.check(INSTANCE)
    _assert_metrics(aggregator)