Skip to content

Commit

Permalink
Make sure to cleanup only the runs that are assigned to the worker.
Browse files Browse the repository at this point in the history
  • Loading branch information
brocaar committed Apr 12, 2013
1 parent ef0bd8d commit 25966d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.rst
Expand Up @@ -121,6 +121,13 @@ For starting the worker, you can use the ``job_runner_worker`` command::
Changes
-------

v2.0.1
~~~~~~

* Make sure to only cleanup runs that are assigned to the worker. This version
is dependent on ``job-runner>=3.0.1``.


v2.0.0
~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion job_runner_worker/__init__.py
@@ -1 +1 @@
__version__ = '2.0.0'
__version__ = '2.0.1'
1 change: 1 addition & 0 deletions job_runner_worker/cleanup.py
Expand Up @@ -24,6 +24,7 @@ def reset_incomplete_runs():
config.get('job_runner_worker', 'run_resource_uri'),
params={
'state': state,
'worker__api_key': config.get('job_runner_worker', 'api_key'),
}
))

Expand Down
13 changes: 10 additions & 3 deletions job_runner_worker/tests/unit/test_cleanup.py
Expand Up @@ -17,7 +17,8 @@ def test_reset_incomplete_runs(self, config, Run):
"""
def config_side_effect(*args):
return {
('job_runner_worker', 'run_resource_uri'): '/api/run/'
('job_runner_worker', 'run_resource_uri'): '/api/run/',
('job_runner_worker', 'api_key'): 'test_api_key',
}[args]

config.get.side_effect = config_side_effect
Expand All @@ -29,8 +30,14 @@ def config_side_effect(*args):
reset_incomplete_runs()

self.assertEqual([
call('/api/run/', params={'state': 'in_queue'}),
call('/api/run/', params={'state': 'started'}),
call('/api/run/', params={
'state': 'in_queue',
'worker__api_key': 'test_api_key',
}),
call('/api/run/', params={
'state': 'started',
'worker__api_key': 'test_api_key',
}),
], Run.get_list.call_args_list)

incomplete_run.patch.assert_called_once_with({
Expand Down

0 comments on commit 25966d7

Please sign in to comment.