Skip to content
Snippets Groups Projects
Commit 7dff82ca authored by Auke Klazema's avatar Auke Klazema
Browse files

Task LSRT-15: Tasks without a mom id are now seen as non killable and does not...

Task LSRT-15: Tasks without a mom id are now seen as non killable and does not cause an exception. Reservations and maintenance tasks do not have a mom id.
parent 7179cb78
No related branches found
No related tags found
No related merge requests found
from datetime import datetime, timedelta
from lofar.common.cache import cache
from lofar.parameterset import parameterset
from lofar.sas.resourceassignment.database.radb import RADatabase
......@@ -603,14 +602,14 @@ class PriorityScheduler(StationScheduler):
# find all conflicting claims & which tasks they belong to
conflicting_claims, conflicting_tasks = self._get_conflicting_claims_and_tasks(conflict_claim)
conflicting_task_momids = [t["mom_id"] for t in conflicting_tasks]
conflicting_task_momids = [t["mom_id"] for t in conflicting_tasks if t["mom_id"]]
logger.debug("PriorityScheduler: conflicting claims are %s", conflicting_claims)
logger.debug("PriorityScheduler: conflicting tasks are %s", conflicting_tasks)
# check which tasks we can kill
task_priorities = self.momqueryservice.get_project_priorities_for_objects(conflicting_task_momids)
logger.debug("PriorityScheduler: conflicting task priorities are %s", task_priorities)
kill_task_list = [t for t in conflicting_tasks if task_priorities[t["mom_id"]] < self._my_task_priority()]
kill_task_list = [t for t in conflicting_tasks if t["mom_id"] and task_priorities[t["mom_id"]] < self._my_task_priority()]
logger.debug("PriorityScheduler: task kill list is %s", kill_task_list)
# update if we're blocked by an earlier task than we know so far
......
......@@ -378,6 +378,7 @@ class BasicSchedulerTest(SchedulerTest):
allocation_succesful = self.new_scheduler(1, lambda _: estimates).allocate_resources()
self.assertFalse(allocation_succesful)
class StationSchedulerTest(BasicSchedulerTest):
# The StationScheduler must not regress on the BasicScheduler, so we inherit all its tests
......@@ -651,6 +652,18 @@ class PrioritySchedulerTest(StationSchedulerTest):
self.fake_ra_database.commit()
self.fake_ra_database.committed = False # dont confuse subsequent checks on whether the scheduler committed
def new_task_without_momid(self, task_id):
self.fake_ra_database.addTask(task_id, {
"mom_id": None,
"otdb_id": 2000 + task_id,
"type": "observation",
"starttime": datetime.datetime(2017, 1, 1, 1, 0, 0),
"endtime": datetime.datetime(2017, 1, 1, 2, 0, 0),
})
self.fake_ra_database.commit()
self.fake_ra_database.committed = False # dont confuse subsequent checks on whether the scheduler committed
def new_scheduler(self, task_id, resource_estimator):
return PriorityScheduler(task_id, self.get_specification_tree(task_id), resource_estimator, self.fake_resource_availability_checker, None)
......@@ -740,6 +753,23 @@ class PrioritySchedulerTest(StationSchedulerTest):
otdb_id = self.fake_ra_database.tasks[0]["otdb_id"]
self.obscontrol_mock.assert_called_with(otdb_id)
def test_should_not_kill_a_task_without_a_mom_id(self):
# First task must succeed
self.new_task_without_momid(0)
estimates = [{'resource_types': {'bandwidth': 512}}]
allocation_succesful = self.new_scheduler(0, lambda _: estimates).allocate_resources()
self.assertTrue(allocation_succesful)
self.new_task(1000)
estimates = [{'resource_types': {'bandwidth': 513}}]
allocation_succesful = self.new_scheduler(1000, lambda _: estimates).allocate_resources()
self.assertFalse(allocation_succesful)
# First task must have been killed
otdb_id = self.fake_ra_database.tasks[0]["otdb_id"]
self.obscontrol_mock.assert_not_called()
class DwellSchedulerTest(PrioritySchedulerTest):
# The DwellScheduler must not regress on the PriorityScheduler, so we inherit all its tests
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment