Esempio n. 1
0
def test_indexing_metrics(aggregator, check, gauges, active_tasks):
    """
    Testing metrics coming from a running indexer would be extremely flaky,
    let's use mock.
    """
    from datadog_checks.couch import couch

    check.checker = couch.CouchDB2(check)

    def _get(url, tags, run_check=False):
        if '_active_tasks' in url:
            return active_tasks
        return {}

    check.get = _get

    # run the check on all instances
    for config in [common.NODE1, common.NODE2, common.NODE3]:
        check.check(config)

    for node in [common.NODE1, common.NODE2, common.NODE3]:
        expected_tags = [
            'database:kennel', 'design_document:dummy',
            'instance:{}'.format(node['name'])
        ]
        for gauge in gauges["indexing_tasks_gauges"]:
            aggregator.assert_metric(gauge, tags=expected_tags)
Esempio n. 2
0
def test_compaction_metrics(aggregator, gauges, active_tasks):
    """
    Database compaction tasks are super quick to run on small amounts of data, leading to the task sometimes
    being complete before the check queries for active tasks. This can lead to flaky results, so let's mock.
    """
    from datadog_checks.couch import couch

    def _get_active_tasks(server, name, tags):
        return active_tasks

    check = CouchDb(common.CHECK_NAME, {}, [common.NODE1])
    check.checker = couch.CouchDB2(check)
    check.checker._get_active_tasks = _get_active_tasks
    check.check(common.NODE1)

    for gauge in gauges["compaction_tasks_gauges"]:
        aggregator.assert_metric(gauge)