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')
def test_collect_xdr_invalid_data(aggregator): check = AerospikeCheck('aerospike', {}, [common.INSTANCE]) check.log = mock.MagicMock() with mock.patch('datadog_checks.aerospike.AerospikeCheck.get_info', return_value="ERROR::XDR-not-configured"): check.collect_xdr() check.log.debug.assert_called_with('Error collecting XDR metrics: %s', 'ERROR::XDR-not-configured') aggregator.assert_all_metrics_covered() # no metric
def test_collect_latency_invalid_data(aggregator): check = AerospikeCheck('aerospike', {}, [common.INSTANCE]) check.get_info = mock.MagicMock(return_value=[ 'error-no-data-yet-or-back-too-small', 'xxxread:11:53:47-GMT,ops/sec,>1ms,>8ms,>64ms', '11:53:57,0.0,0.00,0.00,0.00', '{ns-2}-write:11:53:47-GMT,ops/sec,>1ms,>8ms,>64ms', '11:53:57,0.0,0.00,0.00,0.00', ]) check.log = mock.MagicMock() check.collect_latency(None) check.log.warning.assert_called_with( 'Invalid data. Namespace and/or metric name not found in line: `%s`', 'xxxread:11:53:47-GMT,ops/sec,>1ms,>8ms,>64ms', ) aggregator.assert_all_metrics_covered() # no metric