Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow healthcheck to work in host_matching mode #198

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 5.3.0

* Update the Healthcheck to support apps running in `host_matching` mode.

### 5.2.0

* Adding check internal user functionality and adding FAB and Form Designer to list of supported apps
Expand Down
4 changes: 2 additions & 2 deletions fsd_utils/healthchecks/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
class Healthcheck(object):
def __init__(self, app):
self.flask_app = app
self.flask_app.add_url_rule("/healthcheck", view_func=self.healthcheck_view)
self.flask_app.add_url_rule("/healthcheck", view_func=self.healthcheck_view, host="<host>")
self.checkers = []

def healthcheck_view(self):
def healthcheck_view(self, host=None):
responseCode = 200
response = {"checks": []}
version = os.getenv("GITHUB_SHA")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "funding-service-design-utils"

version = "5.2.0"
version = "5.3.0"

authors = [
{ name="MHCLG", email="FundingService@communities.gov.uk" },
Expand Down
10 changes: 5 additions & 5 deletions tests/test_healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class TestHealthcheck:
def testHealthChecksSetup(self):
test_app = Mock()
health = Healthcheck(test_app)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY, host="<host>")
assert health.checkers == [], "Checks not initialised"

@mock.patch.dict(os.environ, clear=True)
def testWithNoChecks(self):
mock_app = Mock()
health = Healthcheck(mock_app)
mock_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY)
mock_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY, host="<host>")

expected_dict = {"checks": []}

Expand All @@ -29,7 +29,7 @@ def testWithNoChecks(self):
def testWithChecksPassing_mocks(self, flask_test_client):
test_app = Mock()
health = Healthcheck(test_app)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY, host="<host>")

expected_dict = {"checks": [{"check_a": "ok"}, {"check_b": "ok"}]}

Expand All @@ -50,7 +50,7 @@ def testWithChecksPassing_mocks(self, flask_test_client):
def testWithChecksFailing_mocks(self, flask_test_client):
test_app = Mock()
health = Healthcheck(test_app)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY, host="<host>")

expected_dict = {"checks": [{"check_a": "fail"}, {"check_b": "ok"}]}

Expand All @@ -71,7 +71,7 @@ def testWithChecksFailing_mocks(self, flask_test_client):
def testWithChecksException_mocks(self, flask_test_client):
test_app = Mock()
health = Healthcheck(test_app)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY)
test_app.add_url_rule.assert_called_with("/healthcheck", view_func=ANY, host="<host>")

expected_dict = {"checks": [{"check_a": "fail"}, {"check_b": "Failed - check logs"}]}

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading