Merge lp:~elachuni/ubuntu-webcatalog/celery-preflight into lp:ubuntu-webcatalog

Proposed by Anthony Lenton
Status: Merged
Approved by: Łukasz Czyżykowski
Approved revision: 171
Merged at revision: 173
Proposed branch: lp:~elachuni/ubuntu-webcatalog/celery-preflight
Merge into: lp:ubuntu-webcatalog
Diff against target: 83 lines (+13/-5)
3 files modified
setup.py (+2/-2)
src/webcatalog/preflight.py (+4/-0)
src/webcatalog/tests/test_preflight.py (+7/-3)
To merge this branch: bzr merge lp:~elachuni/ubuntu-webcatalog/celery-preflight
Reviewer Review Type Date Requested Status
Łukasz Czyżykowski Pending
Review via email: mp+126996@code.launchpad.net

Commit message

Added a preflight check to see if the Celery worker is up and running.

Description of the change

Added a preflight check to see if the Celery worker is up and running.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2012-08-23 15:07:44 +0000
3+++ setup.py 2012-09-28 15:35:42 +0000
4@@ -50,8 +50,8 @@
5 'ssoclient==1.0',
6 'pep8',
7 'PIL',
8- 'celery',
9- 'django-celery',
10+ 'celery==2.5.0',
11+ 'django-celery==2.5.0',
12 'oops-wsgi==0.0.10',
13 'oops-dictconfig==0.0.2',
14 'oops-datedir_repo==0.0.17',
15
16=== modified file 'src/webcatalog/preflight.py'
17--- src/webcatalog/preflight.py 2012-07-02 21:25:30 +0000
18+++ src/webcatalog/preflight.py 2012-09-28 15:35:42 +0000
19@@ -19,6 +19,7 @@
20
21 from __future__ import absolute_import
22
23+from celery.app import default_app
24 from django import db
25 from django.conf import settings
26 from preflight import Preflight, register
27@@ -83,5 +84,8 @@
28
29 return True
30
31+ def check_celery_workers(self):
32+ """Check that the celery worker is up and running."""
33+ return len(default_app.control.ping()) > 0
34
35 register(WebcatalogPreflight)
36
37=== modified file 'src/webcatalog/tests/test_preflight.py'
38--- src/webcatalog/tests/test_preflight.py 2012-06-27 17:03:15 +0000
39+++ src/webcatalog/tests/test_preflight.py 2012-09-28 15:35:42 +0000
40@@ -28,12 +28,13 @@
41
42
43 class TestPreflight(TestCaseWithFactory):
44+ @patch('celery.app.default_app.control.ping')
45 @patch('webcatalog.utilities.WebServices.identity_provider')
46 @patch('webcatalog.utilities.WebServices.get_screenshots_for_package')
47 @patch('webcatalog.utilities.WebServices.recommender_api')
48 @patch('webcatalog.utilities.WebServices.rnr_api')
49- def test_login_needed_for_preflight(self, mock_rnr, mock_recommender,
50- mock_screenshots, mock_sso):
51+ def test_preflight_requires_login(self, mock_rnr, mock_recommender,
52+ mock_screenshots, mock_sso, mock_ping):
53 self.make_user(groups=['preflight'], logged_in=True)
54
55 with patch_settings(PREFLIGHT_GROUPS=['preflight']):
56@@ -54,16 +55,18 @@
57
58 self.assertEqual(404, response.status_code)
59
60+ @patch('celery.app.default_app.control.ping')
61 @patch('webcatalog.utilities.WebServices.identity_provider')
62 @patch('webcatalog.utilities.WebServices.get_screenshots_for_package')
63 @patch('webcatalog.utilities.WebServices.recommender_api')
64 @patch('webcatalog.utilities.WebServices.rnr_api')
65 def test_success(self, mock_rnr, mock_recommender, mock_screenshots,
66- mock_sso):
67+ mock_sso, mock_ping):
68 mock_rnr.server_status.return_value = 'ok'
69 mock_recommender.server_status.return_value = 'ok'
70 mock_screenshots.return_value = ['some_screenshot.jpg']
71 mock_sso.validate_token.return_value = False
72+ mock_ping.return_value = ['worker-1']
73 self.make_user(groups=['preflight'], logged_in=True)
74
75 with patch_settings(PREFLIGHT_GROUPS=['preflight']):
76@@ -88,6 +91,7 @@
77 ('recommender_available', True),
78 ('rnr_available', True),
79 ('screenshots_available', True),
80+ ('celery_workers', True),
81 ])
82 self.assertEqual(expected_libs, libs)
83 self.assertEqual(expected_checks, checks)

Subscribers

People subscribed via source and target branches