diff --git a/test/telegraf-agents/test_telegraf_agents.py b/test/telegraf-agents/test_telegraf_agents.py index 2f35d0187668cad52177384f3bf6b60755c9a0ec..77b6290e1603a24e0886f59f6ceb9ba86a1a7c35 100644 --- a/test/telegraf-agents/test_telegraf_agents.py +++ b/test/telegraf-agents/test_telegraf_agents.py @@ -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", [