diff --git a/QA/QA_Service/lib/qa_service.py b/QA/QA_Service/lib/qa_service.py index 13a8e1b874c55f410fb1033f8ef412bf62dbc691..c78bbc80c26995e0aea6e4806ccdf27022b97edb 100644 --- a/QA/QA_Service/lib/qa_service.py +++ b/QA/QA_Service/lib/qa_service.py @@ -188,7 +188,7 @@ class QAService: return if subtask_id: - hdf5_file_path = self._convert_ms2hdf5(subtask_id) + hdf5_file_path = self._convert_ms2hdf5(otdb_id=otdb_id, subtask_id=subtask_id) if hdf5_file_path: # cluster it diff --git a/QA/QA_Service/test/t_qa_service.py b/QA/QA_Service/test/t_qa_service.py index 508007d1f7fd05e2bd4cfdbaa8a4a4f41da996b5..5bf33508b46f28b260a2f9248f7031a915177bcc 100755 --- a/QA/QA_Service/test/t_qa_service.py +++ b/QA/QA_Service/test/t_qa_service.py @@ -28,6 +28,7 @@ from datetime import datetime import logging from lofar.sas.tmss.client.tmssbuslistener import DEFAULT_TMSS_SUBTASK_NOTIFICATION_PREFIX +from lofar.sas.tmss.test.test_utils import TMSSTestEnvironment logger = logging.getLogger(__name__) @@ -96,7 +97,7 @@ class TestQAService(unittest.TestCase): ''' self.TEST_UUID = uuid.uuid1() self.TEST_OTDB_ID = 999999 - self.TEST_TMSS_ID = 2000000+999999 + self.TEST_TMSS_ID = 2000001#+999999 self.tmp_exchange = TemporaryExchange("%s_%s" % (__class__.__name__, self.TEST_UUID)) self.tmp_exchange.open() @@ -189,15 +190,6 @@ class TestQAService(unittest.TestCase): "time_of_change": datetime.utcnow()}) sender.send(msg) - def send_tmss_task_scheduled_event(self): - '''helper method: create a ToBus and send a scheduled EventMessage''' - with self.tmp_exchange.create_tobus() as sender: - msg = EventMessage(subject="%s.Scheduled" % (DEFAULT_TMSS_SUBTASK_NOTIFICATION_PREFIX,), - content={"subtask_id": self.TEST_TMSS_ID, - "old_state": "scheduling", - "new_state": 'scheduled'}) - sender.send(msg) - def test_01_qa_service_for_expected_behaviour(self): ''' This test starts a QAService, triggers a test observation completing event, @@ -503,6 +495,7 @@ class TestQAService(unittest.TestCase): the intermediate steps are tested in other tests/modules. ''' logger.info(' -- test_05_qa_service_for_expected_behaviour_on_tmss_events -- ') + import requests # override the mock behaviour from setUp for this specific test def mocked_wrap_command_for_docker(cmd, image_name=None, image_label=None): @@ -541,13 +534,17 @@ class TestQAService(unittest.TestCase): # start the QAService (the object under test) qaservice = QAService(exchange=self.tmp_exchange.address) - with qaservice, BusListenerJanitor(qaservice.filtering_otdbbuslistener), BusListenerJanitor(qaservice.filtering_tmssbuslistener), BusListenerJanitor(qaservice.commands_buslistener): + tmss_test_env = TMSSTestEnvironment(exchange=self.tmp_exchange.address) + with qaservice, tmss_test_env, BusListenerJanitor(qaservice.filtering_otdbbuslistener), BusListenerJanitor(qaservice.filtering_tmssbuslistener), BusListenerJanitor(qaservice.commands_buslistener): # start listening for QA event messages from the QAService with BusListenerJanitor(SynchronizationQABusListener(exchange=self.tmp_exchange.address)) as qa_listener: - # trigger a qa process by sending tmss subtask finished event + # trigger a qa process by setting the tmss subtask to scheduled # this will result in the QAService actually doing its magic - self.send_tmss_task_scheduled_event() + auth = requests.auth.HTTPBasicAuth(tmss_test_env.ldap_server.dbcreds.user, tmss_test_env.ldap_server.dbcreds.password) + requests.patch(url=tmss_test_env.django_server.url+'/subtask/%s/' % self.TEST_TMSS_ID, + json={'state': tmss_test_env.django_server.url+"/subtask_state/scheduled/" }, + auth=auth) # start waiting until ConvertedMS2Hdf5 event message received (or timeout) qa_listener.converted_event.wait(30)