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

L2SS-542: add archive-attributes integration tests

parent 77502150
No related branches found
No related tags found
1 merge request!240Resolve L2SS-542 "Add timescaledb views"
...@@ -8,14 +8,22 @@ ...@@ -8,14 +8,22 @@
# 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.tangostationcontrol.toolkit.archiver import Archiver from tangostationcontrol.toolkit.archiver import *
from tangostationcontrol.toolkit.retriever import RetrieverTimescale
from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy
import time
from datetime import datetime
class TestArchiver(BaseIntegrationTestCase): class TestArchiver(BaseIntegrationTestCase):
def test_archiver_initialisation(self): def setUp(self):
"""Test archiver main attributes""" super().setUp()
self.archiver = Archiver() self.archiver = Archiver()
self.assertIsNotNone(self.archiver) self.assertIsNotNone(self.archiver)
def test_archiver_initialisation(self):
"""Test archiver main attributes"""
self.assertEqual(self.archiver.cm_name,"archiving/hdbppts/confmanager01") self.assertEqual(self.archiver.cm_name,"archiving/hdbppts/confmanager01")
self.assertTrue(len(self.archiver.es_list)) # subscribers list not empty self.assertTrue(len(self.archiver.es_list)) # subscribers list not empty
...@@ -32,3 +40,82 @@ class TestArchiver(BaseIntegrationTestCase): ...@@ -32,3 +40,82 @@ class TestArchiver(BaseIntegrationTestCase):
"""Test archiver configuration file""" """Test archiver configuration file"""
config_dict = self.archiver.get_configuration() config_dict = self.archiver.get_configuration()
self.assertIsNotNone(config_dict) self.assertIsNotNone(config_dict)
# Apply the configuration file
self.archiver.apply_configuration(config_dict)
def test_archive_scalar_attribute(self):
"""Test if a scalar attribute is correctly archived"""
# Start RECV Device
recv_proxy = TestDeviceProxy("STAT/RECV/1")
recv_proxy.off()
time.sleep(1)
recv_proxy.initialise()
time.sleep(1)
self.assertEqual(DevState.STANDBY, recv_proxy.state())
recv_proxy.set_defaults()
recv_proxy.on()
self.assertEqual(DevState.ON, recv_proxy.state())
# Safety operation that prevents event subscriber to go in Fault state
self.archiver.remove_attributes_in_error()
attr_fullname = 'stat/recv/1/recvtr_translator_busy_r' # boolean
self.archiver.add_attribute_to_archiver(attr_fullname, polling_period=1000, event_period=3000)
time.sleep(3)
# Test if the attribute has been correctly added to event subscriber
self.assertTrue(self.archiver.is_attribute_archived(attr_fullname))
# Retrieve data from DB views
self.retriever = RetrieverTimescale()
self.assertIsNotNone(self.retriever)
records = self.retriever.get_lofar_attribute(attr_fullname)
self.assertTrue(len(records)>0)
self.assertEqual('stat/recv/1',[item.device for item in records][-1]) # column device
self.assertEqual('recvtr_translator_busy_r',[item.name for item in records][-1]) # column attribute
self.assertEqual(datetime,type([item.data_time for item in records][-1])) # column datetime
self.assertEqual(bool,type([item.value for item in records][-1])) # column value
# Remove attribute at the end of the test
self.archiver.remove_attribute_from_archiver(attr_fullname)
time.sleep(3)
# Test if the attribute has been correctly removed
self.assertFalse(self.archiver.is_attribute_archived(attr_fullname))
recv_proxy.off()
def test_archive_array_attribute(self):
"""Test if an array attribute is correctly archived"""
# Start SDP Device
sdp_proxy = TestDeviceProxy("STAT/SDP/1")
sdp_proxy.off()
time.sleep(1)
sdp_proxy.initialise()
time.sleep(1)
self.assertEqual(DevState.STANDBY, sdp_proxy.state())
sdp_proxy.set_defaults()
sdp_proxy.on()
self.assertEqual(DevState.ON, sdp_proxy.state())
# Safety operation that prevents event subscriber to go in Fault state
self.archiver.remove_attributes_in_error()
attr_fullname = 'stat/sdp/1/fpga_temp_r' # double
self.archiver.add_attribute_to_archiver(attr_fullname, polling_period=1000, event_period=3000)
time.sleep(5)
# Test if the attribute has been correctly added to event subscriber
self.assertTrue(self.archiver.is_attribute_archived(attr_fullname))
# Retrieve data from DB views
self.retriever = RetrieverTimescale()
self.assertIsNotNone(self.retriever)
records = self.retriever.get_lofar_attribute(attr_fullname)
self.assertTrue(len(records)>0)
self.assertEqual('stat/sdp/1',[item.device for item in records][-1]) # column device
self.assertEqual('fpga_temp_r',[item.name for item in records][-1]) # column attribute
self.assertEqual(datetime,type([item.data_time for item in records][-1])) # column datetime
self.assertEqual(int,type([item.x for item in records][-1])) # column index
self.assertEqual(float,type([item.value for item in records][-1])) # column value
# Remove attribute at the end of the test
self.archiver.remove_attribute_from_archiver(attr_fullname)
time.sleep(3)
# Test if the attribute has been correctly removed
self.assertFalse(self.archiver.is_attribute_archived(attr_fullname))
sdp_proxy.off()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment