diff --git a/tangostationcontrol/tangostationcontrol/integration_test/default/prometheus/test_tango_prometheus_client.py b/tangostationcontrol/tangostationcontrol/integration_test/default/prometheus/test_tango_prometheus_client.py index f6ff9d75909c69d7b603c9a346448fbdbc9d77e9..20056c49455b4f33e48febfd415ca9e629f94c20 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/default/prometheus/test_tango_prometheus_client.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/default/prometheus/test_tango_prometheus_client.py @@ -81,6 +81,26 @@ class TestPrometheusClient(BaseIntegrationTestCase): if '*' not in e: # exclude wildcard 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): """ Test if the metrics are correctly exposed """ device_name = 'stat/recv/1'