Skip to content

Commit

Permalink
Add healthcheck endpoint (#1012)
Browse files Browse the repository at this point in the history
* Add healthcheck endpoint

* Add unittest for healthcheck route

* Pin vin library version
  • Loading branch information
bmwant authored Oct 8, 2020
1 parent 8218da2 commit e64ceb0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions flower/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
(r"/api/task/events/task-custom/(.*)", events.TaskCustom),
# Metrics
(r"/metrics", monitor.Metrics),
(r"/healthcheck", monitor.Healthcheck),
# Static
(r"/static/(.*)", StaticFileHandler,
{"path": settings['static_path']}),
Expand Down
6 changes: 6 additions & 0 deletions flower/views/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ class Metrics(BaseHandler):
@gen.coroutine
def get(self):
self.write(prometheus_client.generate_latest())


class Healthcheck(BaseHandler):
@gen.coroutine
def get(self):
self.write("OK")
1 change: 1 addition & 0 deletions requirements/default.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
celery>=3.1.0; python_version<"3.7"
celery>=4.3.0; python_version>="3.7"
vine==1.3.0
tornado>=5.0.0,<7.0.0; python_version>="3.5.2"
prometheus_client==0.8.0
humanize
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/views/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@ def test_metrics(self):
self.assertTrue('task-received' in events)
self.assertTrue('task-started' in events)
self.assertTrue('task-succeeded' in events)


class HealthcheckTests(AsyncHTTPTestCase):
def setUp(self):
self.app = super(HealthcheckTests, self).get_app()
super(HealthcheckTests, self).setUp()

def get_app(self):
return self.app

def test_healthcheck_route(self):
response = self.get('/healthcheck').body.decode('utf-8')
self.assertEquals(response, 'OK')

0 comments on commit e64ceb0

Please sign in to comment.