Skip to content

Commit

Permalink
Merge pull request #69 from brocaar/fix_do_not_schedule_disabled_chil…
Browse files Browse the repository at this point in the history
…dren

Do not schedule disabled children.
  • Loading branch information
Guillaume committed May 16, 2013
2 parents c5faf85 + 81e21e1 commit 128cae3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.rst
Expand Up @@ -54,6 +54,13 @@ Links
Changes
-------

v3.1.2
~~~~~~

* Fix: do not schedule disabled children (regression introduced by the new
way of scheduling in v3.1.0).


v3.1.1
~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion job_runner/__init__.py
@@ -1 +1 @@
__version__ = '3.1.1'
__version__ = '3.1.2'
3 changes: 2 additions & 1 deletion job_runner/apps/job_runner/signals.py
Expand Up @@ -69,4 +69,5 @@ def post_run_update(sender, instance, created, raw, **kwargs):
# the job completed successfully including it's siblings
# and has children to schedule now
for child in instance.job.children.all():
child.schedule()
if child.enqueue_is_enabled:
child.schedule()
22 changes: 22 additions & 0 deletions job_runner/apps/job_runner/tests/functional/test_api.py
Expand Up @@ -853,6 +853,28 @@ def test_patch_with_reschedule(self):
self.assertEqual(202, response.status_code)
self.assertEqual(1, Job.objects.get(pk=3).run_set.count())

def test_patch_with_disabled_child(self):
"""
Test PATCH ``/api/v1/run/1/`` for chained job with disabled child.
When enqueue_is_enabled=False, we do not expect that the child will
be scheduled.
"""
Job.objects.filter(pk=3).update(enqueue_is_enabled=False)
Run.objects.update(enqueue_dts=timezone.now())
self.assertEqual(0, Job.objects.get(pk=3).run_set.count())
response = self.patch(
'/api/v1/run/1/',
{
'return_dts': timezone.now().isoformat(' '),
'return_success': True,
}
)

self.assertEqual(202, response.status_code)
self.assertEqual(0, Job.objects.get(pk=3).run_set.count())

def test_patch_with_reschedule_no_children_reschedule(self):
"""
Test PATCH ``/api/v1/run/1/`` for chained job but not reschedule
Expand Down

0 comments on commit 128cae3

Please sign in to comment.