Skip to content

Commit

Permalink
Don't fix produce content
Browse files Browse the repository at this point in the history
  • Loading branch information
therve committed Apr 2, 2020
1 parent b59dc79 commit 3f4fbd0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
7 changes: 3 additions & 4 deletions openmetrics/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ def poll_mock():
g3 = Gauge('metric3', 'memory usage', ['matched_label', 'node', 'timestamp'], registry=registry)
g3.labels(matched_label="foobar", node="host2", timestamp="456").set(float('inf'))

data = ensure_unicode(generate_latest(registry))
data = data.replace("_total", "")

poll_mock_patch = mock.patch(
'requests.get',
return_value=mock.MagicMock(
status_code=200, iter_lines=lambda **kwargs: data.split("\n"), headers={'Content-Type': "text/plain"},
status_code=200,
iter_lines=lambda **kwargs: ensure_unicode(generate_latest(registry)).split("\n"),
headers={'Content-Type': "text/plain"},
),
)
with poll_mock_patch:
Expand Down
8 changes: 5 additions & 3 deletions openmetrics/tests/test_openmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
instance = {
'prometheus_url': 'http://localhost:10249/metrics',
'namespace': 'openmetrics',
'metrics': [{'metric1': 'renamed.metric1'}, 'metric2', 'counter1'],
'metrics': [{'metric1': 'renamed.metric1'}, 'metric2', 'counter1_total'],
'send_histograms_buckets': True,
'send_monotonic_counter': True,
}
Expand All @@ -32,7 +32,9 @@ def test_openmetrics_check(aggregator):
tags=['timestamp:123', 'node:host2', 'matched_label:foobar'],
metric_type=aggregator.GAUGE,
)
aggregator.assert_metric(CHECK_NAME + '.counter1', tags=['node:host2'], metric_type=aggregator.MONOTONIC_COUNT)
aggregator.assert_metric(
CHECK_NAME + '.counter1_total', tags=['node:host2'], metric_type=aggregator.MONOTONIC_COUNT
)
aggregator.assert_all_metrics_covered()


Expand All @@ -50,7 +52,7 @@ def test_openmetrics_check_counter_gauge(aggregator):
tags=['timestamp:123', 'node:host2', 'matched_label:foobar'],
metric_type=aggregator.GAUGE,
)
aggregator.assert_metric(CHECK_NAME + '.counter1', tags=['node:host2'], metric_type=aggregator.GAUGE)
aggregator.assert_metric(CHECK_NAME + '.counter1_total', tags=['node:host2'], metric_type=aggregator.GAUGE)
aggregator.assert_all_metrics_covered()


Expand Down
9 changes: 4 additions & 5 deletions prometheus/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
INSTANCE_UNIT = {
'prometheus_url': 'http://localhost:10249/metrics',
'namespace': 'prometheus',
'metrics': [{'metric1': 'renamed.metric1'}, 'metric2', 'counter1'],
'metrics': [{'metric1': 'renamed.metric1'}, 'metric2', 'counter1_total'],
'send_histograms_buckets': True,
'send_monotonic_counter': True,
}
Expand Down Expand Up @@ -58,13 +58,12 @@ def poll_mock():
g3 = Gauge('metric3', 'memory usage', ['matched_label', 'node', 'timestamp'], registry=registry)
g3.labels(matched_label="foobar", node="host2", timestamp="456").set(float('inf'))

data = ensure_unicode(generate_latest(registry))
data = data.replace("_total", "")

poll_mock_patch = mock.patch(
'requests.get',
return_value=mock.MagicMock(
status_code=200, iter_lines=lambda **kwargs: data.split("\n"), headers={'Content-Type': "text/plain"},
status_code=200,
iter_lines=lambda **kwargs: ensure_unicode(generate_latest(registry)).split("\n"),
headers={'Content-Type': "text/plain"},
),
)
with poll_mock_patch:
Expand Down
6 changes: 4 additions & 2 deletions prometheus/tests/test_prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def test_prometheus_check(aggregator, instance, poll_mock):
tags=['timestamp:123', 'node:host2', 'matched_label:foobar'],
metric_type=aggregator.GAUGE,
)
aggregator.assert_metric(CHECK_NAME + '.counter1', tags=['node:host2'], metric_type=aggregator.MONOTONIC_COUNT)
aggregator.assert_metric(
CHECK_NAME + '.counter1_total', tags=['node:host2'], metric_type=aggregator.MONOTONIC_COUNT
)
assert aggregator.metrics_asserted_pct == 100.0


Expand All @@ -50,7 +52,7 @@ def test_prometheus_check_counter_gauge(aggregator, instance, poll_mock):
tags=['timestamp:123', 'node:host2', 'matched_label:foobar'],
metric_type=aggregator.GAUGE,
)
aggregator.assert_metric(CHECK_NAME + '.counter1', tags=['node:host2'], metric_type=aggregator.GAUGE)
aggregator.assert_metric(CHECK_NAME + '.counter1_total', tags=['node:host2'], metric_type=aggregator.GAUGE)
assert aggregator.metrics_asserted_pct == 100.0


Expand Down

0 comments on commit 3f4fbd0

Please sign in to comment.