Remove custom healthcheck app and use oslo middleware instead

We shouldn't use custom healthcheck instead we should use the oslo
middleware healthcheck.

Change-Id: Ib8decdc33dbf3ce7e2e4c28890322f8466748275
This commit is contained in:
Saad Zaher 2017-03-13 16:04:05 +00:00
parent 7579e59f20
commit 231548dfec
3 changed files with 1 additions and 64 deletions

View File

@ -15,10 +15,6 @@ paste.filter_factory = oslo_middleware:Healthcheck.factory
backends = disable_by_file
disable_by_file_path = /etc/freezer/healthcheck_disable
# @todo deprecated and should be removed soon
[filter:HealthApp]
paste.filter_factory = freezer_api.api.common.middleware:HealthApp.factory
[filter:context]
paste.filter_factory = freezer_api.api.common.middleware:ContextMiddleware.factory
@ -32,7 +28,7 @@ paste.filter_factory = oslo_middleware:HTTPProxyToWSGI.factory
pipeline = healthcheck http_proxy_to_wsgi versionsNegotiator authtoken context backupapp
[pipeline:unauthenticated_freezer_api]
pipeline = http_proxy_to_wsgi HealthApp Healthcheck freezer_app
pipeline = http_proxy_to_wsgi healthcheck freezer_app
[composite:backupapp]
paste.composite_factory = freezer_api.cmd.api:root_app_factory

View File

@ -72,21 +72,6 @@ class Middleware(object):
return e
# @todo this should be removed and oslo.middleware should be used instead
class HealthApp(Middleware):
"""
Simple WSGI app to support HAProxy polling.
If the requested url matches the configured path it replies
with a 200 otherwise passes the request to the inner app
"""
def __call__(self, environ, start_response):
if environ.get('PATH_INFO') == '/v1/health':
start_response('200 OK', [])
return []
return self.app(environ, start_response)
class HookableMiddlewareMixin(object):
"""Provides methods to extract before and after hooks from WSGI Middleware

View File

@ -1,44 +0,0 @@
"""Freezer swift.py related tests
(c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import unittest
import mock
from freezer_api.api.common import middleware
class TestHealthApp(unittest.TestCase):
def test_call_nested_app(self):
mock_app = mock.Mock()
mock_app.return_value = ['app_body']
health_app = middleware.HealthApp(mock_app)
environ = {}
start_response = mock.Mock()
result = health_app(environ, start_response)
self.assertEqual(result, ['app_body'])
def test_return_200_when_paths_match(self):
mock_app = mock.Mock()
mock_app.return_value = ['app_body']
health_app = middleware.HealthApp(mock_app)
environ = {'PATH_INFO': '/v1/health'}
start_response = mock.Mock()
result = health_app(environ, start_response)
start_response.assert_called_once_with('200 OK', [])
self.assertEqual(result, [])