Skip to content
Snippets Groups Projects
Commit c5792d4f authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-780: add further integration tests

parent 07626f63
Branches
No related tags found
1 merge request!393Resolve L2SS-780 "Prometheus exporter test"
...@@ -81,6 +81,26 @@ class TestPrometheusClient(BaseIntegrationTestCase): ...@@ -81,6 +81,26 @@ class TestPrometheusClient(BaseIntegrationTestCase):
if '*' not in e: # exclude wildcard if '*' not in e: # exclude wildcard
self.assertNotIn(e, attribute_list) self.assertNotIn(e, attribute_list)
def test_label_metric_list(self):
""" Test whether the metric label list matches up with the ones defined in the GaugeMetricFamily constructor"""
collector = self.setUp()
attribute_metrics, scraping_metrics = collector.collect()
expected_attribute_labels = ['station', 'device', 'name', 'str_value', 'type', 'x', 'y', 'idx']
expected_scraping_labels = ['station', 'device']
numpy.testing.assert_equal([*attribute_metrics.samples[0].labels.keys()], expected_attribute_labels)
numpy.testing.assert_equal([*scraping_metrics.samples[0].labels.keys()], expected_scraping_labels)
def test_collector_metrics_with_devices_in_off(self):
""" Test if the metrics are exposed even if devices are in OFF state """
device_name = 'stat/recv/1'
recv_proxy = TestDeviceProxy(device_name)
recv_proxy.off()
collector = self.setUp()
expected_attrs = ['State', 'Status'] # only state attributes are scraped when device is in OFF
metrics = collector.device_metrics(device_name)
actual_attrs = [metrics[0][0][2], metrics[1][0][2]]
numpy.testing.assert_equal(sorted(actual_attrs), expected_attrs)
def test_collector_metrics(self): def test_collector_metrics(self):
""" Test if the metrics are correctly exposed """ """ Test if the metrics are correctly exposed """
device_name = 'stat/recv/1' device_name = 'stat/recv/1'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment