[ADD] Health checks for load balancers.
https://tools.ietf.org/html/draft-inadarei-api-health-check-04 closes odoo/odoo#56522 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import json
|
||||
|
||||
from odoo import exceptions, _
|
||||
from odoo.http import Controller, request, route
|
||||
@@ -42,3 +44,12 @@ class BusController(Controller):
|
||||
@route('/longpolling/im_status', type="json", auth="user")
|
||||
def im_status(self, partner_ids):
|
||||
return request.env['res.partner'].with_context(active_test=False).search([('id', 'in', partner_ids)]).read(['im_status'])
|
||||
|
||||
@route('/longpolling/health', type='http', auth='none', save_session=False)
|
||||
def health(self):
|
||||
data = json.dumps({
|
||||
'status': 'pass',
|
||||
})
|
||||
headers = [('Content-Type', 'application/json'),
|
||||
('Cache-Control', 'no-store')]
|
||||
return request.make_response(data, headers)
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
from . import test_assetsbundle
|
||||
from . import test_health
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import HttpCase
|
||||
|
||||
|
||||
class TestBusController(HttpCase):
|
||||
def test_health(self):
|
||||
response = self.url_open('/longpolling/health')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
payload = response.json()
|
||||
self.assertEqual(payload['status'], 'pass')
|
||||
self.assertNotIn('session_id', response.cookies)
|
||||
@@ -903,6 +903,16 @@ class Home(http.Controller):
|
||||
|
||||
return request.redirect(self._login_redirect(uid))
|
||||
|
||||
@http.route('/web/health', type='http', auth='none', save_session=False)
|
||||
def health(self):
|
||||
data = json.dumps({
|
||||
'status': 'pass',
|
||||
})
|
||||
headers = [('Content-Type', 'application/json'),
|
||||
('Cache-Control', 'no-store')]
|
||||
return request.make_response(data, headers)
|
||||
|
||||
|
||||
class WebClient(http.Controller):
|
||||
|
||||
@http.route('/web/webclient/locale/<string:lang>', type='http', auth="none")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_health
|
||||
from . import test_image
|
||||
from . import test_js
|
||||
from . import test_menu
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import HttpCase
|
||||
|
||||
|
||||
class TestWebController(HttpCase):
|
||||
def test_health(self):
|
||||
response = self.url_open('/web/health')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
payload = response.json()
|
||||
self.assertEqual(payload['status'], 'pass')
|
||||
self.assertNotIn('session_id', response.cookies)
|
||||
Reference in New Issue
Block a user