Provoke predictable errors in your Django projects.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs/_static
sabot
.gitignore
AUTHORS.rst
CREDITS
HISTORY.rst
LICENSE
MANIFEST.in
README.rst
requirements.txt
setup.cfg
setup.py

README.rst

Sabot: Controlled failure for Django

Logo

Description

Provoke predictable errors in your Django projects. Raise OperationalErrors to see how well your project handle database connection errors. Ideal for failure tolerance testing.

Blog post: http://blog.robertorosario.com/testing-django-project-infrastructure-failure-tolerance/

License

This project is open sourced under the MIT License.

Installation

$ pip install django-sabot
  • Add 'sabot', to your project's INSTALLED_APPS list.
  • Add some sabot patches in your settings.py file.

Usage

In you settings.py file:

from django.db import OperationalError

from sabot.import *

SABOT_PATCHES = (
    ConnectPatcher(error_generator=RandomErrorProducer, kwargs={'low': 1, 'high': 3}),
    CursorPatcher(error_producer=RandomErrorProducer, kwargs={'exception': OperationalError, 'low': 1, 'high': 10}),
    CursorPatcher(error_producer=CountErrorProducer, kwargs={'exception': OperationalError, 'number': 100, 'reset': True}),
    CursorPatcher(error_producer=TimeDeltaErrorProducer, kwargs={'exception': OperationalError, 'timedelta': {'seconds': 30}, 'reset': True}),
)

A django-sabot patch is composed of a monkey patcher class and an error producer class.

For example:

CursorPatcher(error_producer=TimeDeltaErrorProducer, kwargs={'exception': OperationalError, 'timedelta': {'seconds': 30}, 'reset': True}),

will produce an OperationalError when a database cursor is requested, every 30 seconds.

Contribute

  • Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
  • Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).
  • Write a test which shows that the bug was fixed or that the feature works as expected.
  • Make sure to add yourself to the AUTHORS file.
  • Send a pull request