Hello community,
here is the log from the commit of package python-django-health-check for
openSUSE:Factory checked in at 2020-09-17 15:03:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-health-check (Old)
and /work/SRC/openSUSE:Factory/.python-django-health-check.new.4249 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-health-check"
Thu Sep 17 15:03:07 2020 rev:5 rq:835131 version:3.14.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-django-health-check/python-django-health-check.changes
2020-09-03 01:18:29.632566303 +0200
+++
/work/SRC/openSUSE:Factory/.python-django-health-check.new.4249/python-django-health-check.changes
2020-09-17 15:08:39.728927719 +0200
@@ -1,0 +2,10 @@
+Thu Sep 17 08:42:06 UTC 2020 - John Vandenberg <[email protected]>
+
+- Update to v3.14.0
+ * Register health check for each cache configuration
+- from v3.13.2
+ * Add backend checking if all migrations are applied
+- from v3.12.2
+ * Close all (even non default) db connections after check suite
+
+-------------------------------------------------------------------
Old:
----
django-health-check-3.12.1.tar.gz
New:
----
django-health-check-3.14.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-django-health-check.spec ++++++
--- /var/tmp/diff_new_pack.YMkB2E/_old 2020-09-17 15:08:40.396928354 +0200
+++ /var/tmp/diff_new_pack.YMkB2E/_new 2020-09-17 15:08:40.400928357 +0200
@@ -19,12 +19,12 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-django-health-check
-Version: 3.12.1
+Version: 3.14.0
Release: 0
-Summary: Run checks on services like databases, queue servers, celery
processes, etc
+Summary: Run checks on Django and is dependent services
License: MIT
URL: https://github.com/KristianOellegaard/django-health-check
-Source:
https://files.pythonhosted.org/packages/source/d/django-health-check/django-health-check-%{version}.tar.gz
+Source:
https://github.com/KristianOellegaard/django-health-check/archive/%{version}.tar.gz#/django-health-check-%{version}.tar.gz
BuildRequires: %{python_module Django >= 1.11}
BuildRequires: %{python_module celery}
BuildRequires: %{python_module mock}
@@ -43,10 +43,15 @@
This project checks for various conditions and provides reports when anomalous
behavior is detected.
+Services checked include databases, caches, queue servers, celery processes,
etc.
+
%prep
%setup -q -n django-health-check-%{version}
+# setuptools-scm fails for GitHub archives
+sed -i 's/use_scm_version=True/version="%{version}"/' setup.py
+
# do not nedlessly pull extra deps
-sed -i -e '/sphinx/d' -e '/pytest-runner/d' setup.cfg
+sed -i -e '/sphinx/d;/pytest-runner/d;/--cov[-=]/d' setup.cfg
%build
%python_build
@@ -56,7 +61,7 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-PYTHONPATH=.
+PYTHONPATH=${PWD}
export DJANGO_SETTINGS_MODULE=tests.testapp.settings
%pytest
++++++ django-health-check-3.12.1.tar.gz -> django-health-check-3.14.0.tar.gz
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/.editorconfig
new/django-health-check-3.14.0/.editorconfig
--- old/django-health-check-3.12.1/.editorconfig 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/.editorconfig 2020-09-16
08:01:23.000000000 +0200
@@ -16,7 +16,7 @@
multi_line_output = 5
line_length = 80
combine_as_imports = true
-skip = wsgi.py,docs,.tox,env,.eggs
+skip = wsgi.py,docs,env,.eggs
known_first_party = health_check,tests
known_third_party = django,celery,psutil
default_section=THIRDPARTY
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/.github/workflows/ci.yml
new/django-health-check-3.14.0/.github/workflows/ci.yml
--- old/django-health-check-3.12.1/.github/workflows/ci.yml 1970-01-01
01:00:00.000000000 +0100
+++ new/django-health-check-3.14.0/.github/workflows/ci.yml 2020-09-16
08:01:23.000000000 +0200
@@ -0,0 +1,48 @@
+name: CI
+on:
+ - push
+ - pull_request
+
+jobs:
+
+ dist:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/setup-python@v2
+ - run: python -m pip install --upgrade pip setuptools wheel twine
readme-renderer
+ - uses: actions/checkout@v2
+ - run: python setup.py sdist bdist_wheel
+ - run: python -m twine check dist/*
+
+ docs:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: setup Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.8
+ - name: check docs
+ run: python setup.py build_sphinx
+
+ pytest:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version:
+ - "3.6"
+ - "3.7"
+ - "3.8"
+ django-version:
+ - 2.2.*
+ - 3.1.*
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup Python version ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - run: python -m pip install --upgrade pip setuptools codecov
+ - run: pip install Django=="${{ matrix.django-version }}"
+ - run: python setup.py test
+ - run: codecov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/.github/workflows/release.yml
new/django-health-check-3.14.0/.github/workflows/release.yml
--- old/django-health-check-3.12.1/.github/workflows/release.yml
1970-01-01 01:00:00.000000000 +0100
+++ new/django-health-check-3.14.0/.github/workflows/release.yml
2020-09-16 08:01:23.000000000 +0200
@@ -0,0 +1,22 @@
+name: Release
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ PyPI:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-python@v2
+
+ - name: Install Python dependencies
+ run: python -m pip install --upgrade pip setuptools wheel twine
+ - name: Build dist packages
+ run: python setup.py sdist bdist_wheel
+ - name: Upload packages
+ run: python -m twine upload dist/*
+ env:
+ TWINE_USERNAME: __token__
+ TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/.travis.yml
new/django-health-check-3.14.0/.travis.yml
--- old/django-health-check-3.12.1/.travis.yml 2020-01-14 16:53:51.000000000
+0100
+++ new/django-health-check-3.14.0/.travis.yml 1970-01-01 01:00:00.000000000
+0100
@@ -1,48 +0,0 @@
-language: python
-cache: pip
-dist: xenial
-python:
-- '3.6'
-- '3.7'
-env:
- matrix:
- - TOXENV=docs
- - DJANGO=111
- - DJANGO=22
- - DJANGO=master
-services:
- - redis-server
-matrix:
- fast_finish: true
- allow_failures:
- - env: DJANGO=master
-install:
-- pip install --upgrade codecov tox
-before_script:
-- |
- if [[ -z $TOXENV ]]; then
- export TOXENV=py$(echo $TRAVIS_PYTHON_VERSION | sed -e 's/\.//g')-dj$DJANGO
- fi
-- echo $TOXENV
-script:
-- tox -e $TOXENV
-after_success:
-- codecov
-jobs:
- include:
- - stage: PyPI release # will run after the default "test" stage succeeds
- script: echo "Deploying to PyPI ..." # override regular test script;
"skip" should also work
- env:
- - TOXENV=qa # if not set explicitly, build matrix vars will use their
first value
- if: tag IS present
- deploy:
- python: 3.7
- provider: pypi
- distributions: sdist bdist_wheel
- user: codingjoe
- password:
- secure:
jJyadofJm7F1Qco+EDCyN/aMZaYSbfQ0GAE02Bx7I499MkjPYvv38X2btg+PjdW3rzGD0d/kq24lfWLkgKncyQ/YMgLQ7H/GuCCHHYbKUklxllaoFXActBjstmKOvXyWWC5oEb+YEJ4HTwgkvS6wkp69B7C1d4BAOqGs5IKnCSo=
- on:
- tags: true
- repo: KristianOellegaard/django-health-check
- branch: master
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/MANIFEST.in
new/django-health-check-3.14.0/MANIFEST.in
--- old/django-health-check-3.12.1/MANIFEST.in 2020-01-14 16:53:51.000000000
+0100
+++ new/django-health-check-3.14.0/MANIFEST.in 2020-09-16 08:01:23.000000000
+0200
@@ -1,3 +1,3 @@
include LICENSE
-recursive-include health_check
-prune tests docs
+prune tests
+prune docs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/PKG-INFO
new/django-health-check-3.14.0/PKG-INFO
--- old/django-health-check-3.12.1/PKG-INFO 2020-01-14 16:54:28.000000000
+0100
+++ new/django-health-check-3.14.0/PKG-INFO 1970-01-01 01:00:00.000000000
+0100
@@ -1,329 +0,0 @@
-Metadata-Version: 1.1
-Name: django-health-check
-Version: 3.12.1
-Summary: Run checks on services like databases, queue servers, celery
processes, etc.
-Home-page: https://github.com/KristianOellegaard/django-health-check
-Author: Kristian Ollegaard
-Author-email: [email protected]
-License: MIT License
-Description: ===================
- django-health-check
- ===================
-
- |version| |ci| |coverage| |health| |license|
-
- This project checks for various conditions and provides reports when
anomalous
- behavior is detected.
-
- The following health checks are bundled with this project:
-
- - cache
- - database
- - storage
- - disk and memory utilization (via ``psutil``)
- - AWS S3 storage
- - Celery task queue
- - RabbitMQ
-
- Writing your own custom health checks is also very quick and easy.
-
- We also like contributions, so don't be afraid to make a pull request.
-
- Use Cases
- ---------
-
- The primary intended use case is to monitor conditions via HTTP(S),
with
- responses available in HTML and JSON formats. When you get back a
response that
- includes one or more problems, you can then decide the appropriate
course of
- action, which could include generating notifications and/or automating
the
- replacement of a failing node with a new one. If you are monitoring
health in a
- high-availability environment with a load balancer that returns
responses from
- multiple nodes, please note that certain checks (e.g., disk and memory
usage)
- will return responses specific to the node selected by the load
balancer.
-
- Supported Versions
- ------------------
-
- We officially only support the latest version of Python as well as the
- latest version of Django and the latest Django LTS version.
-
- .. note:: The latest version to support Python 2 is 2.4.0
-
- Installation
- ------------
-
- First install the ``django-health-check`` package:
-
- .. code::
-
- pip install django-health-check
-
- Add the health checker to a URL you want to use:
-
- .. code:: python
-
- urlpatterns = [
- # ...
- url(r'^ht/', include('health_check.urls')),
- ]
-
- Add the ``health_check`` applications to your ``INSTALLED_APPS``:
-
- .. code:: python
-
- INSTALLED_APPS = [
- # ...
- 'health_check', # required
- 'health_check.db', # stock Django
health checkers
- 'health_check.cache',
- 'health_check.storage',
- 'health_check.contrib.celery', # requires celery
- 'health_check.contrib.psutil', # disk and memory
utilization; requires psutil
- 'health_check.contrib.s3boto_storage', # requires boto
and S3BotoStorage backend
- 'health_check.contrib.rabbitmq', # requires
RabbitMQ broker
- 'health_check.contrib.redis', # required Redis
broker
- ]
-
- (Optional) If using the ``psutil`` app, you can configure disk and
memory
- threshold settings; otherwise below defaults are assumed. If you want
to disable
- one of these checks, set its value to ``None``.
-
- .. code:: python
-
- HEALTH_CHECK = {
- 'DISK_USAGE_MAX': 90, # percent
- 'MEMORY_MIN': 100, # in MB
- }
-
- If using the DB check, run migrations:
-
- .. code::
-
- django-admin migrate
-
- To use the RabbitMQ healthcheck, please make sure that there is a
variable named ``BROKER_URL``
- on django.conf.settings with the required format to connect to your
rabbit server. For example:
-
- .. code::
-
- BROKER_URL = amqp://myuser:mypassword@localhost:5672/myvhost
-
- To use the Redis healthcheck, please make sure that there is a
variable named ``REDIS_URL``
- on django.conf.settings with the required format to connect to your
redis server. For example:
-
- .. code::
-
- REDIS_URL = redis://localhost:6370
-
- Setting up monitoring
- ---------------------
-
- You can use tools like Pingdom_ or other uptime robots to monitor
service status.
- The ``/ht/`` endpoint will respond a HTTP 200 if all checks passed
- and a HTTP 500 if any of the tests failed.
-
- .. code::
-
- $ curl -v -X GET -H http://www.example.com/ht/
-
- > GET /ht/ HTTP/1.1
- > Host: www.example.com
- > Accept: */*
- >
- < HTTP/1.1 200 OK
- < Content-Type: text/html; charset=utf-8
-
- <!-- This is an excerpt -->
- <div class="container">
- <h1>System status</h1>
- <table>
- <tr>
- <td class="status_1"></td>
- <td>CacheBackend</td>
- <td>working</td>
- </tr>
- <tr>
- <td class="status_1"></td>
- <td>DatabaseBackend</td>
- <td>working</td>
- </tr>
- <tr>
- <td class="status_1"></td>
- <td>S3BotoStorageHealthCheck</td>
- <td>working</td>
- </tr>
- </table>
- </div>
-
- Getting machine readable JSON reports
- -------------------------------------
-
- If you want machine readable status reports you can request the
``/ht/``
- endpoint with the ``Accept`` HTTP header set to ``application/json``
- or pass ``format=json`` as a query parameter.
-
- The backend will return a JSON response:
-
- .. code::
-
- $ curl -v -X GET -H "Accept: application/json"
http://www.example.com/ht/
-
- > GET /ht/ HTTP/1.1
- > Host: www.example.com
- > Accept: application/json
- >
- < HTTP/1.1 200 OK
- < Content-Type: application/json
-
- {
- "CacheBackend": "working",
- "DatabaseBackend": "working",
- "S3BotoStorageHealthCheck": "working"
- }
-
- $ curl -v -X GET http://www.example.com/ht/?format=json
-
- > GET /ht/?format=json HTTP/1.1
- > Host: www.example.com
- >
- < HTTP/1.1 200 OK
- < Content-Type: application/json
-
- {
- "CacheBackend": "working",
- "DatabaseBackend": "working",
- "S3BotoStorageHealthCheck": "working"
- }
-
- Writing a custom health check
- -----------------------------
-
- Writing a health check is quick and easy:
-
- .. code:: python
-
- from health_check.backends import BaseHealthCheckBackend
-
- class MyHealthCheckBackend(BaseHealthCheckBackend):
- #: The status endpoints will respond with a 200 status code
- #: even if the check errors.
- critical_service = False
-
- def check_status(self):
- # The test code goes here.
- # You can use `self.add_error` or
- # raise a `HealthCheckException`,
- # similar to Django's form validation.
- pass
-
- def identifier(self):
- return self.__class__.__name__ # Display name on the
endpoint.
-
- After writing a custom checker, register it in your app configuration:
-
- .. code:: python
-
- from django.apps import AppConfig
-
- from health_check.plugins import plugin_dir
-
- class MyAppConfig(AppConfig):
- name = 'my_app'
-
- def ready(self):
- from .backends import MyHealthCheckBackend
- plugin_dir.register(MyHealthCheckBackend)
-
- Make sure the application you write the checker into is registered in
your ``INSTALLED_APPS``.
-
- Customizing output
- ------------------
-
- You can customize HTML or JSON rendering by inheriting from
``MainView`` in ``health_check.views``
- and customizing the ``template_name``, ``get``, ``render_to_response``
and ``render_to_response_json`` properties:
-
- .. code:: python
-
- # views.py
- from health_check.views import MainView
-
- class HealthCheckCustomView(MainView):
- template_name = 'myapp/health_check_dashboard.html' #
customize the used templates
-
- def get(self, request, *args, **kwargs):
- plugins = []
- # ...
- if 'application/json' in request.META.get('HTTP_ACCEPT',
''):
- return self.render_to_response_json(plugins, status)
- return self.render_to_response(plugins, status)
-
- def render_to_response(self, plugins, status): #
customize HTML output
- return HttpResponse('COOL' if status == 200 else 'SWEATY',
status=status)
-
- def render_to_response_json(self, plugins, status): #
customize JSON output
- return JsonResponse(
- {str(p.identifier()): 'COOL' if status == 200 else
'SWEATY' for p in plugins}
- status=status
- )
-
- # urls.py
- import views
-
- urlpatterns = [
- # ...
- url(r'^ht/$', views.HealthCheckCustomView.as_view(),
name='health_check_custom'),
- ]
-
- Django command
- --------------
-
- You can run the Django command `health_check` to perform your health
checks via the command line,
- or periodically with a cron, as follow:
-
- .. code::
-
- django-admin health_check
-
- This should yield the following output:
-
- .. code::
-
- DatabaseHealthCheck ... working
- CustomHealthCheck ... unavailable: Something went wrong!
-
- Similar to the http version, a critical error will case the command to
quit with the exit code `1`.
-
-
- Other resources
- ---------------
-
- - django-watchman_ is a package that does some of the same things in a
slightly different way.
- - See this weblog_ about configuring Django and health checking with
AWS Elastic Load Balancer.
-
- .. |version| image::
https://img.shields.io/pypi/v/django-health-check.svg
- :target: https://pypi.python.org/pypi/django-health-check/
- .. |ci| image::
https://api.travis-ci.org/KristianOellegaard/django-health-check.svg?branch=master
- :target:
https://travis-ci.org/KristianOellegaard/django-health-check
- .. |coverage| image::
https://codecov.io/gh/KristianOellegaard/django-health-check/branch/master/graph/badge.svg
- :target:
https://codecov.io/gh/KristianOellegaard/django-health-check
- .. |health| image::
https://landscape.io/github/KristianOellegaard/django-health-check/master/landscape.svg?style=flat
- :target:
https://landscape.io/github/KristianOellegaard/django-health-check/master
- .. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg
- :target: LICENSE
-
- .. _Pingdom: https://www.pingdom.com/
- .. _django-watchman: https://github.com/mwarkentin/django-watchman
- .. _weblog:
https://www.vincit.fi/en/blog/deploying-django-to-elastic-beanstalk-with-https-redirects-and-functional-health-checks/
-
-Keywords: django,postgresql
-Platform: UNKNOWN
-Classifier: Development Status :: 5 - Production/Stable
-Classifier: Framework :: Django
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python :: 3
-Classifier: Topic :: Software Development :: Quality Assurance
-Classifier: Topic :: System :: Logging
-Classifier: Topic :: System :: Monitoring
-Classifier: Topic :: Utilities
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/README.rst
new/django-health-check-3.14.0/README.rst
--- old/django-health-check-3.12.1/README.rst 2020-01-14 16:53:51.000000000
+0100
+++ new/django-health-check-3.14.0/README.rst 2020-09-16 08:01:23.000000000
+0200
@@ -2,7 +2,7 @@
django-health-check
===================
-|version| |ci| |coverage| |health| |license|
+|version| |coverage| |health| |license|
This project checks for various conditions and provides reports when anomalous
behavior is detected.
@@ -16,6 +16,7 @@
- AWS S3 storage
- Celery task queue
- RabbitMQ
+- Migrations
Writing your own custom health checks is also very quick and easy.
@@ -39,8 +40,6 @@
We officially only support the latest version of Python as well as the
latest version of Django and the latest Django LTS version.
-.. note:: The latest version to support Python 2 is 2.4.0
-
Installation
------------
@@ -69,13 +68,16 @@
'health_check.db', # stock Django health
checkers
'health_check.cache',
'health_check.storage',
+ 'health_check.contrib.migrations',
'health_check.contrib.celery', # requires celery
'health_check.contrib.psutil', # disk and memory
utilization; requires psutil
- 'health_check.contrib.s3boto_storage', # requires boto and
S3BotoStorage backend
+ 'health_check.contrib.s3boto3_storage', # requires boto3 and
S3BotoStorage backend
'health_check.contrib.rabbitmq', # requires RabbitMQ broker
'health_check.contrib.redis', # required Redis broker
]
+Note : If using ``boto 2.x.x`` use ``health_check.contrib.s3boto_storage``
+
(Optional) If using the ``psutil`` app, you can configure disk and memory
threshold settings; otherwise below defaults are assumed. If you want to
disable
one of these checks, set its value to ``None``.
@@ -244,6 +246,7 @@
def get(self, request, *args, **kwargs):
plugins = []
+ status = 200 # needs to be filled status you need
# ...
if 'application/json' in request.META.get('HTTP_ACCEPT', ''):
return self.render_to_response_json(plugins, status)
@@ -254,7 +257,7 @@
def render_to_response_json(self, plugins, status): # customize JSON
output
return JsonResponse(
- {str(p.identifier()): 'COOL' if status == 200 else 'SWEATY'
for p in plugins}
+ {str(p.identifier()): 'COOL' if status == 200 else 'SWEATY'
for p in plugins},
status=status
)
@@ -283,7 +286,7 @@
DatabaseHealthCheck ... working
CustomHealthCheck ... unavailable: Something went wrong!
-Similar to the http version, a critical error will case the command to quit
with the exit code `1`.
+Similar to the http version, a critical error will cause the command to quit
with the exit code `1`.
Other resources
@@ -294,8 +297,6 @@
.. |version| image:: https://img.shields.io/pypi/v/django-health-check.svg
:target: https://pypi.python.org/pypi/django-health-check/
-.. |ci| image::
https://api.travis-ci.org/KristianOellegaard/django-health-check.svg?branch=master
- :target: https://travis-ci.org/KristianOellegaard/django-health-check
.. |coverage| image::
https://codecov.io/gh/KristianOellegaard/django-health-check/branch/master/graph/badge.svg
:target: https://codecov.io/gh/KristianOellegaard/django-health-check
.. |health| image::
https://landscape.io/github/KristianOellegaard/django-health-check/master/landscape.svg?style=flat
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/django_health_check.egg-info/PKG-INFO
new/django-health-check-3.14.0/django_health_check.egg-info/PKG-INFO
--- old/django-health-check-3.12.1/django_health_check.egg-info/PKG-INFO
2020-01-14 16:54:28.000000000 +0100
+++ new/django-health-check-3.14.0/django_health_check.egg-info/PKG-INFO
1970-01-01 01:00:00.000000000 +0100
@@ -1,329 +0,0 @@
-Metadata-Version: 1.1
-Name: django-health-check
-Version: 3.12.1
-Summary: Run checks on services like databases, queue servers, celery
processes, etc.
-Home-page: https://github.com/KristianOellegaard/django-health-check
-Author: Kristian Ollegaard
-Author-email: [email protected]
-License: MIT License
-Description: ===================
- django-health-check
- ===================
-
- |version| |ci| |coverage| |health| |license|
-
- This project checks for various conditions and provides reports when
anomalous
- behavior is detected.
-
- The following health checks are bundled with this project:
-
- - cache
- - database
- - storage
- - disk and memory utilization (via ``psutil``)
- - AWS S3 storage
- - Celery task queue
- - RabbitMQ
-
- Writing your own custom health checks is also very quick and easy.
-
- We also like contributions, so don't be afraid to make a pull request.
-
- Use Cases
- ---------
-
- The primary intended use case is to monitor conditions via HTTP(S),
with
- responses available in HTML and JSON formats. When you get back a
response that
- includes one or more problems, you can then decide the appropriate
course of
- action, which could include generating notifications and/or automating
the
- replacement of a failing node with a new one. If you are monitoring
health in a
- high-availability environment with a load balancer that returns
responses from
- multiple nodes, please note that certain checks (e.g., disk and memory
usage)
- will return responses specific to the node selected by the load
balancer.
-
- Supported Versions
- ------------------
-
- We officially only support the latest version of Python as well as the
- latest version of Django and the latest Django LTS version.
-
- .. note:: The latest version to support Python 2 is 2.4.0
-
- Installation
- ------------
-
- First install the ``django-health-check`` package:
-
- .. code::
-
- pip install django-health-check
-
- Add the health checker to a URL you want to use:
-
- .. code:: python
-
- urlpatterns = [
- # ...
- url(r'^ht/', include('health_check.urls')),
- ]
-
- Add the ``health_check`` applications to your ``INSTALLED_APPS``:
-
- .. code:: python
-
- INSTALLED_APPS = [
- # ...
- 'health_check', # required
- 'health_check.db', # stock Django
health checkers
- 'health_check.cache',
- 'health_check.storage',
- 'health_check.contrib.celery', # requires celery
- 'health_check.contrib.psutil', # disk and memory
utilization; requires psutil
- 'health_check.contrib.s3boto_storage', # requires boto
and S3BotoStorage backend
- 'health_check.contrib.rabbitmq', # requires
RabbitMQ broker
- 'health_check.contrib.redis', # required Redis
broker
- ]
-
- (Optional) If using the ``psutil`` app, you can configure disk and
memory
- threshold settings; otherwise below defaults are assumed. If you want
to disable
- one of these checks, set its value to ``None``.
-
- .. code:: python
-
- HEALTH_CHECK = {
- 'DISK_USAGE_MAX': 90, # percent
- 'MEMORY_MIN': 100, # in MB
- }
-
- If using the DB check, run migrations:
-
- .. code::
-
- django-admin migrate
-
- To use the RabbitMQ healthcheck, please make sure that there is a
variable named ``BROKER_URL``
- on django.conf.settings with the required format to connect to your
rabbit server. For example:
-
- .. code::
-
- BROKER_URL = amqp://myuser:mypassword@localhost:5672/myvhost
-
- To use the Redis healthcheck, please make sure that there is a
variable named ``REDIS_URL``
- on django.conf.settings with the required format to connect to your
redis server. For example:
-
- .. code::
-
- REDIS_URL = redis://localhost:6370
-
- Setting up monitoring
- ---------------------
-
- You can use tools like Pingdom_ or other uptime robots to monitor
service status.
- The ``/ht/`` endpoint will respond a HTTP 200 if all checks passed
- and a HTTP 500 if any of the tests failed.
-
- .. code::
-
- $ curl -v -X GET -H http://www.example.com/ht/
-
- > GET /ht/ HTTP/1.1
- > Host: www.example.com
- > Accept: */*
- >
- < HTTP/1.1 200 OK
- < Content-Type: text/html; charset=utf-8
-
- <!-- This is an excerpt -->
- <div class="container">
- <h1>System status</h1>
- <table>
- <tr>
- <td class="status_1"></td>
- <td>CacheBackend</td>
- <td>working</td>
- </tr>
- <tr>
- <td class="status_1"></td>
- <td>DatabaseBackend</td>
- <td>working</td>
- </tr>
- <tr>
- <td class="status_1"></td>
- <td>S3BotoStorageHealthCheck</td>
- <td>working</td>
- </tr>
- </table>
- </div>
-
- Getting machine readable JSON reports
- -------------------------------------
-
- If you want machine readable status reports you can request the
``/ht/``
- endpoint with the ``Accept`` HTTP header set to ``application/json``
- or pass ``format=json`` as a query parameter.
-
- The backend will return a JSON response:
-
- .. code::
-
- $ curl -v -X GET -H "Accept: application/json"
http://www.example.com/ht/
-
- > GET /ht/ HTTP/1.1
- > Host: www.example.com
- > Accept: application/json
- >
- < HTTP/1.1 200 OK
- < Content-Type: application/json
-
- {
- "CacheBackend": "working",
- "DatabaseBackend": "working",
- "S3BotoStorageHealthCheck": "working"
- }
-
- $ curl -v -X GET http://www.example.com/ht/?format=json
-
- > GET /ht/?format=json HTTP/1.1
- > Host: www.example.com
- >
- < HTTP/1.1 200 OK
- < Content-Type: application/json
-
- {
- "CacheBackend": "working",
- "DatabaseBackend": "working",
- "S3BotoStorageHealthCheck": "working"
- }
-
- Writing a custom health check
- -----------------------------
-
- Writing a health check is quick and easy:
-
- .. code:: python
-
- from health_check.backends import BaseHealthCheckBackend
-
- class MyHealthCheckBackend(BaseHealthCheckBackend):
- #: The status endpoints will respond with a 200 status code
- #: even if the check errors.
- critical_service = False
-
- def check_status(self):
- # The test code goes here.
- # You can use `self.add_error` or
- # raise a `HealthCheckException`,
- # similar to Django's form validation.
- pass
-
- def identifier(self):
- return self.__class__.__name__ # Display name on the
endpoint.
-
- After writing a custom checker, register it in your app configuration:
-
- .. code:: python
-
- from django.apps import AppConfig
-
- from health_check.plugins import plugin_dir
-
- class MyAppConfig(AppConfig):
- name = 'my_app'
-
- def ready(self):
- from .backends import MyHealthCheckBackend
- plugin_dir.register(MyHealthCheckBackend)
-
- Make sure the application you write the checker into is registered in
your ``INSTALLED_APPS``.
-
- Customizing output
- ------------------
-
- You can customize HTML or JSON rendering by inheriting from
``MainView`` in ``health_check.views``
- and customizing the ``template_name``, ``get``, ``render_to_response``
and ``render_to_response_json`` properties:
-
- .. code:: python
-
- # views.py
- from health_check.views import MainView
-
- class HealthCheckCustomView(MainView):
- template_name = 'myapp/health_check_dashboard.html' #
customize the used templates
-
- def get(self, request, *args, **kwargs):
- plugins = []
- # ...
- if 'application/json' in request.META.get('HTTP_ACCEPT',
''):
- return self.render_to_response_json(plugins, status)
- return self.render_to_response(plugins, status)
-
- def render_to_response(self, plugins, status): #
customize HTML output
- return HttpResponse('COOL' if status == 200 else 'SWEATY',
status=status)
-
- def render_to_response_json(self, plugins, status): #
customize JSON output
- return JsonResponse(
- {str(p.identifier()): 'COOL' if status == 200 else
'SWEATY' for p in plugins}
- status=status
- )
-
- # urls.py
- import views
-
- urlpatterns = [
- # ...
- url(r'^ht/$', views.HealthCheckCustomView.as_view(),
name='health_check_custom'),
- ]
-
- Django command
- --------------
-
- You can run the Django command `health_check` to perform your health
checks via the command line,
- or periodically with a cron, as follow:
-
- .. code::
-
- django-admin health_check
-
- This should yield the following output:
-
- .. code::
-
- DatabaseHealthCheck ... working
- CustomHealthCheck ... unavailable: Something went wrong!
-
- Similar to the http version, a critical error will case the command to
quit with the exit code `1`.
-
-
- Other resources
- ---------------
-
- - django-watchman_ is a package that does some of the same things in a
slightly different way.
- - See this weblog_ about configuring Django and health checking with
AWS Elastic Load Balancer.
-
- .. |version| image::
https://img.shields.io/pypi/v/django-health-check.svg
- :target: https://pypi.python.org/pypi/django-health-check/
- .. |ci| image::
https://api.travis-ci.org/KristianOellegaard/django-health-check.svg?branch=master
- :target:
https://travis-ci.org/KristianOellegaard/django-health-check
- .. |coverage| image::
https://codecov.io/gh/KristianOellegaard/django-health-check/branch/master/graph/badge.svg
- :target:
https://codecov.io/gh/KristianOellegaard/django-health-check
- .. |health| image::
https://landscape.io/github/KristianOellegaard/django-health-check/master/landscape.svg?style=flat
- :target:
https://landscape.io/github/KristianOellegaard/django-health-check/master
- .. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg
- :target: LICENSE
-
- .. _Pingdom: https://www.pingdom.com/
- .. _django-watchman: https://github.com/mwarkentin/django-watchman
- .. _weblog:
https://www.vincit.fi/en/blog/deploying-django-to-elastic-beanstalk-with-https-redirects-and-functional-health-checks/
-
-Keywords: django,postgresql
-Platform: UNKNOWN
-Classifier: Development Status :: 5 - Production/Stable
-Classifier: Framework :: Django
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python :: 3
-Classifier: Topic :: Software Development :: Quality Assurance
-Classifier: Topic :: System :: Logging
-Classifier: Topic :: System :: Monitoring
-Classifier: Topic :: Utilities
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/django_health_check.egg-info/SOURCES.txt
new/django-health-check-3.14.0/django_health_check.egg-info/SOURCES.txt
--- old/django-health-check-3.12.1/django_health_check.egg-info/SOURCES.txt
2020-01-14 16:54:28.000000000 +0100
+++ new/django-health-check-3.14.0/django_health_check.egg-info/SOURCES.txt
1970-01-01 01:00:00.000000000 +0100
@@ -1,83 +0,0 @@
-.bandit
-.checks.yml
-.editorconfig
-.gitignore
-.travis.yml
-LICENSE
-MANIFEST.in
-README.rst
-requirements-dev.txt
-setup.cfg
-setup.py
-django_health_check.egg-info/PKG-INFO
-django_health_check.egg-info/SOURCES.txt
-django_health_check.egg-info/dependency_links.txt
-django_health_check.egg-info/requires.txt
-django_health_check.egg-info/top_level.txt
-docs/changelog.rst
-docs/conf.py
-docs/contrib.rst
-docs/index.rst
-docs/readme.rst
-docs/settings.rst
-health_check/__init__.py
-health_check/backends.py
-health_check/conf.py
-health_check/exceptions.py
-health_check/mixins.py
-health_check/plugins.py
-health_check/urls.py
-health_check/views.py
-health_check/cache/__init__.py
-health_check/cache/apps.py
-health_check/cache/backends.py
-health_check/contrib/__init__.py
-health_check/contrib/celery/__init__.py
-health_check/contrib/celery/apps.py
-health_check/contrib/celery/backends.py
-health_check/contrib/celery/tasks.py
-health_check/contrib/psutil/__init__.py
-health_check/contrib/psutil/apps.py
-health_check/contrib/psutil/backends.py
-health_check/contrib/rabbitmq/__init__.py
-health_check/contrib/rabbitmq/apps.py
-health_check/contrib/rabbitmq/backends.py
-health_check/contrib/redis/__init__.py
-health_check/contrib/redis/apps.py
-health_check/contrib/redis/backends.py
-health_check/contrib/s3boto3_storage/__init__.py
-health_check/contrib/s3boto3_storage/apps.py
-health_check/contrib/s3boto3_storage/backends.py
-health_check/contrib/s3boto_storage/__init__.py
-health_check/contrib/s3boto_storage/apps.py
-health_check/contrib/s3boto_storage/backends.py
-health_check/db/__init__.py
-health_check/db/apps.py
-health_check/db/backends.py
-health_check/db/models.py
-health_check/db/migrations/0001_initial.py
-health_check/db/migrations/__init__.py
-health_check/management/__init__.py
-health_check/management/commands/__init__.py
-health_check/management/commands/health_check.py
-health_check/storage/__init__.py
-health_check/storage/apps.py
-health_check/storage/backends.py
-health_check/templates/health_check/index.html
-tests/__init__.py
-tests/test_autodiscover.py
-tests/test_backends.py
-tests/test_cache.py
-tests/test_commands.py
-tests/test_db.py
-tests/test_mixins.py
-tests/test_plugins.py
-tests/test_rabbitmq.py
-tests/test_redis.py
-tests/test_storage.py
-tests/test_views.py
-tests/testapp/__init__.py
-tests/testapp/celery.py
-tests/testapp/manage.py
-tests/testapp/settings.py
-tests/testapp/urls.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/django_health_check.egg-info/dependency_links.txt
new/django-health-check-3.14.0/django_health_check.egg-info/dependency_links.txt
---
old/django-health-check-3.12.1/django_health_check.egg-info/dependency_links.txt
2020-01-14 16:54:28.000000000 +0100
+++
new/django-health-check-3.14.0/django_health_check.egg-info/dependency_links.txt
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/django_health_check.egg-info/requires.txt
new/django-health-check-3.14.0/django_health_check.egg-info/requires.txt
--- old/django-health-check-3.12.1/django_health_check.egg-info/requires.txt
2020-01-14 16:54:28.000000000 +0100
+++ new/django-health-check-3.14.0/django_health_check.egg-info/requires.txt
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-django>=1.11
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/django_health_check.egg-info/top_level.txt
new/django-health-check-3.14.0/django_health_check.egg-info/top_level.txt
--- old/django-health-check-3.12.1/django_health_check.egg-info/top_level.txt
2020-01-14 16:54:28.000000000 +0100
+++ new/django-health-check-3.14.0/django_health_check.egg-info/top_level.txt
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-health_check
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/cache/apps.py
new/django-health-check-3.14.0/health_check/cache/apps.py
--- old/django-health-check-3.12.1/health_check/cache/apps.py 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/cache/apps.py 2020-09-16
08:01:23.000000000 +0200
@@ -1,4 +1,5 @@
from django.apps import AppConfig
+from django.conf import settings
from health_check.plugins import plugin_dir
@@ -8,4 +9,6 @@
def ready(self):
from .backends import CacheBackend
- plugin_dir.register(CacheBackend)
+
+ for backend in settings.CACHES:
+ plugin_dir.register(CacheBackend, backend=backend)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/cache/backends.py
new/django-health-check-3.14.0/health_check/cache/backends.py
--- old/django-health-check-3.12.1/health_check/cache/backends.py
2020-01-14 16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/cache/backends.py
2020-09-16 08:01:23.000000000 +0200
@@ -1,4 +1,4 @@
-from django.core.cache import CacheKeyWarning, cache
+from django.core.cache import CacheKeyWarning, caches
from health_check.backends import BaseHealthCheckBackend
from health_check.exceptions import (
@@ -7,7 +7,16 @@
class CacheBackend(BaseHealthCheckBackend):
+ def __init__(self, backend='default'):
+ super().__init__()
+ self.backend = backend
+
+ def identifier(self):
+ return f"Cache backend: {self.backend}"
+
def check_status(self):
+ cache = caches[self.backend]
+
try:
cache.set('djangohealtcheck_test', 'itworks', 1)
if not cache.get("djangohealtcheck_test") == "itworks":
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/contrib/celery/backends.py
new/django-health-check-3.14.0/health_check/contrib/celery/backends.py
--- old/django-health-check-3.12.1/health_check/contrib/celery/backends.py
2020-01-14 16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/contrib/celery/backends.py
2020-09-16 08:01:23.000000000 +0200
@@ -21,6 +21,7 @@
result.get(timeout=timeout)
if result.result != 8:
self.add_error(ServiceReturnedUnexpectedResult("Celery
returned wrong result"))
+ add.forget()
except IOError as e:
self.add_error(ServiceUnavailable("IOError"), e)
except NotImplementedError as e:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/contrib/migrations/__init__.py
new/django-health-check-3.14.0/health_check/contrib/migrations/__init__.py
--- old/django-health-check-3.12.1/health_check/contrib/migrations/__init__.py
1970-01-01 01:00:00.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/contrib/migrations/__init__.py
2020-09-16 08:01:23.000000000 +0200
@@ -0,0 +1 @@
+default_app_config = 'health_check.contrib.migrations.apps.HealthCheckConfig'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/contrib/migrations/apps.py
new/django-health-check-3.14.0/health_check/contrib/migrations/apps.py
--- old/django-health-check-3.12.1/health_check/contrib/migrations/apps.py
1970-01-01 01:00:00.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/contrib/migrations/apps.py
2020-09-16 08:01:23.000000000 +0200
@@ -0,0 +1,12 @@
+from django.apps import AppConfig
+
+from health_check.plugins import plugin_dir
+
+
+class HealthCheckConfig(AppConfig):
+ name = "health_check.contrib.migrations"
+
+ def ready(self):
+ from .backends import MigrationsHealthCheck
+
+ plugin_dir.register(MigrationsHealthCheck)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/contrib/migrations/backends.py
new/django-health-check-3.14.0/health_check/contrib/migrations/backends.py
--- old/django-health-check-3.12.1/health_check/contrib/migrations/backends.py
1970-01-01 01:00:00.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/contrib/migrations/backends.py
2020-09-16 08:01:23.000000000 +0200
@@ -0,0 +1,28 @@
+import logging
+
+from django.conf import settings
+from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections
+from django.db.migrations.executor import MigrationExecutor
+
+from health_check.backends import BaseHealthCheckBackend
+from health_check.exceptions import ServiceUnavailable
+
+logger = logging.getLogger(__name__)
+
+
+class MigrationsHealthCheck(BaseHealthCheckBackend):
+
+ def get_migration_plan(self, executor):
+ return executor.migration_plan(executor.loader.graph.leaf_nodes())
+
+ def check_status(self):
+ db_alias = getattr(settings, 'HEALTHCHECK_MIGRATIONS_DB',
DEFAULT_DB_ALIAS)
+ try:
+ executor = MigrationExecutor(connections[db_alias])
+ plan = self.get_migration_plan(executor)
+ if plan:
+ self.add_error(ServiceUnavailable("There are migrations to
apply"))
+ except DatabaseError as e:
+ self.add_error(ServiceUnavailable("Database is not ready"), e)
+ except Exception as e:
+ self.add_error(ServiceUnavailable("Unexpected error"), e)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/contrib/psutil/apps.py
new/django-health-check-3.14.0/health_check/contrib/psutil/apps.py
--- old/django-health-check-3.12.1/health_check/contrib/psutil/apps.py
2020-01-14 16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/contrib/psutil/apps.py
2020-09-16 08:01:23.000000000 +0200
@@ -9,6 +9,7 @@
def ready(self):
from .backends import DiskUsage, MemoryUsage
+
# Ensure checks haven't been explicitly disabled before registering
if (hasattr(settings, 'HEALTH_CHECK') and
('DISK_USAGE_MAX' in settings.HEALTH_CHECK) and
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/health_check/mixins.py
new/django-health-check-3.14.0/health_check/mixins.py
--- old/django-health-check-3.12.1/health_check/mixins.py 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/mixins.py 2020-09-16
08:01:23.000000000 +0200
@@ -1,5 +1,4 @@
import copy
-
from concurrent.futures import ThreadPoolExecutor
from health_check.conf import HEALTH_CHECK
@@ -34,8 +33,8 @@
try:
return plugin
finally:
- from django.db import connection
- connection.close()
+ from django.db import connections
+ connections.close_all()
with ThreadPoolExecutor(max_workers=len(self.plugins) or 1) as
executor:
for plugin in executor.map(_run, self.plugins):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-health-check-3.12.1/health_check/templates/health_check/index.html
new/django-health-check-3.14.0/health_check/templates/health_check/index.html
---
old/django-health-check-3.12.1/health_check/templates/health_check/index.html
2020-01-14 16:53:51.000000000 +0100
+++
new/django-health-check-3.14.0/health_check/templates/health_check/index.html
2020-09-16 08:01:23.000000000 +0200
@@ -1,32 +1,35 @@
<html>
<head>
- <title>System status</title>
+ <title>{% block title %}System status{% endblock title %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
+ {% block extra_head %}{% endblock extra_head %}
</head>
<body class="w3-content">
-<h1 class="w3-center">System status</h1>
-<table class="w3-table w3-striped w3-white">
- <tr class="w3-blue">
- <th colspan="2">Service</th>
- <th>Status</th>
- <th class="w3-hide-small w3-hide-medium w3-right">Time Taken</th>
- </tr>
- {% for plugin in plugins %}
- <tr>
- <td class="w3-center" style="width: 50px">
- {% if plugin.status %}
- <i class="w3-text-green fa fa-check" aria-hidden="true"></i>
- {% else %}
- <i class="w3-text-red fa fa-close" aria-hidden="true"></i>
- {% endif %}
- </td>
- <td>{{ plugin.identifier }}</td>
- <td>{{ plugin.pretty_status }}</td>
- <td class="w3-hide-small w3-hide-medium w3-right">{{
plugin.time_taken|floatformat:4 }} seconds</td>
- </tr>
- {% endfor %}
-</table>
+ {% block content %}
+ <h1 class="w3-center">System status</h1>
+ <table class="w3-table w3-striped w3-white">
+ <tr class="w3-blue">
+ <th colspan="2">Service</th>
+ <th>Status</th>
+ <th class="w3-hide-small w3-hide-medium w3-right">Time Taken</th>
+ </tr>
+ {% for plugin in plugins %}
+ <tr>
+ <td class="w3-center" style="width: 50px">
+ {% if plugin.status %}
+ <i class="w3-text-green fa fa-check" aria-hidden="true"></i>
+ {% else %}
+ <i class="w3-text-red fa fa-close" aria-hidden="true"></i>
+ {% endif %}
+ </td>
+ <td>{{ plugin.identifier }}</td>
+ <td>{{ plugin.pretty_status }}</td>
+ <td class="w3-hide-small w3-hide-medium w3-right">{{
plugin.time_taken|floatformat:4 }} seconds</td>
+ </tr>
+ {% endfor %}
+ </table>
+ {% endblock content %}
</body>
</html>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/health_check/views.py
new/django-health-check-3.14.0/health_check/views.py
--- old/django-health-check-3.12.1/health_check/views.py 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/health_check/views.py 2020-09-16
08:01:23.000000000 +0200
@@ -92,16 +92,19 @@
accept_header = request.META.get('HTTP_ACCEPT', '*/*')
for media in MediaType.parse_header(accept_header):
if media.mime_type in ('text/html', 'application/xhtml+xml',
'text/*', '*/*'):
- context = {'plugins': self.plugins, 'status_code': status_code}
+ context = self.get_context_data(**kwargs)
return self.render_to_response(context, status=status_code)
elif media.mime_type in ('application/json', 'application/*'):
return self.render_to_response_json(self.plugins, status_code)
return HttpResponse(
'Not Acceptable: Supported content types: text/html,
application/json',
status=406,
- content_type='text/plain'
+ content_type='text/plain',
)
+ def get_context_data(self, **kwargs):
+ return {**super().get_context_data(**kwargs), "plugins": self.plugins}
+
def render_to_response_json(self, plugins, status):
return JsonResponse(
{str(p.identifier()): str(p.pretty_status()) for p in plugins},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/setup.cfg
new/django-health-check-3.14.0/setup.cfg
--- old/django-health-check-3.12.1/setup.cfg 2020-01-14 16:54:28.000000000
+0100
+++ new/django-health-check-3.14.0/setup.cfg 2020-09-16 08:01:23.000000000
+0200
@@ -7,101 +7,85 @@
url = https://github.com/KristianOellegaard/django-health-check
license = MIT License
license_file = LICENSE
-classifier =
- Development Status :: 5 - Production/Stable
- Framework :: Django
- Intended Audience :: Developers
- License :: OSI Approved :: MIT License
- Operating System :: OS Independent
- Programming Language :: Python :: 3
- Topic :: Software Development :: Quality Assurance
- Topic :: System :: Logging
- Topic :: System :: Monitoring
- Topic :: Utilities
-keywords =
- django
- postgresql
+classifier =
+ Development Status :: 5 - Production/Stable
+ Framework :: Django
+ Intended Audience :: Developers
+ License :: OSI Approved :: MIT License
+ Operating System :: OS Independent
+ Programming Language :: Python :: 3
+ Topic :: Software Development :: Quality Assurance
+ Topic :: System :: Logging
+ Topic :: System :: Monitoring
+ Topic :: Utilities
+keywords =
+ django
+ postgresql
[options]
include_package_data = True
packages = health_check
-install_requires =
- django>=1.11
-setup_requires =
- setuptools_scm
- sphinx
- pytest-runner
-tests_require =
- mock
- pytest
- pytest-cov
- pytest-django
- celery
- redis
+install_requires =
+ django>=1.11
+setup_requires =
+ setuptools_scm
+ sphinx
+ pytest-runner
+tests_require =
+ mock
+ pytest
+ pytest-cov
+ pytest-django
+ celery
+ redis
[bdist_wheel]
universal = 1
[bdist_rpm]
-requires =
- python-django-appconf >= 2.0
- python-django-appconf >= 0.6
+requires =
+ python-django-appconf >= 2.0
+ python-django-appconf >= 0.6
[aliases]
test = pytest
[tool:pytest]
-norecursedirs = venv env .eggs
-django_settings_module = tests.testapp.settings
-addopts = --tb=short -rxs
+norecursedirs=venv env .eggs
+DJANGO_SETTINGS_MODULE=tests.testapp.settings
+addopts =
+ --tb=short
+ -rxs
+ --cov=health_check
+ --cov-report=term
+ --cov-report=xml
[flake8]
max-line-length = 119
max-complexity = 10
statistics = true
show-source = true
-exclude = */migrations/*,docs/*,env/*,.tox/*,.eggs/*
+exclude = */migrations/*,docs/*,env/*,.eggs/*
[pydocstyle]
add-ignore = D1
match-dir = (?!tests|env|.eggs|\.).*
[coverage:run]
-source = .
-omit =
- */migrations/*
- */tests/*
- */test_*.py
- .tox
- .eggs
+branch = True
+omit =
+ */migrations/*
+ */tests/*
+ */test_*.py
+ .eggs/*
[coverage:report]
ignore_errors = True
show_missing = True
+skip_covered = True
+sort = Cover
[build_sphinx]
source_dir = docs
build_dir = docs/_build
warning-is-error = 1
-
-[tox:tox]
-envlist = py{36,37}-dj{111,20,master},qa
-
-[testenv]
-setenv =
- PYTHONPATH = {toxinidir}:$PYTHONPATH
-deps =
- dj111:
https://github.com/django/django/archive/stable/1.11.x.tar.gz#egg=django
- dj22:
https://github.com/django/django/archive/stable/2.2.x.tar.gz#egg=django
- djmaster:
https://github.com/django/django/archive/master.tar.gz#egg=django
-commands =
- python setup.py test
-
-[testenv:docs]
-commands =
- python setup.py build_sphinx
-
-[egg_info]
-tag_build =
-tag_date = 0
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/tests/test_cache.py
new/django-health-check-3.14.0/tests/test_cache.py
--- old/django-health-check-3.12.1/tests/test_cache.py 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/tests/test_cache.py 2020-09-16
08:01:23.000000000 +0200
@@ -45,14 +45,28 @@
Ensures check_status returns/raises the expected result when the cache
works, fails, or raises exceptions.
"""
- @patch("health_check.cache.backends.cache", MockCache())
+ @patch("health_check.cache.backends.caches", dict(default=MockCache()))
def test_check_status_working(self):
cache_backend = CacheBackend()
cache_backend.run_check()
self.assertFalse(cache_backend.errors)
+ @patch("health_check.cache.backends.caches", dict(default=MockCache(),
broken=MockCache(set_works=False)))
+ def test_multiple_backends_check_default(self):
+ # default backend works while other is broken
+ cache_backend = CacheBackend('default')
+ cache_backend.run_check()
+ self.assertFalse(cache_backend.errors)
+
+ @patch("health_check.cache.backends.caches", dict(default=MockCache(),
broken=MockCache(set_works=False)))
+ def test_multiple_backends_check_broken(self):
+ cache_backend = CacheBackend('broken')
+ cache_backend.run_check()
+ self.assertTrue(cache_backend.errors)
+ self.assertIn('unavailable: Cache key does not match',
cache_backend.pretty_status())
+
# check_status should raise ServiceUnavailable when values at cache key do
not match
- @patch("health_check.cache.backends.cache", MockCache(set_works=False))
+ @patch("health_check.cache.backends.caches",
dict(default=MockCache(set_works=False)))
def test_set_fails(self):
cache_backend = CacheBackend()
cache_backend.run_check()
@@ -60,14 +74,14 @@
self.assertIn('unavailable: Cache key does not match',
cache_backend.pretty_status())
# check_status should catch generic exceptions raised by set and convert
to ServiceUnavailable
- @patch("health_check.cache.backends.cache",
MockCache(set_raises=Exception))
+ @patch("health_check.cache.backends.caches",
dict(default=MockCache(set_raises=Exception)))
def test_set_raises_generic(self):
cache_backend = CacheBackend()
with self.assertRaises(Exception):
cache_backend.run_check()
# check_status should catch CacheKeyWarning and convert to
ServiceReturnedUnexpectedResult
- @patch("health_check.cache.backends.cache",
MockCache(set_raises=CacheKeyWarning))
+ @patch("health_check.cache.backends.caches",
dict(default=MockCache(set_raises=CacheKeyWarning)))
def test_set_raises_cache_key_warning(self):
cache_backend = CacheBackend()
cache_backend.check_status()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/tests/test_commands.py
new/django-health-check-3.14.0/tests/test_commands.py
--- old/django-health-check-3.12.1/tests/test_commands.py 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/tests/test_commands.py 2020-09-16
08:01:23.000000000 +0200
@@ -1,12 +1,11 @@
from io import StringIO
import pytest
+from django.core.management import call_command
from health_check.backends import BaseHealthCheckBackend
from health_check.plugins import plugin_dir
-from django.core.management import call_command
-
class FailPlugin(BaseHealthCheckBackend):
def check_status(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/tests/test_migrations.py
new/django-health-check-3.14.0/tests/test_migrations.py
--- old/django-health-check-3.12.1/tests/test_migrations.py 1970-01-01
01:00:00.000000000 +0100
+++ new/django-health-check-3.14.0/tests/test_migrations.py 2020-09-16
08:01:23.000000000 +0200
@@ -0,0 +1,26 @@
+from django.db.migrations import Migration
+from django.test import TestCase
+from mock import patch
+
+from health_check.contrib.migrations.backends import MigrationsHealthCheck
+
+
+class MockMigration(Migration):
+ ...
+
+
+class TestMigrationsHealthCheck(TestCase):
+
+ def test_check_status_work(self):
+ with
patch('health_check.contrib.migrations.backends.MigrationsHealthCheck.get_migration_plan',
+ return_value=[]):
+ backend = MigrationsHealthCheck()
+ backend.run_check()
+ self.assertFalse(backend.errors)
+
+ def test_check_status_raises_error_if_there_are_migrations(self):
+ with
patch('health_check.contrib.migrations.backends.MigrationsHealthCheck.get_migration_plan',
+ return_value=[(MockMigration, False)]):
+ backend = MigrationsHealthCheck()
+ backend.run_check()
+ self.assertTrue(backend.errors)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/tests/test_views.py
new/django-health-check-3.14.0/tests/test_views.py
--- old/django-health-check-3.12.1/tests/test_views.py 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/tests/test_views.py 2020-09-16
08:01:23.000000000 +0200
@@ -49,6 +49,7 @@
('*/*;v=b3', MediaType('*/*')),
('*/*; q=0.5; v=b3', MediaType('*/*', 0.5)),
]
+
@pytest.mark.parametrize("type, expected", valid_strings)
def test_from_valid_strings(self, type, expected):
assert MediaType.from_string(type) == expected
@@ -59,6 +60,7 @@
'text/html; xxx',
'text/html; =a',
]
+
@pytest.mark.parametrize("type", invalid_strings)
def test_from_invalid_strings(self, type):
with pytest.raises(ValueError) as e:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-health-check-3.12.1/tests/testapp/settings.py
new/django-health-check-3.14.0/tests/testapp/settings.py
--- old/django-health-check-3.12.1/tests/testapp/settings.py 2020-01-14
16:53:51.000000000 +0100
+++ new/django-health-check-3.14.0/tests/testapp/settings.py 2020-09-16
08:01:23.000000000 +0200
@@ -9,6 +9,10 @@
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
+ },
+ 'other': { # 2nd database conneciton to ensure proper connection handling
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':backup:',
}
}
@@ -23,6 +27,7 @@
'health_check.db',
'health_check.storage',
'health_check.contrib.celery',
+ 'health_check.contrib.migrations',
'health_check.contrib.s3boto_storage',
'tests',
)