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

TMSS-189: added a scheduling test for a scheduling_unit consisting of an observation and a pipeline

parent b90d9fb9
No related branches found
No related tags found
1 merge request!182Resolve TMSS-189 (and TMSS-192)
......@@ -167,6 +167,62 @@ class SchedulingTest(unittest.TestCase):
self.assertEqual('scheduled', ra_test_env.radb.getTask(tmss_id=pipe_subtask['id'])['status'])
def test_schedule_schedulingunit_enough_resources_available(self):
'''similar test as test_schedule_pipeline_subtask_with_enough_resources_available, but now created from a scheduling_unit'''
with tmss_test_env.create_tmss_client() as client:
scheduling_unit_template = client.get_schedulingunit_template("scheduling unit schema")
scheduling_unit_doc = get_default_json_object_for_schema(scheduling_unit_template['schema'])
# define an observation without QA
obs_task = get_default_json_object_for_schema(client.get_task_template(name="observation schema")['schema'])
obs_task['QA']['plots']['enabled'] = False
obs_task['QA']['file_conversion']['enabled'] = False
scheduling_unit_doc['tasks'].append({"name": "Observation",
"specifications_doc": obs_task,
"specifications_template": "observation schema"})
# define a pipeline
scheduling_unit_doc['tasks'].append({"name": "Pipeline",
"specifications_doc": get_default_json_object_for_schema(client.get_task_template(name="preprocessing schema")['schema']),
"specifications_template": "preprocessing schema"})
# connect obs to pipeline
scheduling_unit_doc['task_relations'].append({"producer": "Observation",
"consumer": "Pipeline",
"input": { "role": "input", "datatype": "visibilities" },
"output": { "role": "correlator", "datatype": "visibilities" },
"dataformat": "MeasurementSet",
"selection_doc": {},
"selection_template": "All" })
# submit
scheduling_unit_draft_data = test_data_creator.SchedulingUnitDraft(template_url=scheduling_unit_template['url'],
requirements_doc=scheduling_unit_doc)
scheduling_unit_draft = test_data_creator.post_data_and_get_response_as_json_object(scheduling_unit_draft_data, '/scheduling_unit_draft/')
# create the whole blueprints tree...
scheduling_unit_blueprint = client.create_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft['id'])
# fetch the created task_blueprints
task_blueprints = [client.get_url_as_json_object(task_blueprint_url) for task_blueprint_url in scheduling_unit_blueprint['task_blueprints']]
self.assertEqual(2, len(task_blueprints))
# and make sure they are ordered correctly
if "Pipeline" in task_blueprints[0]['name']:
task_blueprints.reverse()
for task_blueprint in task_blueprints:
self.assertEqual(1, len(task_blueprint['subtasks']))
subtask = client.get_url_as_json_object(task_blueprint['subtasks'][0])
client.set_subtask_status(subtask['id'], 'defined')
subtask = client.schedule_subtask(subtask['id'])
self.assertEqual('scheduled', subtask['state_value'])
self.assertEqual('scheduled', ra_test_env.radb.getTask(tmss_id=subtask['id'])['status'])
client.set_subtask_status(subtask['id'], 'finished')
if __name__ == "__main__":
os.environ['TZ'] = 'UTC'
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment