Skip to content
Snippets Groups Projects
Commit 881934bc authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Slight refactoring of telegraph agent test

parent 417be55b
No related branches found
No related tags found
No related merge requests found
......@@ -9,16 +9,23 @@ import pytest
('mongodb', 'SELECT mean("net_in_bytes") AS "mean" FROM "CLMCMetrics"."autogen"."mongodb"', 0)
])
def test_all_inputs(influxdb, measurement, query, expected_result):
"""Tests measurements are received from an input plugin aggregated across all services
"""
Tests measurements are received from an input plugin aggregated across all services
:param influxdb: the influx db client fixture
:param measurement: the measurement to test
:param query: the query to execute
:param expected_result: the expected result from the query
"""
query_result = influxdb.query('SHOW measurements ON "CLMCMetrics"')
points = list(query_result.get_points())
assert any(p['name'] == measurement for p in points), "{0} not in measurement list".format(measurement)
query_result = influxdb.query(query)
points = list(query_result.get_points())
actual_result = points[0]['mean']
assert actual_result > expected_result, "actual result {0} is not > expected result {1} for query {2}".format(actual_result, str(expected_result), query)
points = next(query_result.get_points()) # get_points() returns a generator, to take the first element we can use the next() function
actual_result = points['mean']
assert actual_result > expected_result, "actual result {0} is not > expected result {1} for query {2}".format(actual_result, str(expected_result), query)
@pytest.mark.parametrize("ipendpoint, measurements", [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment