Skip to content
Snippets Groups Projects
Commit ca0bcd23 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-60: integrated TMSS using a TMSSTestEnvironment in the t_qa_service, and...

TMSS-60: integrated TMSS using a TMSSTestEnvironment in the t_qa_service, and letting TMSS send a status EventMessage upon setting the status.
parent 4f952cfc
Branches
Tags
1 merge request!154Resolve TMSS-60 and TMSS-171 and TMSS-198
......@@ -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
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment