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

L2SS-780: add archiverpolicy integration test

parent fdc07228
No related branches found
No related tags found
1 merge request!393Resolve L2SS-780 "Prometheus exporter test"
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
# See LICENSE.txt for more info. # See LICENSE.txt for more info.
from tangostationcontrol.integration_test.base import BaseIntegrationTestCase from tangostationcontrol.integration_test.base import BaseIntegrationTestCase
from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy
from tango import Database
import importlib import importlib
import sys import sys
sys.path.append('/opt/lofar/tango/docker-compose/tango-prometheus-exporter/code') sys.path.append('/opt/lofar/tango/docker-compose/tango-prometheus-exporter/code')
...@@ -15,7 +18,35 @@ tpc = importlib.import_module('tango-prometheus-client') ...@@ -15,7 +18,35 @@ tpc = importlib.import_module('tango-prometheus-client')
class TestPrometheusClient(BaseIntegrationTestCase): class TestPrometheusClient(BaseIntegrationTestCase):
CONFIG = tpc.ArchiverPolicy.load_config('/opt/lofar/tango/docker-compose/tango-prometheus-exporter/lofar2-policy.json')
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.policy = tpc.ArchiverPolicy() db = Database()
self.assertIsNotNone(self.policy) station = db.get_property("station","name")["name"][0]
custom_collector = tpc.CustomCollector(self.CONFIG, station)
self.assertIsNotNone(custom_collector)
return custom_collector
def setup_recv_proxy(self, device_name='stat/recv/1'):
# setup RECV
recv_proxy = TestDeviceProxy(device_name)
recv_proxy.off()
recv_proxy.warm_boot()
recv_proxy.set_defaults()
return recv_proxy
def test_archiver_policy_attribute_list(self):
""" Test if the full set of archiving policy for the given device is retrieved """
device_name = 'stat/recv/1'
recv_proxy = self.setup_recv_proxy(device_name)
policy = tpc.ArchiverPolicy(self.CONFIG)
attribute_list = policy.policy.attribute_list(device_name, recv_proxy.get_attribute_list())
include = policy.config['devices']['stat/recv/1']['include'] # attribute that must be included
for i in include:
if '*' not in i: # exclude wildcard
self.assertIn(i, attribute_list)
exclude = policy.config['devices']['stat/recv/1']['exclude'] # attribute that must be excluded
for e in exclude:
if '*' not in e: # exclude wildcard
self.assertNotIn(e, attribute_list)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment