diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e9acfe73b5ae00a8ee3e7ba3ca4695a9122ab9aa..5c6e486d84dde4fcd4c4c02db86bc0cc72152c39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -474,6 +474,7 @@ integration_test_docker: fi - apk add --update make bash docker-compose - apk add --update bind-tools + - apk add --update postgresql14-client gzip - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script: - touch /root/.Xauthority @@ -498,6 +499,7 @@ integration_test_docker: echo "Saving log for container $container" docker logs "${container}" >& "log/${container}.log" done + PGPASSWORD=password pg_dump --host=docker --username=postgres hdb 2>log/archiver-timescale-dump.log | gzip > log/archiver-timescale-dump.txt.gz wheel_packaging: stage: packaging artifacts: diff --git a/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py b/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py index 1ead9d257645eeb3934b57052cd3cbd89bce39d6..ebe7a59e57632b107ef1eaa61fb9e36de56b168b 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py @@ -61,8 +61,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 +72,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 +107,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 +118,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 +155,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