Skip to content

Commit

Permalink
Fix test version
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristineTChen committed Jan 30, 2021
1 parent eb839e1 commit 2610143
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion aerospike/datadog_checks/aerospike/aerospike.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def get_info(self, command, separator=';'):
data,
)
except Exception as e:
self.log.warning("Command `%s` was unsuccessful: %s" (command, str(e)))
self.log.warning("Command `%s` was unsuccessful: %s"(command, str(e)))
return
# Get rid of command and whitespace
data = data[len(command) :].strip()
Expand Down
1 change: 1 addition & 0 deletions aerospike/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

HOST = get_docker_hostname()
PORT = 3000
VERSION = os.environ.get('AEROSPIKE_VERSION')

NAMESPACE_METRICS = [
'objects',
Expand Down
4 changes: 2 additions & 2 deletions aerospike/tests/test_aerospike.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from datadog_checks.aerospike import AerospikeCheck
from datadog_checks.dev.utils import get_metadata_metrics

from .common import LATENCIES_METRICS, LAZY_METRICS, NAMESPACE_METRICS, SET_METRICS, STATS_METRICS, TPS_METRICS
from .common import LATENCIES_METRICS, LAZY_METRICS, NAMESPACE_METRICS, SET_METRICS, STATS_METRICS, TPS_METRICS, VERSION


@pytest.mark.usefixtures('dd_environment')
Expand Down Expand Up @@ -63,7 +63,7 @@ def _test_check(aggregator):
for metric in NAMESPACE_METRICS:
aggregator.assert_metric("aerospike.namespace.{}".format(metric))

if os.environ.get('AEROSPIKE_VERSION') == '5.3.0.6':
if VERSION == '5.3.0.6':
for metric in LATENCIES_METRICS:
aggregator.assert_metric(metric)
aggregator.assert_metric('aerospike.set.device_data_bytes')
Expand Down
13 changes: 8 additions & 5 deletions aerospike/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
pytestmark = pytest.mark.unit


@pytest.mark.skipif(os.getenv('AEROSPIKE_VERSION') == '5.3.0.6', reason="Datacenter metrics not supported")
@pytest.mark.skipif(common.VERSION == '5.3.0.6', reason="Datacenter metrics not supported")
def test_datacenter_metrics(aggregator):
check = AerospikeCheck('aerospike', {}, [common.INSTANCE])
original_get_info = check.get_info
Expand All @@ -33,7 +33,10 @@ def mock_get_info(command, separator=";"):
check.collect_info = mock.MagicMock()
check.collect_throughput = mock.MagicMock()
check.collect_latency = mock.MagicMock()
check.collect_version = mock.MagicMock()
if common.VERSION == '5.3.0.6':
check.collect_version = common.VERSION.split('.')
else:
check.collect_version = mock.MagicMock()
check.check(None)
for metric in common.DATACENTER_METRICS:
aggregator.assert_metric(metric)
Expand Down Expand Up @@ -129,14 +132,14 @@ def test_collect_latencies_parser(aggregator):
)
check.collect_latencies(None)

for type in ['read', 'udf']:
for metric_type in ['read', 'udf']:
for i in range(17):
aggregator.assert_metric(
'aerospike.namespace.latency.{}_over_{}ms'.format(type, str(2 ** i)),
'aerospike.namespace.latency.{}_over_{}ms'.format(metric_type, str(2 ** i)),
tags=['namespace:{}'.format('test')],
)

aggregator.assert_metric(
'aerospike.namespace.latency.{}_ops_sec'.format(type), tags=['namespace:{}'.format('test')]
'aerospike.namespace.latency.{}_ops_sec'.format(metric_type), tags=['namespace:{}'.format('test')]
)
aggregator.assert_all_metrics_covered()

0 comments on commit 2610143

Please sign in to comment.