Healthchecks for Python.
Project description
#################################
hospital: healthchecks for Python
#################################
`hospital` makes it easy to setup and use health checks in Python.
Health checks are kind of tests applied to running applications and services.
**********
Quickstart
**********
Write health checks
===================
Write health checks just like you would write tests. The main difference is
their scope: they check "production" facts instead of mocks/fakes/dummies.
Health checks are special kind of tests. Use :func:`~hospital.core.healthcheck`
decorator to differenciate health checks from tests.
Just like tests, health checks can be simple functions that perform assertions:
.. code:: python
import sys
import hospital
@hospital.healthcheck
def test_python_version():
"""Python version >= 2."""
assert sys.version_info[0] >= 2
You can reuse test libraries, like :mod:`unittest`:
.. code:: python
import unittest
import hospital
@hospital.healthcheck
class DocumentationHealthCheck(unittest.TestCase):
"""Check `hospital` online documentation."""
def test_ping(self):
"""`hospital` documentation server responds to ping."""
hostname = 'hospital.readthedocs.org'
hospital.assert_ping(hostname)
def test_http_200(self):
"""`hospital` online documentation returns HTTP 200."""
url = 'http://hospital.readthedocs.org/en/0.1/'
hospital.assert_http_response(url, status_code=200)
`Hospital` provides a set of useful assertions and health check suites.
Run health checks
=================
Run health checks to make sure everything is ok. As an example, run health
checks after a deployment to verify configuration, services...
Health checks are tests having a ``is_healthcheck`` attribute which is
``True``. Let's use this feature to capture and run the tests.
With `nose` (here we run health checks of `hospital` project):
.. code:: sh
nosetests --no-path-adjustment --all-modules --attr="is_healthcheck" hospital
.. tip::
You may want to skip health checks when you run unit/functional/integration
tests. With `nose`, it could be:
.. code:: sh
nosetests --no-path-adjustment --all-modules --attr="!is_healthcheck" hospital
Plug in supervision, monitoring
===============================
Include health checks in supervision/monitoring tools.
Diagnose
========
In case of incidents, use health checks to diagnose problems.
*********
Resources
*********
* Documentation: https://hospital.readthedocs.org
* IRC: ``#python-hospital`` on freenode
* Mailing-list: ``pythonhospital@librelist.com``,
see archives at http://librelist.com/browser/pythonhospital/
* PyPI page: https://pypi-hypernode.com/pypi/hospital
* Code repository: https://github.com/python-hospital/hospital
* Bugs & feature requests: https://github.com/python-hospital/hospital/issues
* Roadmap: https://github.com/python-hospital/hospital/issues/milestones
* Continuous integration: https://travis-ci.org/python-hospital/hospital
hospital: healthchecks for Python
#################################
`hospital` makes it easy to setup and use health checks in Python.
Health checks are kind of tests applied to running applications and services.
**********
Quickstart
**********
Write health checks
===================
Write health checks just like you would write tests. The main difference is
their scope: they check "production" facts instead of mocks/fakes/dummies.
Health checks are special kind of tests. Use :func:`~hospital.core.healthcheck`
decorator to differenciate health checks from tests.
Just like tests, health checks can be simple functions that perform assertions:
.. code:: python
import sys
import hospital
@hospital.healthcheck
def test_python_version():
"""Python version >= 2."""
assert sys.version_info[0] >= 2
You can reuse test libraries, like :mod:`unittest`:
.. code:: python
import unittest
import hospital
@hospital.healthcheck
class DocumentationHealthCheck(unittest.TestCase):
"""Check `hospital` online documentation."""
def test_ping(self):
"""`hospital` documentation server responds to ping."""
hostname = 'hospital.readthedocs.org'
hospital.assert_ping(hostname)
def test_http_200(self):
"""`hospital` online documentation returns HTTP 200."""
url = 'http://hospital.readthedocs.org/en/0.1/'
hospital.assert_http_response(url, status_code=200)
`Hospital` provides a set of useful assertions and health check suites.
Run health checks
=================
Run health checks to make sure everything is ok. As an example, run health
checks after a deployment to verify configuration, services...
Health checks are tests having a ``is_healthcheck`` attribute which is
``True``. Let's use this feature to capture and run the tests.
With `nose` (here we run health checks of `hospital` project):
.. code:: sh
nosetests --no-path-adjustment --all-modules --attr="is_healthcheck" hospital
.. tip::
You may want to skip health checks when you run unit/functional/integration
tests. With `nose`, it could be:
.. code:: sh
nosetests --no-path-adjustment --all-modules --attr="!is_healthcheck" hospital
Plug in supervision, monitoring
===============================
Include health checks in supervision/monitoring tools.
Diagnose
========
In case of incidents, use health checks to diagnose problems.
*********
Resources
*********
* Documentation: https://hospital.readthedocs.org
* IRC: ``#python-hospital`` on freenode
* Mailing-list: ``pythonhospital@librelist.com``,
see archives at http://librelist.com/browser/pythonhospital/
* PyPI page: https://pypi-hypernode.com/pypi/hospital
* Code repository: https://github.com/python-hospital/hospital
* Bugs & feature requests: https://github.com/python-hospital/hospital/issues
* Roadmap: https://github.com/python-hospital/hospital/issues/milestones
* Continuous integration: https://travis-ci.org/python-hospital/hospital
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hospital-0.2.zip
(19.5 kB
view details)
File details
Details for the file hospital-0.2.zip
.
File metadata
- Download URL: hospital-0.2.zip
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb0360cc5af67781babd68a796f52a1be0503dedb26f68cbbbe58af297bbeac4 |
|
MD5 | 85c7d27238dbe4f74b660c4592514c46 |
|
BLAKE2b-256 | 033862c637a1f632b5e37714ff2636db5cf4eacae611ce8e68ec5e0d2a4f2611 |