Skip to content
Snippets Groups Projects
Commit f48321f9 authored by Roy de Goei's avatar Roy de Goei
Browse files

TMSS-501 One testcase fix of dynamic_scheduler and add some comment

parent e3f0fcfa
No related branches found
No related tags found
1 merge request!364Resolve TMSS-501
...@@ -132,7 +132,7 @@ def schedule_next_scheduling_unit() -> models.SchedulingUnitBlueprint: ...@@ -132,7 +132,7 @@ def schedule_next_scheduling_unit() -> models.SchedulingUnitBlueprint:
def assign_start_stop_times_to_schedulable_scheduling_units(lower_bound_start_time: datetime): def assign_start_stop_times_to_schedulable_scheduling_units(lower_bound_start_time: datetime):
'''''' ''''''
logger.info("Estimating mid-term schedule...") logger.info("Estimating mid-term schedule with lower_bound_start_time=%s ..." % lower_bound_start_time)
scheduling_units = get_schedulable_scheduling_units() scheduling_units = get_schedulable_scheduling_units()
...@@ -147,6 +147,9 @@ def assign_start_stop_times_to_schedulable_scheduling_units(lower_bound_start_ti ...@@ -147,6 +147,9 @@ def assign_start_stop_times_to_schedulable_scheduling_units(lower_bound_start_ti
start_time = round_to_second_precision(best_scored_scheduling_unit.start_time) start_time = round_to_second_precision(best_scored_scheduling_unit.start_time)
logger.info("mid-term schedule: next scheduling unit id=%s '%s' start_time=%s", scheduling_unit.id, scheduling_unit.name, start_time) logger.info("mid-term schedule: next scheduling unit id=%s '%s' start_time=%s", scheduling_unit.id, scheduling_unit.name, start_time)
update_subtasks_start_times_for_scheduling_unit(scheduling_unit, start_time) update_subtasks_start_times_for_scheduling_unit(scheduling_unit, start_time)
# TODO check this?
# If the start_time of the subtasks are updated, should the start_time (and stop_time) of the
# scheduling_unit also be updated? Currently its a cached property
# keep track of the lower_bound_start_time based on last sub.stoptime and gap # keep track of the lower_bound_start_time based on last sub.stoptime and gap
lower_bound_start_time = scheduling_unit.stop_time + DEFAULT_INTER_OBSERVATION_GAP lower_bound_start_time = scheduling_unit.stop_time + DEFAULT_INTER_OBSERVATION_GAP
......
...@@ -136,7 +136,7 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst ...@@ -136,7 +136,7 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst
scheduling_constraints_doc=constraints, scheduling_constraints_doc=constraints,
scheduling_constraints_template=constraints_template) scheduling_constraints_template=constraints_template)
@unittest.skip("FIX TEST, skipping it for now") @unittest.skip("FIX TEST, skipping it for now, see TODO comment in assign_start_stop_times_to_schedulable_scheduling_units")
def test_three_simple_observations_no_constraints_different_project_priority(self): def test_three_simple_observations_no_constraints_different_project_priority(self):
scheduling_unit_draft_low = self.create_simple_observation_scheduling_unit("scheduling unit low", scheduling_set=self.scheduling_set_low) scheduling_unit_draft_low = self.create_simple_observation_scheduling_unit("scheduling unit low", scheduling_set=self.scheduling_set_low)
scheduling_unit_blueprint_low = create_task_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft_low) scheduling_unit_blueprint_low = create_task_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft_low)
...@@ -179,9 +179,8 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst ...@@ -179,9 +179,8 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst
self.assertGreaterEqual(scheduling_unit_blueprint_medium.start_time - scheduling_unit_blueprint_high.stop_time, DEFAULT_INTER_OBSERVATION_GAP) self.assertGreaterEqual(scheduling_unit_blueprint_medium.start_time - scheduling_unit_blueprint_high.stop_time, DEFAULT_INTER_OBSERVATION_GAP)
self.assertGreaterEqual(scheduling_unit_blueprint_low.start_time - scheduling_unit_blueprint_medium.stop_time, DEFAULT_INTER_OBSERVATION_GAP) self.assertGreaterEqual(scheduling_unit_blueprint_low.start_time - scheduling_unit_blueprint_medium.stop_time, DEFAULT_INTER_OBSERVATION_GAP)
@unittest.skip("FIX TEST, skipping it for now")
def test_time_bound_unit_wins_even_at_lower_priority(self): def test_time_bound_unit_wins_even_at_lower_priority(self):
# create two schedunits, one with high one with low prio. # create two schedule units, one with high one with low prio.
# first create them without any further constraints, and check if high prio wins. # first create them without any further constraints, and check if high prio wins.
scheduling_unit_draft_low = self.create_simple_observation_scheduling_unit("scheduling unit low", scheduling_set=self.scheduling_set_low) scheduling_unit_draft_low = self.create_simple_observation_scheduling_unit("scheduling unit low", scheduling_set=self.scheduling_set_low)
scheduling_unit_blueprint_low = create_task_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft_low) scheduling_unit_blueprint_low = create_task_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft_low)
...@@ -212,22 +211,23 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst ...@@ -212,22 +211,23 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst
# update the low prio unit. enlarge the time window constraint a bit, so both low and high prio units can fit # update the low prio unit. enlarge the time window constraint a bit, so both low and high prio units can fit
# this should result that the high prio goes first, and the low prio (which now fits as well) goes second # this should result that the high prio goes first, and the low prio (which now fits as well) goes second
scheduling_unit_draft_low.scheduling_constraints_doc['time'] = { 'before': (now+scheduling_unit_draft_low.duration+scheduling_unit_draft_high.duration).isoformat()+'Z' } scheduling_unit_draft_low.scheduling_constraints_doc['time'] = \
{ 'before': (now+scheduling_unit_draft_low.duration+scheduling_unit_draft_high.duration).isoformat()+'Z' }
scheduling_unit_draft_low.save() scheduling_unit_draft_low.save()
scheduling_unit_blueprint_low.refresh_from_db() scheduling_unit_blueprint_low.refresh_from_db()
# call the method-under-test. # call the method-under-test.
best_scored_scheduling_unit = find_best_next_schedulable_unit([scheduling_unit_blueprint_low, scheduling_unit_blueprint_high], now, tomorrow) best_scored_scheduling_unit = find_best_next_schedulable_unit([scheduling_unit_blueprint_low, scheduling_unit_blueprint_high], now, tomorrow)
# now we expect the scheduling_unit with the lowest project rank to be scheduled first because it can only run within this limited timewindow # now we expect the scheduling_unit with the lowest project rank to be scheduled first because it can only
self.assertEqual(scheduling_unit_blueprint_high.id, best_scored_scheduling_unit.scheduling_unit.id) # run within this limited timewindow
self.assertEqual(scheduling_unit_blueprint_low.id, best_scored_scheduling_unit.scheduling_unit.id)
# call the method-under-test again but search after first unit (should return low prio unit) # call the method-under-test again but search after first unit (should return low prio unit)
stop_time_of_first = best_scored_scheduling_unit.start_time + best_scored_scheduling_unit.scheduling_unit.duration stop_time_of_first = best_scored_scheduling_unit.start_time + best_scored_scheduling_unit.scheduling_unit.duration
best_scored_scheduling_unit = find_best_next_schedulable_unit([scheduling_unit_blueprint_low, scheduling_unit_blueprint_high], stop_time_of_first, tomorrow) best_scored_scheduling_unit = find_best_next_schedulable_unit([scheduling_unit_blueprint_low, scheduling_unit_blueprint_high], stop_time_of_first, tomorrow)
self.assertEqual(scheduling_unit_blueprint_low.id, best_scored_scheduling_unit.scheduling_unit.id) self.assertEqual(scheduling_unit_blueprint_low.id, best_scored_scheduling_unit.scheduling_unit.id)
def test_manual_constraint_is_preventing_scheduling_unit_from_being_scheduled_dynamically(self): def test_manual_constraint_is_preventing_scheduling_unit_from_being_scheduled_dynamically(self):
scheduling_unit_draft_manual = self.create_simple_observation_scheduling_unit("scheduling unit manual low", scheduling_set=self.scheduling_set_low, scheduling_unit_draft_manual = self.create_simple_observation_scheduling_unit("scheduling unit manual low", scheduling_set=self.scheduling_set_low,
constraints={'scheduler': 'manual'}) constraints={'scheduler': 'manual'})
...@@ -244,7 +244,7 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst ...@@ -244,7 +244,7 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst
scheduling_unit_blueprint_manual.refresh_from_db() scheduling_unit_blueprint_manual.refresh_from_db()
self.assertEqual(scheduling_unit_blueprint_manual.status, 'schedulable') self.assertEqual(scheduling_unit_blueprint_manual.status, 'schedulable')
@unittest.skip("FIX TEST, skipping it for now") @unittest.skip("FIX TEST, skipping it for now,...something with manual scheduler ?")
def test_manually_scheduled_blocking_dynamically_scheduled(self): def test_manually_scheduled_blocking_dynamically_scheduled(self):
scheduling_unit_draft_manual = self.create_simple_observation_scheduling_unit("scheduling unit manual low", scheduling_set=self.scheduling_set_low, scheduling_unit_draft_manual = self.create_simple_observation_scheduling_unit("scheduling unit manual low", scheduling_set=self.scheduling_set_low,
constraints={'scheduler': 'manual'}) constraints={'scheduler': 'manual'})
...@@ -260,7 +260,7 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst ...@@ -260,7 +260,7 @@ class TestDynamicScheduling(TestCase): # Note: we use django.test.TestCase inst
# call the method-under-test. # call the method-under-test.
scheduled_scheduling_unit = do_dynamic_schedule() scheduled_scheduling_unit = do_dynamic_schedule()
# we expect the no scheduling_unit to be scheduled, because the manual is in the way # we expect the no scheduling_unit to be scheduled, because the manual is in the way -> Fix it
self.assertIsNone(scheduled_scheduling_unit) self.assertIsNone(scheduled_scheduling_unit)
# check the results # check the results
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment