sabotage
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
📦 Sabotaged Container
@asynccontextmanager
async def sabotaged_container(service_name: str,
project_name: Optional[str] = None,
*,
wait_timeout: float = 30.0,
wait_interval: float = 0.01
) -> AsyncGenerator[None, None]:
Temporarily stops a specified Docker container and restarts it after performing tasks within the context. Useful for testing how applications handle Docker container failures.
Parameters:
service_name(str): The name of the Docker service.project_name(str): (Optional) The Docker Compose project name. If not provided, it defaults to theCOMPOSE_PROJECT_NAMEenvironment variable.wait_timeout(float): (Optional) The maximum time to wait for the container to become healthy upon restart.wait_interval(float): (Optional) The polling interval to check the container's health status.
import asyncio
from sabotage import sabotaged_container
async def test_container_restart():
async with sabotaged_container("app"):
# 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())
🌐 Sabotaged Network
@asynccontextmanager
async def sabotaged_network(service_name: str,
project_name: Optional[str] = None
) -> AsyncGenerator[None, None]:
Disconnects and reconnects a container from its networks to simulate network issues.
service_name(str): The name of the Docker service.project_name(str): (Optional) The Docker Compose project name. If not provided, it defaults to theCOMPOSE_PROJECT_NAMEenvironment variable.
import asyncio
from sabotage import sabotaged_network
async def test_network_disruption():
async with sabotaged_network("app"):
# 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())
Metadata
Release files for sabotage 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sabotage-1.0.1.tar.gz | 9.9 kB | Without provenance | Details for sabotage-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sabotage-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for sabotage-1.0.1-py3-none-any.whl |
Total release size: 20.2 kB
Release files / sabotage-1.0.1.tar.gz
| Download URL | sabotage-1.0.1.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ad68f12b84998c6a547c7db2f09cc7fd0db029d45acf9961800106de08da94d
|
|
BLAKE2b-256 checksum How to use checksums |
5ce4c44b2384d46bf867016fc138b815cb3442279f2c3e91dd05ef626241b1d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.9
|
Release files / sabotage-1.0.1-py3-none-any.whl
| Download URL | sabotage-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d744c2336b275e018909ae03d2e2bf8301dc01a73281632e9828508e5cc47a72
|
|
BLAKE2b-256 checksum How to use checksums |
1c7f090b46f609183e04a558ee728c103a559a8cd17859ede766f0ca1d27976c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.9
|
Security for sabotage 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.