Esempio 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)
Esempio n. 2
0
def test_collect_empty_data(aggregator):
    check = AerospikeCheck('aerospike', {}, [common.INSTANCE])

    check._client = mock.MagicMock()
    check._client.info_single_node.return_value = 'sets/test/ci	'  # from real data, there is a tab after the command
    check.log = mock.MagicMock()
    assert [] == check.get_info('sets/test/ci')
Esempio n. 3
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)