def test_indexing_metrics(aggregator, gauges, active_tasks): """ Testing metrics coming from a running indexer would be extremely flaky, let's use mock. """ from datadog_checks.couch import couch def _get(url, tags, run_check=False): if '_active_tasks' in url: return active_tasks return {} # run the check on all instances for config in [common.NODE1, common.NODE2, common.NODE3]: check = CouchDb(common.CHECK_NAME, {}, [config]) check.checker = couch.CouchDB2(check) check.get = _get 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)
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)