Ejemplo n.º 1
0
def test_datacenter_metrics(aggregator):
    check = AerospikeCheck('aerospike', {}, [common.INSTANCE])
    original_get_info = check.get_info

    def mock_get_info(command, separator=";"):
        if command == 'dcs':
            return ['test']
        elif command.startswith("dc/"):
            return common.MOCK_DATACENTER_METRICS

        return original_get_info(command, separator)

    check.get_info = mock_get_info
    check._client = mock.MagicMock()
    check._client.get_node_names = mock.MagicMock(
        side_effect=lambda: [{
            'address': common.HOST,
            'port': common.PORT,
            'node_name': 'test'
        }])
    check.get_namespaces = mock.MagicMock()
    check.collect_info = mock.MagicMock()
    check.collect_throughput = mock.MagicMock()
    check.collect_latency = mock.MagicMock()
    check.check(None)
    for metric in common.DATACENTER_METRICS:
        aggregator.assert_metric(metric)
Ejemplo n.º 2
0
def test_check(aggregator, instance):
    check = AerospikeCheck('aerospike', {}, {})
    check.check(instance)

    # This hasn't been working
    # aggregator.assert_metric('aerospike.batch_error', 0)

    aggregator.assert_metric('aerospike.cluster_size')
    aggregator.assert_metric('aerospike.namespace.objects')
    aggregator.assert_metric('aerospike.namespace.hwm_breached')
    aggregator.assert_metric('aerospike.namespace.client_write_error', 0)
    aggregator.assert_metric('aerospike.namespace.client_write_success', 1)
    aggregator.assert_metric('aerospike.namespace.truncate_lut', 0)
    aggregator.assert_metric('aerospike.namespace.tombstones', 0)
    aggregator.assert_metric('aerospike.set.tombstones', 0)
    aggregator.assert_metric('aerospike.set.truncate_lut', 0)
    aggregator.assert_metric('aerospike.set.memory_data_bytes', 289)
    aggregator.assert_metric(
        'aerospike.set.objects',
        1,
        tags=['namespace:test', 'set:characters', 'tag:value'])
    aggregator.assert_metric(
        'aerospike.set.stop_writes_count',
        0,
        tags=['namespace:test', 'set:characters', 'tag:value'])

    aggregator.assert_service_check('aerospike.cluster_up', check.OK)
Ejemplo n.º 3
0
def test_check(aggregator, instance):
    check = AerospikeCheck('aerospike', {}, [instance])
    # sleep to make sure client is available
    time.sleep(30)
    for _ in range(10):
        check.check(instance)
        time.sleep(1)
    _test_check(aggregator)
Ejemplo n.º 4
0
def test_version_metadata(aggregator, instance, datadog_agent):

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

    # sleep to make sure client is available
    time.sleep(30)
    for _ in range(10):
        check.check(instance)
        time.sleep(1)

    raw_version = check.get_info("build")[0]
    major, minor = raw_version.split('.')[:2]
    version_metadata = {
        'version.scheme': 'semver',
        'version.major': major,
        'version.minor': minor,
        'version.patch': mock.ANY,
        'version.raw': raw_version,
    }

    datadog_agent.assert_metadata('test:123', version_metadata)
Ejemplo n.º 5
0
def test_datacenter_metrics(aggregator):
    check = AerospikeCheck('aerospike', {}, [common.INSTANCE])
    original_get_info = check.get_info

    def mock_get_info(command, separator=";"):
        if command == 'dcs':
            return ['test']
        elif command.startswith("dc/"):
            return common.DATACENTER_METRICS

        return original_get_info(command, separator)

    check.get_info = mock_get_info
    check._client = mock.MagicMock()
    check.get_namespaces = mock.MagicMock()
    check.collect_info = mock.MagicMock()
    check.collect_throughput = mock.MagicMock()
    check.collect_latency = mock.MagicMock()
    check.collect_version = mock.MagicMock()
    check.check(common.INSTANCE)
    for metric in METRICS:
        aggregator.assert_metric(metric)
def test_check(aggregator, instance):
    check = AerospikeCheck('aerospike', {}, [instance])
    check.check(instance)
    _test_check(aggregator)