Skip to main content

Simulates Docker container and network failures to test application resilience

Project description

sabotage

Codecov PyPI PyPI - Downloads Python Version

sabotage is a package designed to assist developers in testing the resilience and fault tolerance of applications running in Docker containers. It offers functionality to simulate failures by either temporarily stopping containers (sabotaged_container) or disconnecting them from their networks (sabotaged_network).

Installation

$ pip3 install sabotage

Usage

  1. sabotaged_container

Temporarily stops a specified Docker container and restarts it after performing tasks within the context. Useful for testing how applications handle Docker container failures.

import asyncio
from sabotage import sabotaged_container

async def test_container_restart():
    async with sabotaged_container(service_name="webapp"):
        # Perform actions while the container is stopped
        print("Container is temporarily stopped.")

    # Actions after the container restarts
    print("Container has restarted.")

asyncio.run(test_container_restart())
  1. sabotaged_network

Disconnects and reconnects a container from its networks to simulate network issues.

import asyncio
from sabotage import sabotaged_network

async def test_network_disruption():
    async with sabotaged_network(service_name="webapp"):
        # Perform actions while the network is disconnected
        print("Network is temporarily disconnected.")

    # Actions after the network is reconnected
    print("Network has been reconnected.")

asyncio.run(test_network_disruption())

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

sabotage-1.0.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sabotage-1.0.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file sabotage-1.0.0.tar.gz.

File metadata

  • Download URL: sabotage-1.0.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for sabotage-1.0.0.tar.gz
Algorithm Hash digest
SHA256 735e3183abfdf925ef155c7f1e88be2cfb4a5cd3aa0f221ebfa0b629c71dab23
MD5 30561ecb27c84f38fd35eb291ba2bf1c
BLAKE2b-256 fe44740de1cda09e0e415eb0687b055e582ca3126965f859ae0ac06b7b0acf3b

See more details on using hashes here.

File details

Details for the file sabotage-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sabotage-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for sabotage-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b567451cd225be8dc749977ef9998ad8707a06937250235ad3c4c422c6d73a
MD5 ed08fc290159a1af750afc7c54b38edd
BLAKE2b-256 8edbff6f54c9c5caa27f5a8860a8ab0ff3ce411259799752df19b97226fbbf6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page