Skip to content
Snippets Groups Projects

L2SS-747: Fix integration tests

Merged Jan David Mol requested to merge L2SS-747-fix-master into master
1 file
+ 22
4
Compare changes
  • Side-by-side
  • Inline
@@ -14,6 +14,7 @@ from tangostationcontrol.toolkit.archiver_util import attribute_fqdn
from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy
import time
from tango import DeviceProxy
from datetime import datetime
@@ -23,6 +24,10 @@ class TestArchiver(BaseIntegrationTestCase):
super().setUp()
self.archiver = Archiver()
self.assertIsNotNone(self.archiver)
# Safety cleanup
self.archiver.cm.delete_property('__SubDevices')
DeviceProxy(self.archiver.get_subscribers()[0]).delete_property('AttributeList')
DeviceProxy(self.archiver.get_subscribers()[0]).delete_property('__SubDevices')
def test_archiver_initialisation(self):
"""Test archiver main attributes"""
@@ -61,8 +66,10 @@ class TestArchiver(BaseIntegrationTestCase):
self.archiver.remove_attributes_in_error()
time.sleep(3)
"""
polling_period=1000
archive_event_period=3000
attr_fullname = 'stat/recv/1/recvtr_translator_busy_r' # boolean
self.archiver.add_attribute_to_archiver(attr_fullname, polling_period=1000, archive_event_period=3000)
self.archiver.add_attribute_to_archiver(attr_fullname, polling_period, archive_event_period)
time.sleep(3)
# Test if the attribute has been correctly added to event subscriber
self.assertTrue(self.archiver.is_attribute_archived(attribute_fqdn(attr_fullname)))
@@ -70,7 +77,7 @@ class TestArchiver(BaseIntegrationTestCase):
# Retrieve data from DB views
self.retriever = RetrieverTimescale()
self.assertIsNotNone(self.retriever)
records = self.retriever.get_lofar_attribute(attr_fullname)
records = self._wait_for_archiving(attr_fullname, archive_event_period)
self.assertTrue(len(records)>0)
item = records[-1] # last table record
self.assertEqual('stat/recv/1',item.device) # column device
@@ -105,8 +112,10 @@ class TestArchiver(BaseIntegrationTestCase):
self.archiver.remove_attributes_in_error()
time.sleep(3)
"""
polling_period=1000
archive_event_period=3000
attr_fullname = 'stat/sdp/1/fpga_temp_r' # double
self.archiver.add_attribute_to_archiver(attr_fullname, polling_period=1000, archive_event_period=3000)
self.archiver.add_attribute_to_archiver(attr_fullname, polling_period, archive_event_period)
time.sleep(3)
# Test if the attribute has been correctly added to event subscriber
self.assertTrue(self.archiver.is_attribute_archived(attribute_fqdn(attr_fullname)))
@@ -114,7 +123,7 @@ class TestArchiver(BaseIntegrationTestCase):
# Retrieve data from DB views
self.retriever = RetrieverTimescale()
self.assertIsNotNone(self.retriever)
records = self.retriever.get_lofar_attribute(attr_fullname)
records = self._wait_for_archiving(attr_fullname, archive_event_period)
self.assertTrue(len(records)>0)
item = records[-1] # last table record
self.assertEqual('stat/sdp/1',item.device) # column device
@@ -151,3 +160,12 @@ class TestArchiver(BaseIntegrationTestCase):
time.sleep(3)
max_load = self.archiver.get_maximum_device_load(device_name)
self.assertGreater(max_load,0)
def _wait_for_archiving(self, attr_fullname: str, archive_event_period: int, max_wait: int = 10):
wait = 0
records = self.retriever.get_lofar_attribute(attr_fullname)
while (not(len(records)>0) and wait<max_wait):
time.sleep(archive_event_period)
records = self.retriever.get_lofar_attribute(attr_fullname)
wait+=1
return records
Loading